/* Copyright 2003-2005 ROBLOX Corporation, All Rights Reserved */ #pragma once #include "V8DataModel/PartInstance.h" #include "V8DataModel/Seat.h" namespace RBX { class RotateJoint; class RotateVJoint; class Humanoid; class VehicleController; extern const char* const sVehicleSeat; class VehicleSeat : public DescribedCreatable, sVehicleSeat> , public KernelJoint { private: typedef DescribedCreatable, sVehicleSeat> Super; // saves float maxSpeed; float turnSpeed; float torque; // dominates low-end startup performance bool enableHud; // only for controller/seat interface int throttle; // -1, 0, 1 back, forward int steer; // -1, 0, 1 left to right World* world; G3D::Array hinges; G3D::Array onRights; G3D::Array axlePointingIns; G3D::Array axleVelocities; weak_ptr myController; int computeNumHinges(); void doLoadHinges(Primitive* primitive); void loadMotorsAndHinges(); void getJointInfo(RotateJoint* rotateJoint, bool& aligned, bool& onRight, bool& axlePointingIn); void stepHinges(); int lookupFunction(int throttle, int steer, bool onRight, bool overMaxSpeed, bool overTurnSpeed, float jointVelocity); ////////////////////////////////////////////////////////////////////////// // Instance /*override*/ void onAncestorChanged(const AncestorChanged& event); /*override*/ void onServiceProvider(ServiceProvider* oldProvider, ServiceProvider* newProvider); ////////////////////////////////////////////////////////////////////////// // Seat /*override*/ void onSeatedChanged(bool seated, Humanoid* humanoid); /*override*/ void createSeatWeld(Humanoid *h); /*override*/ void findAndDestroySeatWeld(); /*override*/ void setOccupant(Humanoid* value); /////////////////////////////////////////////////////////////////////////// // KernelJoint / Connector /*override*/ void computeForce(bool throttling); /*override*/ Body* getEngineBody(); /*override*/ bool canStepUi() const {return true;} /*override*/ bool stepUi(double distributedGameTime); /////////////////////////////////////////////////////////////////////////// // IAdornable /*override*/ bool shouldRender2d() const; /*override*/ void render2d(Adorn* adorn); /////////////////////////////////////////////////////////////////////////// // CameraSubject /*override*/ void getCameraIgnorePrimitives(std::vector& primitives); void onLocalSeated(Humanoid* humanoid); void onLocalUnseated(Humanoid* humanoid); public: rbx::remote_signal)> createSeatWeldSignal; rbx::remote_signal destroySeatWeldSignal; VehicleSeat(); virtual ~VehicleSeat(); int getNumHinges() const; void setThrottle(int value); int getThrottle() const {return throttle;} void setEnableHud(bool value); bool getEnableHud() const { return enableHud; } void setSteer(int value); int getSteer() const {return steer;} void setMaxSpeed(float value); float getMaxSpeed() const {return maxSpeed;} void setTurnSpeed(float value); float getTurnSpeed() const {return turnSpeed;} void setTorque(float value); float getTorque() const {return torque;} Humanoid* getLocalHumanoid(); }; } // namespace