예제 #1
0
        /*
         * 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
        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
 /*
  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();
 }