コード例 #1
0
ファイル: Vehicles.cs プロジェクト: MaudiTemp/Nitrox
        /*
         * A poorly timed movement packet will cause major problems when docking because the remote
         * player will think that the player is no longer in a vehicle.  Unfortunetly, the game calls
         * the vehicle exit code before the animation completes so we need to suppress any side affects.
         * Two thing we want to protect against:
         *
         *   1) If a movement packet is received when docking, the player might exit the vehicle early
         *      and it will show them sitting outside the vehicle during the docking animation.
         *
         *   2) If a movement packet is received when undocking, the player game object will be stuck in
         *      place until after the player exits the vehicle.  This causes the player body to strech to
         *      the current cyclops position.
         */
        public IEnumerator AllowMovementPacketsAfterDockingAnimation(PacketSuppressor <Movement> movementSuppressor, PacketSuppressor <VehicleMovement> vehicleMovementSuppressor)
        {
            yield return(new WaitForSeconds(3.0f));

            movementSuppressor.Dispose();
            vehicleMovementSuppressor.Dispose();
        }
コード例 #2
0
        public void BroadcastVehicleDocking(VehicleDockingBay dockingBay, Vehicle vehicle)
        {
            NitroxId dockId;

            if (dockingBay.GetSubRoot() is BaseRoot)
            {
                dockId = NitroxEntity.GetId(dockingBay.GetComponentInParent <BaseRoot>().gameObject);
            }
            else if (dockingBay.GetSubRoot() is SubRoot)
            {
                dockId = NitroxEntity.GetId(dockingBay.GetSubRoot().gameObject);
            }
            else
            {
                dockId = NitroxEntity.GetId(dockingBay.GetComponentInParent <ConstructableBase>().gameObject);
            }

            NitroxId vehicleId = NitroxEntity.GetId(vehicle.gameObject);
            ushort   playerId  = multiplayerSession.Reservation.PlayerId;

            VehicleDocking packet = new VehicleDocking(vehicleId, dockId, playerId);

            packetSender.Send(packet);

            PacketSuppressor <Movement> movementSuppressor = packetSender.Suppress <Movement>();

            vehicle.StartCoroutine(AllowMovementPacketsAfterDockingAnimation(movementSuppressor));
        }
コード例 #3
0
ファイル: Vehicles.cs プロジェクト: MaudiTemp/Nitrox
        public void BroadcastVehicleUndocking(VehicleDockingBay dockingBay, Vehicle vehicle, bool undockingStart)
        {
            NitroxId dockId;

            if (dockingBay.GetSubRoot() is BaseRoot)
            {
                dockId = NitroxEntity.GetId(dockingBay.GetComponentInParent <BaseRoot>().gameObject);
            }
            else if (dockingBay.GetSubRoot() is SubRoot)
            {
                dockId = NitroxEntity.GetId(dockingBay.GetSubRoot().gameObject);
            }
            else
            {
                dockId = NitroxEntity.GetId(dockingBay.GetComponentInParent <ConstructableBase>().gameObject);
            }

            NitroxId vehicleId = NitroxEntity.GetId(vehicle.gameObject);
            ushort   playerId  = multiplayerSession.Reservation.PlayerId;

            PacketSuppressor <Movement>        movementSuppressor        = packetSender.Suppress <Movement>();
            PacketSuppressor <VehicleMovement> vehicleMovementSuppressor = packetSender.Suppress <VehicleMovement>();

            if (!undockingStart)
            {
                movementSuppressor.Dispose();
                vehicleMovementSuppressor.Dispose();
            }

            VehicleUndocking packet = new VehicleUndocking(vehicleId, dockId, playerId, undockingStart);

            packetSender.Send(packet);
        }
コード例 #4
0
 public static void Postfix(PacketSuppressor <ItemContainerRemove> __state)
 {
     if (__state != null)
     {
         __state.Dispose();
     }
 }
コード例 #5
0
 public static bool Prefix(SeaMoth __instance, TechType techType, int slotID, PacketSuppressor <ItemContainerRemove> __state)
 {
     if (techType == TechType.SeamothElectricalDefense)
     {
         NitroxServiceLocator.LocateService <SeamothModulesEvent>().BroadcastElectricalDefense(techType, slotID, __instance);
     }
     else if (techType == TechType.SeamothTorpedoModule)
     {
         __state = NitroxServiceLocator.LocateService <IPacketSender>().Suppress <ItemContainerRemove>();
         NitroxServiceLocator.LocateService <SeamothModulesEvent>().BroadcastTorpedoLaunch(techType, slotID, __instance);
     }
     return(true);
 }
コード例 #6
0
        public void BroadcastVehicleUndocking(VehicleDockingBay dockingBay, Vehicle vehicle)
        {
            string dockGuid    = GuidHelper.GetGuid(dockingBay.gameObject);
            string vehicleGuid = GuidHelper.GetGuid(vehicle.gameObject);
            ushort playerId    = multiplayerSession.Reservation.PlayerId;

            VehicleUndocking packet = new VehicleUndocking(vehicleGuid, dockGuid, playerId);

            packetSender.Send(packet);

            PacketSuppressor <Movement> movementSuppressor = packetSender.Suppress <Movement>();

            vehicle.StartCoroutine(AllowMovementPacketsAfterDockingAnimation(movementSuppressor));
        }
コード例 #7
0
        public void BroadcastVehicleDocking(VehicleDockingBay dockingBay, Vehicle vehicle)
        {
            NitroxId dockId = NitroxEntity.GetId(dockingBay.gameObject);


            NitroxId vehicleId = NitroxEntity.GetId(vehicle.gameObject);
            ushort   playerId  = multiplayerSession.Reservation.PlayerId;

            VehicleDocking packet = new VehicleDocking(vehicleId, dockId, playerId);

            packetSender.Send(packet);

            PacketSuppressor <Movement>        movementSuppressor        = packetSender.Suppress <Movement>();
            PacketSuppressor <VehicleMovement> vehicleMovementSuppressor = packetSender.Suppress <VehicleMovement>();

            vehicle.StartCoroutine(AllowMovementPacketsAfterDockingAnimation(movementSuppressor, vehicleMovementSuppressor));
        }
コード例 #8
0
        public static bool Prefix(SeaMoth __instance, TechType techType, int slotID, out PacketSuppressor <ItemContainerRemove> __state)
        {
            __state = null;

            switch (techType)
            {
            case TechType.SeamothElectricalDefense:
                Resolve <SeamothModulesEvent>().BroadcastElectricalDefense(techType, slotID, __instance);
                break;

            case TechType.SeamothTorpedoModule:
                __state = Resolve <IPacketSender>().Suppress <ItemContainerRemove>();
                Resolve <SeamothModulesEvent>().BroadcastTorpedoLaunch(techType, slotID, __instance);
                break;
            }

            return(true);
        }
コード例 #9
0
        public void BroadcastVehicleUndocking(VehicleDockingBay dockingBay, Vehicle vehicle, bool undockingStart)
        {
            NitroxId dockId = NitroxEntity.GetId(dockingBay.gameObject);

            NitroxId vehicleId = NitroxEntity.GetId(vehicle.gameObject);
            ushort   playerId  = multiplayerSession.Reservation.PlayerId;

            PacketSuppressor <Movement>        movementSuppressor        = packetSender.Suppress <Movement>();
            PacketSuppressor <VehicleMovement> vehicleMovementSuppressor = packetSender.Suppress <VehicleMovement>();

            if (!undockingStart)
            {
                movementSuppressor.Dispose();
                vehicleMovementSuppressor.Dispose();
            }

            VehicleUndocking packet = new VehicleUndocking(vehicleId, dockId, playerId, undockingStart);

            packetSender.Send(packet);
        }
コード例 #10
0
        public void BroadcastVehicleDocking(VehicleDockingBay dockingBay, Vehicle vehicle)
        {
            string dockGuid = string.Empty;

            if (dockingBay.GetSubRoot() is BaseRoot)
            {
                dockGuid = GuidHelper.GetGuid(dockingBay.GetComponentInParent <BaseRoot>().gameObject);
            }
            else
            {
                dockGuid = GuidHelper.GetGuid(dockingBay.GetComponentInParent <ConstructableBase>().gameObject);
            }

            string vehicleGuid = GuidHelper.GetGuid(vehicle.gameObject);
            ushort playerId    = multiplayerSession.Reservation.PlayerId;

            VehicleDocking packet = new VehicleDocking(vehicleGuid, dockGuid, playerId);

            packetSender.Send(packet);

            PacketSuppressor <Movement> movementSuppressor = packetSender.Suppress <Movement>();

            vehicle.StartCoroutine(AllowMovementPacketsAfterDockingAnimation(movementSuppressor));
        }
コード例 #11
0
ファイル: Vehicles.cs プロジェクト: willchris2/Nitrox
 /*
  A poorly timed movement packet will cause major problems when docking because the remote 
  player will think that the player is no longer in a vehicle.  Unfortunetly, the game calls
  the vehicle exit code before the animation completes so we need to suppress any side affects.
  Two thing we want to protect against:
 
      1) If a movement packet is received when docking, the player might exit the vehicle early
         and it will show them sitting outside the vehicle during the docking animation.
  
      2) If a movement packet is received when undocking, the player game object will be stuck in
         place until after the player exits the vehicle.  This causes the player body to strech to
         the current cyclops position.
 */
 IEnumerator AllowMovementPacketsAfterDockingAnimation(PacketSuppressor<Movement> movementSuppressor)
 {
     yield return new WaitForSeconds(3.0f);
     movementSuppressor.Dispose();
 }