public override void onAdd(GameBase obj)
        {
            WheeledVehicle wheeledvehicle = obj._ID;

            base.onAdd(obj);
            //int nsd = (nameSpaceDepth + 1);
            //console.ParentExecute(thisobj, "onAdd", nsd, new string[] { thisobj, obj });
            // Setup the car with some tires & springs
            for (int i = wheeledvehicle.getWheelCount() - 1; i >= 0; i--)
            {
                wheeledvehicle.setWheelTire(i, "CheetahCarTire");
                wheeledvehicle.setWheelSpring(i, "CheetahCarSpring");
                wheeledvehicle.setWheelPowered(i, false);
            }
            // Steer with the front tires
            wheeledvehicle.setWheelSteering(0, 1);
            wheeledvehicle.setWheelSteering(1, 1);

            // Only power the two rear wheels... assuming there are only 4 wheels.
            wheeledvehicle.setWheelPowered(2, true);
            wheeledvehicle.setWheelPowered(3, true);
        }
Esempio n. 2
0
        public override void onCollision(ShapeBase obj, SceneObject col, Point3F vec, float len)
        {
            Player player = obj.getId();

            if (player.getState() == "Dead")
            {
                return;
            }
            // Try and pickup all items
            if (col.getClassName() == "Item")
            {
                player.pickup(col.ID, 1);
                return;
            }

            if (col.GetType() != typeof(WheeledVehicle))
            {
                return;
            }

            WheeledVehicle vcol = (WheeledVehicle)col;

            //AI are not allowed to drive they are lousey drivers....
            GameConnection client = player["client"];

            if (!client.isObject())
            {
                return;
            }
            //Mount Vehicle.
            if ((console.getTypeMask(col) & (UInt32)SceneObjectTypesAsUint.GameBaseObjectType) != (UInt32)SceneObjectTypesAsUint.GameBaseObjectType)
            {
                return;
            }
            VehicleData db = vcol.getDataBlock();

            if (!(((db.getClassName() == "WheeledVehicleData") || player["mountVehicle"].AsBool() || player.getState() == "Move" || col["mountable"].AsBool())))
            {
                return;
            }
            // Only mount drivers for now.

            // For this specific example, only one person can fit
            // into a vehicle
            int mount = vcol.getMountNodeObject(0);

            if (mount > 0)
            {
                try
                {
                    Player p = mount;
                    return;
                }
                catch (Exception err)
                {
                    //Water particle emitters seem to take up the seat when the vehicle is in water.
                    vcol.unmountObject(mount.AsString());
                    vcol.mountObject(player, 0, new TransformF());
                    ((GameConnection)player["client"]).setFirstPerson(false);
                    console.commandToClient(client, "PushVehicleMap");
                }
            }
            else
            {
                vcol.mountObject(player, 0, new TransformF());
                ((GameConnection)player["client"]).setFirstPerson(false);
                console.commandToClient(client, "PushVehicleMap");
            }
            //if (mount > 0)
            //return;
            // For this specific FPS Example, always mount the player to node 0

            player["mVehicle"] = col;
        }