示例#1
0
        /// <summary>
        /// Creates a wheel.
        /// </summary>
        /// <param name="wheelName">
        /// The name of the wheel type you want to create. Should be the same as the filename, minus the extension. Case sensitive!
        /// </param>
        public Wheel CreateWheel(string wheelName, WheelID ID, Kart owner, Vector3 position, string meshName)
        {
            IDictionary<string, float> dict = wheels[wheelName];

            Wheel wheel = new Wheel(owner, position, ID, dict, meshName);

            return wheel;
        }
        public static WheelState GetVehicleWheelState(Vehicle veh, WheelID wheel)
        {
            VehicleSyncData data = GetVehicleSyncData(veh);

            if (data == default(VehicleSyncData))
            {
                data = new VehicleSyncData();
                UpdateVehicleSyncData(veh, data);
            }
            return((WheelState)data.Wheel[(int)wheel]);
        }
        public static void SetVehicleWheelState(Vehicle veh, WheelID wheel, WheelState state)
        {
            VehicleSyncData data = GetVehicleSyncData(veh);

            if (data == default(VehicleSyncData))
            {
                data = new VehicleSyncData();
            }

            data.Wheel[(int)wheel] = (int)state;
            UpdateVehicleSyncData(veh, data);
            NAPI.ClientEvent.TriggerClientEventInDimension(veh.Dimension, "VehStream_SetVehicleWheelStatus_Single", veh.Handle, (int)wheel, (int)state);
        }
示例#4
0
 /// <summary>
 /// Gets a wheel
 /// </summary>
 public Wheel GetWheel(WheelID wid)
 {
     switch (wid) {
         case WheelID.FrontLeft:
             return WheelFL;
         case WheelID.FrontRight:
             return WheelFR;
         case WheelID.BackLeft:
             return WheelBL;
         case WheelID.BackRight:
             return WheelBR;
         default:
             throw new ArgumentOutOfRangeException("wid", "Invalid wheel ID number!");
     }
 }
示例#5
0
 /// <summary>
 /// Depending on the wheel's ID and our drift state, this determines what its motor force should be, since the karts are rear-wheel drive
 /// </summary>
 private float GetMotorForceForDriftState(WheelID id, WheelDriftState driftState, float motorForce)
 {
     if (driftState == WheelDriftState.None) {
         if (id == WheelID.BackLeft || id == WheelID.BackRight)
             return motorForce;
     }
     else if (driftState == WheelDriftState.Left) {
         if (id == WheelID.FrontRight || id == WheelID.BackRight)
             return motorForce;
     }
     else if (driftState == WheelDriftState.Right) {
         if (id == WheelID.FrontLeft || id == WheelID.BackLeft)
             return motorForce;
     }
     return 0f;
 }
示例#6
0
        /// <summary>
        /// This should only be used by the WheelFactory
        /// </summary>
        /// <param name="owner">Which kart is the wheel attached to?</param>
        /// <param name="connectionPoint">Where is the wheel attached?</param>
        /// <param name="wheelID">ID number of the wheel</param>
        /// <param name="dict">The properties and values from the .wheel file this wheel was built from</param>
        /// <param name="meshName">The filename of the mesh we should use for this wheel</param>
        public Wheel(Kart owner, Vector3 connectionPoint, WheelID wheelID, IDictionary<string, float> dict, string meshName)
        {
            // set up these
            kart = owner;
            ID = wheelID;
            vehicle = kart.Vehicle;

            // set up our readonlies
            DefaultRadius = dict["Radius"];
            DefaultWidth = dict["Width"];
            DefaultSuspensionRestLength = dict["SuspensionRestLength"];
            DefaultSpringStiffness = dict["SpringStiffness"];
            DefaultSpringCompression = dict["SpringCompression"];
            DefaultSpringDamping = dict["SpringDamping"];
            Friction = dict["FrictionSlip"];
            DefaultRollInfluence = dict["RollInfluence"];
            DefaultBrakeForce = dict["BrakeForce"];
            DefaultMotorForce = dict["MotorForce"];
            DefaultMaxTurnAngle = new Degree(dict["TurnAngle"]).ValueRadians;
            DefaultSlowSpeed = dict["SlowSpeed"];
            DefaultHighSpeed = dict["HighSpeed"];
            DefaultSlowTurnAngleMultiplier = dict["SlowTurnAngleMultiplier"];
            DefaultSlowTurnSpeedMultiplier = dict["SlowTurnSpeedMultiplier"];
            DefaultDriftingTurnAngle = new Degree(dict["DriftingTurnAngle"]).ValueRadians;
            DefaultDriftingTurnSpeed = new Degree(dict["DriftingTurnSpeed"]).ValueRadians;
            DefaultSteerIncrementTurn = new Degree(dict["SteerIncrementTurn"]).ValueRadians;
            DefaultSteerDecrementTurn = new Degree(dict["SteerDecrementTurn"]).ValueRadians;

            // give our fields some default values
            AccelerateMultiplier = 0;
            TurnMultiplier = 0;
            IsBrakeOn = false;
            DriftState = WheelDriftState.None;
            IntWheelID = (int) wheelID;
            DefaultFrictionSlip = Friction;
            IdealSteerAngle = 0f;

            // need to tell bullet whether it's a front wheel or not
            bool isFrontWheel;
            if (ID == WheelID.FrontLeft || ID == WheelID.FrontRight)
                isFrontWheel = true;
            else
                isFrontWheel = false;

            vehicle.AddWheel(connectionPoint, WheelDirection, WheelAxle, DefaultSuspensionRestLength, DefaultRadius, kart.Tuning, isFrontWheel);

            WheelInfo info = vehicle.GetWheelInfo(IntWheelID);
            info.SuspensionStiffness = DefaultSpringStiffness;
            info.WheelDampingRelaxation = DefaultSpringDamping;
            info.WheelDampingCompression = DefaultSpringCompression;
            info.FrictionSlip = Friction;
            info.RollInfluence = DefaultRollInfluence;

            AxlePoint = connectionPoint + new Vector3(0, -DefaultSuspensionRestLength, 0);

            // create our node and entity
            Node = owner.RootNode.CreateChildSceneNode("wheelNode" + kart.ID + ID, AxlePoint);
            Entity = LKernel.GetG<SceneManager>().CreateEntity("wheelNode" + kart.ID + ID, meshName);
            Node.AttachObject(Entity);
            Node.InheritOrientation = false;

            Node.Orientation = kart.ActualOrientation;

            // and then hook up to the event
            PhysicsMain.PostSimulate += PostSimulate;
        }