コード例 #1
0
ファイル: Vehicle.cs プロジェクト: Winterleaf/OmniEngine.Net
 public override void onRemove(GameBase obj)
 {
     // if there are passengers/driver, kick them out
     for (int i = 0; i < ((VehicleData)obj.getDataBlock())["numMountPoints"].AsInt(); i++)
     {
         if (!((SimObject)obj.getMountNodeObject(i)).isMemberOfClass("Player"))
         {
             continue;
         }
         Player passenger = obj.getMountNodeObject(i);
         if (passenger != "0")
         {
             PlayerData passengerdatablock = passenger.getDataBlock();
             passengerdatablock.doDismount(passenger);
         }
     }
 }
コード例 #2
0
        public virtual void teleFrag(GameBase player, Trigger exit)
        {
            // When a telefrag happens, there are two cases we have to consider.
            // The first case occurs when the player's bounding box is much larger than the exit location,
            // it is possible to have players colide even though a player is not within the bounds
            // of the trigger Because of this we first check a radius the size of a player's bounding
            // box around the exit location.

            // Get the bounding box of the player

            Point3F boundingBoxSize = new Point3F(((PlayerData)player.getDataBlock())["boundingBox"]);
            float   radius          = boundingBoxSize.x;
            float   boxSizeY        = boundingBoxSize.y;
            float   boxSizeZ        = boundingBoxSize.z;

            // Use the largest dimention as the radius to check
            if (boxSizeY > radius)
            {
                radius = boxSizeY;
            }
            if (boxSizeZ > radius)
            {
                radius = boxSizeZ;
            }

            Point3F position = exit.getTransform().GetPosition(); // new TransformF(con.getTransform(exit));
            uint    mask     = (uint)SceneObjectTypesAsUint.PlayerObjectType;

            // Check all objects within the found radius of the exit location, and telefrag
            // any players that meet the conditions.

            Dictionary <uint, float> r = console.initContainerRadiusSearch(position, radius, mask);

            foreach (ShapeBase objectNearExit in
                     r.Keys.Where(objectNearExit => ((ShapeBase)objectNearExit).isMemberOfClass("Player")).Where(objectNearExit => objectNearExit.AsString() != player))
            {
                objectNearExit.damage(player, exit.getTransform().GetPosition(), 10000, "Telefrag");
            }
            // The second case occurs when the bounds of the trigger are much larger
            // than the bounding box of the player. (So multiple players can exist within the
            // same trigger). For this case we check all objects contained within the trigger
            // and telefrag all players.

            int objectsInExit = exit.getNumObjects();

            // Loop through all objects in the teleporter exit
            // And kill any players
            for (int i = 0; i < objectsInExit; i++)
            {
                ShapeBase objectInTeleporter = console.Call(exit, "getObject", new[] { i.AsString() });
                if (objectInTeleporter.isMemberOfClass("Player"))
                {
                    continue;
                }
                // Avoid killing the player that is teleporting in the case of two
                // Teleporters near eachother.
                if (objectInTeleporter == player)
                {
                    continue;
                }

                objectInTeleporter.damage(player, exit.getTransform().GetPosition(), 10000, "Telefrag");
            }
        }