Пример #1
0
 internal void SendReassignTargetUpdate(GridAi ai, long targetId, int focusId)
 {
     if (IsClient)
     {
         PacketsToServer.Add(new FocusPacket
         {
             EntityId = ai.MyGrid.EntityId,
             SenderId = MultiplayerId,
             PType    = PacketType.ReassignTargetUpdate,
             TargetId = targetId,
             FocusId  = focusId
         });
     }
     else if (HandlesInput)
     {
         PacketsToClient.Add(new PacketInfo
         {
             Entity = ai.MyGrid,
             Packet = new FocusPacket
             {
                 EntityId = ai.MyGrid.EntityId,
                 SenderId = MultiplayerId,
                 PType    = PacketType.ReassignTargetUpdate,
                 TargetId = targetId,
                 FocusId  = focusId
             }
         });
     }
 }
Пример #2
0
 internal void SendActiveControlUpdate(GridAi ai, MyCubeBlock controlBlock, bool active)
 {
     if (IsClient)
     {
         uint[] mIds;
         if (PlayerMIds.TryGetValue(MultiplayerId, out mIds))
         {
             PacketsToServer.Add(new BoolUpdatePacket
             {
                 MId      = ++mIds[(int)PacketType.ActiveControlUpdate],
                 EntityId = controlBlock.EntityId,
                 SenderId = MultiplayerId,
                 PType    = PacketType.ActiveControlUpdate,
                 Data     = active
             });
         }
         else
         {
             Log.Line($"SendActiveControlUpdate no player MIds found");
         }
     }
     else if (HandlesInput)
     {
         ai.Construct.UpdateConstructsPlayers(controlBlock, PlayerId, active);
     }
     else
     {
         Log.Line($"SendActiveControlUpdate should never be called on Dedicated");
     }
 }
Пример #3
0
 internal void SendFakeTargetUpdate(GridAi ai, Vector3 hitPos)
 {
     if (IsClient)
     {
         PacketsToServer.Add(new FakeTargetPacket
         {
             EntityId = ai.MyGrid.EntityId,
             SenderId = ai.Session.MultiplayerId,
             PType    = PacketType.FakeTargetUpdate,
             Data     = hitPos,
         });
     }
     else if (HandlesInput)
     {
         PacketsToClient.Add(new PacketInfo
         {
             Entity = ai.MyGrid,
             Packet = new FakeTargetPacket
             {
                 EntityId = ai.MyGrid.EntityId,
                 SenderId = ai.Session.MultiplayerId,
                 PType    = PacketType.FakeTargetUpdate,
                 Data     = hitPos,
             }
         });
     }
 }
Пример #4
0
 internal void SendOverRidesUpdate(WeaponComponent comp, GroupOverrides overRides)
 {
     if (MpActive)
     {
         comp.SyncIds.MIds[(int)PacketType.OverRidesUpdate]++;
         if (IsClient)
         {
             PacketsToServer.Add(new OverRidesPacket
             {
                 EntityId = comp.MyCube.EntityId,
                 SenderId = MultiplayerId,
                 MId      = comp.SyncIds.MIds[(int)PacketType.OverRidesUpdate],
                 PType    = PacketType.OverRidesUpdate,
                 Data     = comp.Set.Value.Overrides,
             });
         }
         else
         {
             PacketsToClient.Add(new PacketInfo
             {
                 Entity = comp.MyCube,
                 Packet = new OverRidesPacket
                 {
                     EntityId = comp.MyCube.EntityId,
                     SenderId = 0,
                     MId      = comp.SyncIds.MIds[(int)PacketType.OverRidesUpdate],
                     PType    = PacketType.OverRidesUpdate,
                     Data     = comp.Set.Value.Overrides,
                 }
             });
         }
     }
 }
Пример #5
0
 internal void SendControlingPlayer(WeaponComponent comp)
 {
     comp.SyncIds.MIds[(int)PacketType.PlayerControlUpdate]++;
     if (IsClient)
     {
         PacketsToServer.Add(new ControllingPlayerPacket
         {
             EntityId = comp.MyCube.EntityId,
             SenderId = MultiplayerId,
             MId      = comp.SyncIds.MIds[(int)PacketType.PlayerControlUpdate],
             PType    = PacketType.PlayerControlUpdate,
             Data     = comp.State.Value.CurrentPlayerControl,
         });
     }
     else if (HandlesInput)
     {
         PacketsToClient.Add(new PacketInfo
         {
             Entity = comp.MyCube,
             Packet = new ControllingPlayerPacket
             {
                 EntityId = comp.MyCube.EntityId,
                 SenderId = 0,
                 MId      = comp.SyncIds.MIds[(int)PacketType.PlayerControlUpdate],
                 PType    = PacketType.PlayerControlUpdate,
                 Data     = comp.State.Value.CurrentPlayerControl,
             }
         });
     }
 }
Пример #6
0
 internal void SendCycleAmmoNetworkUpdate(Weapon weapon, int ammoId)
 {
     weapon.Comp.SyncIds.MIds[(int)PacketType.CycleAmmo]++;
     if (IsClient)
     {
         PacketsToServer.Add(new CycleAmmoPacket
         {
             EntityId = weapon.Comp.MyCube.EntityId,
             SenderId = MultiplayerId,
             PType    = PacketType.CycleAmmo,
             AmmoId   = ammoId,
             MId      = weapon.Comp.SyncIds.MIds[(int)PacketType.CycleAmmo],
             WeaponId = weapon.WeaponId
         });
     }
     else
     {
         PacketsToClient.Add(new PacketInfo
         {
             Entity = weapon.Comp.MyCube,
             Packet = new CycleAmmoPacket
             {
                 EntityId = weapon.Comp.MyCube.EntityId,
                 SenderId = 0,
                 PType    = PacketType.CycleAmmo,
                 AmmoId   = ammoId,
                 MId      = weapon.Comp.SyncIds.MIds[(int)PacketType.CycleAmmo],
                 WeaponId = weapon.WeaponId
             }
         });
     }
 }
Пример #7
0
 internal void SendOverRidesUpdate(GridAi ai, string groupName, GroupOverrides overRides)
 {
     if (MpActive)
     {
         ai.UiMId++;
         if (IsClient)
         {
             PacketsToServer.Add(new OverRidesPacket
             {
                 EntityId  = ai.MyGrid.EntityId,
                 SenderId  = MultiplayerId,
                 MId       = ai.UiMId,
                 GroupName = groupName,
                 PType     = PacketType.OverRidesUpdate,
                 Data      = overRides,
             });
         }
         else if (IsServer)
         {
             PacketsToClient.Add(new PacketInfo
             {
                 Entity = ai.MyGrid,
                 Packet = new OverRidesPacket
                 {
                     EntityId  = ai.MyGrid.EntityId,
                     SenderId  = 0,
                     MId       = ai.UiMId,
                     GroupName = groupName,
                     PType     = PacketType.OverRidesUpdate,
                     Data      = overRides,
                 }
             });
         }
     }
 }
Пример #8
0
 internal void SendActiveControlUpdate(MyCubeBlock controlBlock, bool active)
 {
     if (IsClient)
     {
         PacketsToServer.Add(new BoolUpdatePacket
         {
             EntityId = controlBlock.EntityId,
             SenderId = MultiplayerId,
             PType    = PacketType.ActiveControlUpdate,
             Data     = active
         });
     }
     else
     {
         PacketsToClient.Add(new PacketInfo
         {
             Entity = controlBlock,
             Packet = new BoolUpdatePacket
             {
                 EntityId = controlBlock.EntityId,
                 SenderId = 0,
                 PType    = PacketType.ActiveControlUpdate,
                 Data     = active
             }
         });
     }
 }
Пример #9
0
        internal void SendMouseUpdate(MyEntity entity)
        {
            if (!HandlesInput)
            {
                return;
            }

            if (IsClient)
            {
                PacketsToServer.Add(new InputPacket
                {
                    EntityId = entity.EntityId,
                    SenderId = MultiplayerId,
                    PType    = PacketType.ClientMouseEvent,
                    Data     = UiInput.ClientInputState
                });
            }
            else
            {
                PacketsToClient.Add(new PacketInfo
                {
                    Entity = entity,
                    Packet = new InputPacket
                    {
                        EntityId = entity.EntityId,
                        SenderId = MultiplayerId,
                        PType    = PacketType.ClientMouseEvent,
                        Data     = UiInput.ClientInputState
                    }
                });
            }
        }
Пример #10
0
        internal void SendFixedGunHitEvent(MyCubeBlock firingCube, MyEntity hitEnt, Vector3 hitPos, Vector3 hitDirection, Vector3 up, int muzzleId, int systemId)
        {
            if (firingCube == null)
            {
                return;
            }

            var comp = firingCube.Components.Get <WeaponComponent>();

            int weaponId;

            if (comp != null && comp.Platform.State == MyWeaponPlatform.PlatformState.Ready && comp.Platform.Structure.HashToId.TryGetValue(systemId, out weaponId))
            {
                PacketsToServer.Add(new FixedWeaponHitPacket
                {
                    EntityId     = firingCube.EntityId,
                    SenderId     = MultiplayerId,
                    PType        = PacketType.FixedWeaponHitEvent,
                    HitEnt       = hitEnt.EntityId,
                    HitDirection = hitDirection,
                    HitOffset    = hitEnt.PositionComp.WorldMatrixRef.Translation - hitPos,
                    Up           = up,
                    MuzzleId     = muzzleId,
                    WeaponId     = weaponId
                });
            }
        }
Пример #11
0
 internal void SendOverRidesClientComp(WeaponComponent comp, string settings, int value)
 {
     if (IsClient)
     {
         uint[] mIds;
         if (PlayerMIds.TryGetValue(MultiplayerId, out mIds))
         {
             PacketsToServer.Add(new OverRidesPacket
             {
                 MId      = ++mIds[(int)PacketType.OverRidesUpdate],
                 PType    = PacketType.OverRidesUpdate,
                 EntityId = comp.MyCube.EntityId,
                 SenderId = MultiplayerId,
                 Setting  = settings,
                 Value    = value,
             });
         }
         else
         {
             Log.Line($"SendOverRidesClientComp no player MIds found");
         }
     }
     else
     {
         Log.Line($"SendOverRidesClientComp should only be called on clients");
     }
 }
Пример #12
0
        internal void SendCompSettingUpdate(WeaponComponent comp)
        {
            comp.SyncIds.MIds[(int)PacketType.CompSettingsUpdate]++;

            if (IsClient)// client, send settings to server
            {
                PacketsToServer.Add(new SettingPacket
                {
                    EntityId = comp.MyCube.EntityId,
                    PType    = PacketType.CompSettingsUpdate,
                    SenderId = MultiplayerId,
                    Data     = comp.Set.Value,
                    MId      = comp.SyncIds.MIds[(int)PacketType.CompSettingsUpdate]
                });
            }
            else if (HandlesInput)
            {
                PacketsToClient.Add(new PacketInfo
                {
                    Entity = comp.MyCube,
                    Packet = new SettingPacket
                    {
                        EntityId = comp.MyCube.EntityId,
                        SenderId = 0,
                        PType    = PacketType.CompSettingsUpdate,
                        Data     = comp.Set.Value,
                        MId      = comp.SyncIds.MIds[(int)PacketType.CompSettingsUpdate]
                    }
                });
            }
        }
Пример #13
0
 internal void SendUpdateRequest(long entityId, PacketType ptype)
 {
     if (IsClient)
     {
         uint[] mIds;
         if (PlayerMIds.TryGetValue(MultiplayerId, out mIds))
         {
             PacketsToServer.Add(new Packet
             {
                 MId      = ++mIds[(int)ptype],
                 EntityId = entityId,
                 SenderId = MultiplayerId,
                 PType    = ptype
             });
         }
         else
         {
             Log.Line($"SendUpdateRequest no player MIds found");
         }
     }
     else
     {
         Log.Line($"SendUpdateRequest should only be called on clients");
     }
 }
Пример #14
0
 internal void SendNextActiveUpdate(GridAi ai, bool addSecondary)
 {
     if (IsClient)
     {
         PacketsToServer.Add(new FocusPacket
         {
             EntityId     = ai.MyGrid.EntityId,
             SenderId     = MultiplayerId,
             PType        = PacketType.NextActiveUpdate,
             AddSecondary = addSecondary
         });
     }
     else if (HandlesInput)
     {
         PacketsToClient.Add(new PacketInfo
         {
             Entity = ai.MyGrid,
             Packet = new FocusPacket
             {
                 EntityId     = ai.MyGrid.EntityId,
                 SenderId     = MultiplayerId,
                 PType        = PacketType.NextActiveUpdate,
                 AddSecondary = addSecondary
             }
         });
     }
 }
Пример #15
0
        internal void SendFixedGunHitEvent(MyCubeBlock firingCube, MyEntity hitEnt, Vector3 origin, Vector3 velocity, Vector3 up, int muzzleId, int systemId, int ammoIndex, float maxTrajectory)
        {
            if (firingCube == null)
            {
                return;
            }

            var comp = firingCube.Components.Get <WeaponComponent>();

            int weaponId;

            if (comp.Ai?.MyGrid != null && comp.Platform.State == MyWeaponPlatform.PlatformState.Ready && comp.Platform.Structure.HashToId.TryGetValue(systemId, out weaponId))
            {
                PacketsToServer.Add(new FixedWeaponHitPacket
                {
                    EntityId      = firingCube.EntityId,
                    SenderId      = MultiplayerId,
                    PType         = PacketType.FixedWeaponHitEvent,
                    HitEnt        = hitEnt.EntityId,
                    HitOffset     = hitEnt.PositionComp.WorldMatrixRef.Translation - origin,
                    Up            = up,
                    MuzzleId      = muzzleId,
                    WeaponId      = weaponId,
                    Velocity      = velocity,
                    AmmoIndex     = ammoIndex,
                    MaxTrajectory = maxTrajectory,
                });
            }
        }
Пример #16
0
 internal void SendTrackReticleUpdate(WeaponComponent comp, bool track)
 {
     if (IsClient)
     {
         uint[] mIds;
         if (PlayerMIds.TryGetValue(MultiplayerId, out mIds))
         {
             PacketsToServer.Add(new BoolUpdatePacket
             {
                 MId      = ++mIds[(int)PacketType.ReticleUpdate],
                 EntityId = comp.MyCube.EntityId,
                 SenderId = MultiplayerId,
                 PType    = PacketType.ReticleUpdate,
                 Data     = track
             });
         }
         else
         {
             Log.Line($"SendTrackReticleUpdate no player MIds found");
         }
     }
     else if (HandlesInput)
     {
         comp.Data.Repo.Base.State.TrackingReticle = track;
         SendCompBaseData(comp);
     }
 }
Пример #17
0
 internal void SendMouseUpdate(MyEntity entity)
 {
     if (IsClient)
     {
         PacketsToServer.Add(new MouseInputPacket
         {
             EntityId = entity.EntityId,
             SenderId = MultiplayerId,
             PType    = PacketType.ClientMouseEvent,
             Data     = UiInput.ClientMouseState
         });
     }
     else if (MpActive && IsServer)
     {
         PacketsToClient.Add(new PacketInfo
         {
             Entity = entity,
             Packet = new MouseInputPacket
             {
                 EntityId = entity.EntityId,
                 SenderId = MultiplayerId,
                 PType    = PacketType.ClientMouseEvent,
                 Data     = UiInput.ClientMouseState
             }
         });
     }
 }
Пример #18
0
 internal void SendAmmoCycleRequest(Weapon w, int newAmmoId)
 {
     if (IsClient)
     {
         uint[] mIds;
         if (PlayerMIds.TryGetValue(MultiplayerId, out mIds))
         {
             PacketsToServer.Add(new AmmoCycleRequestPacket
             {
                 MId       = ++mIds[(int)PacketType.AmmoCycleRequest],
                 EntityId  = w.Comp.MyCube.EntityId,
                 SenderId  = MultiplayerId,
                 PType     = PacketType.AmmoCycleRequest,
                 WeaponId  = w.WeaponId,
                 NewAmmoId = newAmmoId,
                 PlayerId  = PlayerId,
             });
         }
         else
         {
             Log.Line($"SendAmmoCycleRequest no player MIds found");
         }
     }
     else
     {
         Log.Line($"SendAmmoCycleRequest should never be called on Non-Client");
     }
 }
Пример #19
0
 internal void SendReleaseActiveUpdate(GridAi ai)
 {
     if (IsClient)
     {
         PacketsToServer.Add(new FocusPacket
         {
             EntityId = ai.MyGrid.EntityId,
             SenderId = MultiplayerId,
             PType    = PacketType.ReleaseActiveUpdate
         });
     }
     else if (HandlesInput)
     {
         PacketsToClient.Add(new PacketInfo
         {
             Entity = ai.MyGrid,
             Packet = new FocusPacket
             {
                 EntityId = ai.MyGrid.EntityId,
                 SenderId = MultiplayerId,
                 PType    = PacketType.ReleaseActiveUpdate
             }
         });
     }
 }
Пример #20
0
 internal void SendReleaseActiveUpdate(GridAi ai)
 {
     if (IsClient)
     {
         uint[] mIds;
         if (PlayerMIds.TryGetValue(MultiplayerId, out mIds))
         {
             PacketsToServer.Add(new FocusPacket
             {
                 MId      = ++mIds[(int)PacketType.ReleaseActiveUpdate],
                 EntityId = ai.MyGrid.EntityId,
                 SenderId = MultiplayerId,
                 PType    = PacketType.ReleaseActiveUpdate
             });
         }
         else
         {
             Log.Line($"SendReleaseActiveUpdate no player MIds found");
         }
     }
     else if (HandlesInput)
     {
         PacketsToClient.Add(new PacketInfo
         {
             Entity = ai.MyGrid,
             Packet = new FocusPacket
             {
                 MId      = ++ai.MIds[(int)PacketType.ReleaseActiveUpdate],
                 EntityId = ai.MyGrid.EntityId,
                 SenderId = MultiplayerId,
                 PType    = PacketType.ReleaseActiveUpdate
             }
         });
     }
 }
Пример #21
0
 internal void SendPlayerControlRequest(WeaponComponent comp, long playerId, CompStateValues.ControlMode mode)
 {
     if (IsClient)
     {
         uint[] mIds;
         if (PlayerMIds.TryGetValue(MultiplayerId, out mIds))
         {
             PacketsToServer.Add(new PlayerControlRequestPacket
             {
                 MId      = ++mIds[(int)PacketType.PlayerControlRequest],
                 EntityId = comp.MyCube.EntityId,
                 SenderId = MultiplayerId,
                 PType    = PacketType.PlayerControlRequest,
                 PlayerId = playerId,
                 Mode     = mode,
             });
         }
         else
         {
             Log.Line($"SendPlayerControlRequest no player MIds found");
         }
     }
     else if (HandlesInput)
     {
         SendCompBaseData(comp);
     }
     else
     {
         Log.Line($"SendPlayerControlRequest should never be called on Server");
     }
 }
Пример #22
0
 internal void SendTrackReticleUpdate(WeaponComponent comp)
 {
     if (IsClient)
     {
         PacketsToServer.Add(new BoolUpdatePacket
         {
             EntityId = comp.MyCube.EntityId,
             SenderId = MultiplayerId,
             PType    = PacketType.ReticleUpdate,
             Data     = comp.TrackReticle
         });
     }
     else if (IsServer)
     {
         PacketsToClient.Add(new PacketInfo
         {
             Entity = comp.MyCube,
             Packet = new BoolUpdatePacket
             {
                 EntityId = comp.MyCube.EntityId,
                 PType    = PacketType.ReticleUpdate,
                 Data     = comp.TrackReticle
             }
         });
     }
 }
Пример #23
0
 internal void SendUpdateRequest(long entityId, PacketType ptype)
 {
     PacketsToServer.Add(new Packet
     {
         EntityId = entityId,
         SenderId = MultiplayerId,
         PType    = ptype
     });
 }
Пример #24
0
        internal void ProccessClientPacketsForServer()
        {
            if (!IsClient || !MpActive)
            {
                Log.Line($"trying to process client packets on a non-client");
                PacketsToServer.Clear();
                return;
            }

            for (int i = 0; i < PacketsToServer.Count; i++)
            {
                MyModAPIHelper.MyMultiplayer.Static.SendMessageToServer(ServerPacketId, MyAPIGateway.Utilities.SerializeToBinary(PacketsToServer[i]), true);
            }

            PacketsToServer.Clear();
        }
Пример #25
0
 internal void SendFakeTargetUpdate(GridAi ai, GridAi.FakeTarget fake)
 {
     if (IsClient)
     {
         uint[] mIds;
         if (PlayerMIds.TryGetValue(MultiplayerId, out mIds))
         {
             PacketsToServer.Add(new FakeTargetPacket
             {
                 MId      = ++mIds[(int)PacketType.FakeTargetUpdate],
                 EntityId = ai.MyGrid.EntityId,
                 SenderId = ai.Session.MultiplayerId,
                 PType    = PacketType.FakeTargetUpdate,
                 Pos      = fake.Position,
                 TargetId = fake.EntityId,
             });
         }
         else
         {
             Log.Line($"SendFakeTargetUpdate no player MIds found");
         }
     }
     else if (HandlesInput)
     {
         PacketsToClient.Add(new PacketInfo
         {
             Entity = ai.MyGrid,
             Packet = new FakeTargetPacket
             {
                 MId      = ++ai.MIds[(int)PacketType.FakeTargetUpdate],
                 EntityId = ai.MyGrid.EntityId,
                 SenderId = ai.Session.MultiplayerId,
                 PType    = PacketType.FakeTargetUpdate,
                 Pos      = fake.Position,
                 TargetId = fake.EntityId,
             }
         });
     }
     else
     {
         Log.Line($"SendFakeTargetUpdate should never be called on Dedicated");
     }
 }
Пример #26
0
 internal void SendActiveTerminal(WeaponComponent comp)
 {
     if (IsClient)
     {
         uint[] mIds;
         if (PlayerMIds.TryGetValue(MultiplayerId, out mIds))
         {
             PacketsToServer.Add(new TerminalMonitorPacket
             {
                 SenderId = MultiplayerId,
                 PType    = PacketType.TerminalMonitor,
                 EntityId = comp.MyCube.EntityId,
                 State    = TerminalMonitorPacket.Change.Update,
                 MId      = ++mIds[(int)PacketType.TerminalMonitor],
             });
         }
         else
         {
             Log.Line($"SendActiveTerminal no player MIds found");
         }
     }
     else if (HandlesInput)
     {
         PacketsToClient.Add(new PacketInfo
         {
             Entity = comp.MyCube,
             Packet = new TerminalMonitorPacket
             {
                 SenderId = MultiplayerId,
                 PType    = PacketType.TerminalMonitor,
                 EntityId = comp.MyCube.EntityId,
                 State    = TerminalMonitorPacket.Change.Update,
                 MId      = ++comp.MIds[(int)PacketType.TerminalMonitor],
             }
         });
     }
     else
     {
         Log.Line($"SendActiveTerminal should never be called on Dedicated");
     }
 }
Пример #27
0
 internal void SendMouseUpdate(GridAi ai, MyEntity entity)
 {
     if (IsClient)
     {
         uint[] mIds;
         if (PlayerMIds.TryGetValue(MultiplayerId, out mIds))
         {
             PacketsToServer.Add(new InputPacket
             {
                 MId      = ++mIds[(int)PacketType.ClientMouseEvent],
                 EntityId = entity.EntityId,
                 SenderId = MultiplayerId,
                 PType    = PacketType.ClientMouseEvent,
                 Data     = UiInput.ClientInputState
             });
         }
         else
         {
             Log.Line($"SendMouseUpdate no player MIds found");
         }
     }
     else if (HandlesInput)
     {
         PacketsToClient.Add(new PacketInfo
         {
             Entity = entity,
             Packet = new InputPacket
             {
                 MId      = ++ai.MIds[(int)PacketType.ClientMouseEvent],
                 EntityId = entity.EntityId,
                 SenderId = MultiplayerId,
                 PType    = PacketType.ClientMouseEvent,
                 Data     = UiInput.ClientInputState
             }
         });
     }
     else
     {
         Log.Line($"SendMouseUpdate should never be called on Dedicated");
     }
 }
Пример #28
0
 internal void SendSetCompBoolRequest(WeaponComponent comp, bool newBool, PacketType type)
 {
     if (IsClient)
     {
         uint[] mIds;
         if (PlayerMIds.TryGetValue(MultiplayerId, out mIds))
         {
             PacketsToServer.Add(new BoolUpdatePacket
             {
                 MId      = ++mIds[(int)type],
                 EntityId = comp.MyCube.EntityId,
                 SenderId = MultiplayerId,
                 PType    = type,
                 Data     = newBool,
             });
         }
         else
         {
             Log.Line($"SendSetCompBoolRequest no player MIds found");
         }
     }
     else if (HandlesInput)
     {
         PacketsToClient.Add(new PacketInfo
         {
             Entity = comp.MyCube,
             Packet = new BoolUpdatePacket
             {
                 MId      = ++comp.MIds[(int)type],
                 EntityId = comp.MyCube.EntityId,
                 SenderId = MultiplayerId,
                 PType    = type,
                 Data     = newBool,
             }
         });
     }
     else
     {
         Log.Line($"SendSetCompBoolRequest should never be called on Non-HandlesInput");
     }
 }
Пример #29
0
 internal void SendGroupUpdate(GridAi ai)
 {
     if (IsClient)
     {
         PacketsToServer.Add(new Packet
         {
             EntityId = ai.MyGrid.EntityId,
             SenderId = MultiplayerId,
             PType    = PacketType.RescanGroupRequest,
         });
     }
     else if (IsServer)
     {
         PacketsToClient.Add(new PacketInfo
         {
             Entity = ai.MyGrid,
             Packet = new Packet
             {
                 EntityId = ai.MyGrid.EntityId,
                 PType    = PacketType.RescanGroupRequest,
             }
         });
     }
 }
        internal void PurgeAll()
        {
            FutureEvents.Purge((int)Tick);
            PurgeTerminalSystem();

            foreach (var reports in Reporter.ReportData.Values)
            {
                foreach (var report in reports)
                {
                    report.Clean();
                    Reporter.ReportPool.Return(report);
                }
                reports.Clear();
            }
            Reporter.ReportData.Clear();
            Reporter.ReportPool.Clean();

            PacketsToClient.Clear();
            PacketsToServer.Clear();

            foreach (var suit in (PacketType[])Enum.GetValues(typeof(PacketType)))
            {
                foreach (var pool in PacketPools.Values)
                {
                    pool.Clean();
                }
                PacketPools.Clear();
            }

            foreach (var item in _effectedCubes)
            {
                var cubeid     = item.Key;
                var blockInfo  = item.Value;
                var functBlock = blockInfo.FunctBlock;
                var cube       = blockInfo.CubeBlock;

                if (cube == null || cube.MarkedForClose)
                {
                    _effectPurge.Enqueue(cubeid);
                    continue;
                }

                functBlock.EnabledChanged -= ForceDisable;
                functBlock.Enabled         = blockInfo.FirstState;
                cube.SetDamageEffect(false);
                _effectPurge.Enqueue(cubeid);
            }

            while (_effectPurge.Count != 0)
            {
                _effectedCubes.Remove(_effectPurge.Dequeue());
            }

            Av.Glows.Clear();
            Av.AvShotPool.Clean();

            DeferedUpBlockTypeCleanUp(true);
            BlockTypeCleanUp.Clear();

            foreach (var map in GridToFatMap.Keys)
            {
                RemoveGridFromMap(map);
            }

            GridToFatMap.Clear();
            FatMapPool.Clean();

            DirtyGridsTmp.Clear();

            foreach (var structure in WeaponPlatforms.Values)
            {
                foreach (var system in structure.WeaponSystems)
                {
                    foreach (var ammo in system.Value.WeaponAmmoTypes)
                    {
                        ammo.AmmoDef.Const.PrimeEntityPool?.Clean();
                    }
                }

                structure.WeaponSystems.Clear();
            }
            WeaponPlatforms.Clear();

            foreach (var gridToMap in GridToBlockTypeMap)
            {
                foreach (var map in gridToMap.Value)
                {
                    map.Value.ClearImmediate();
                    ConcurrentListPool.Return(map.Value);
                }
                gridToMap.Value.Clear();
                BlockTypePool.Return(gridToMap.Value);
            }
            GridToBlockTypeMap.Clear();

            foreach (var playerGrids in PlayerEntityIdInRange)
            {
                playerGrids.Value.Clear();
            }

            PlayerEntityIdInRange.Clear();

            DirtyGrids.Clear();

            DsUtil.Purge();
            DsUtil2.Purge();

            _effectActive = false;
            ShootingWeapons.Clear();
            AcquireTargets.Clear();
            RemoveEffectsFromGrid.Clear();
            WeaponAmmoPullQueue.Clear();
            AmmoToPullQueue.Clear();
            Hits.Clear();
            AllArmorBaseDefinitions.Clear();
            HeavyArmorBaseDefinitions.Clear();
            AllArmorBaseDefinitions.Clear();
            AcquireTargets.Clear();
            ChargingWeapons.Clear();
            LargeBlockSphereDb.Clear();
            SmallBlockSphereDb.Clear();
            AnimationsToProcess.Clear();
            _subTypeIdToWeaponDefs.Clear();
            WeaponDefinitions.Clear();
            SlimsSortedList.Clear();
            _destroyedSlims.Clear();
            _destroyedSlimsClient.Clear();
            _slimHealthClient.Clear();
            _slimsSet.Clear();
            _turretDefinitions.Clear();

            foreach (var comp in CompsToStart)
            {
                PlatFormPool.Return(comp.Platform);
                comp.Platform = null;
            }

            foreach (var readd in CompReAdds)
            {
                PlatFormPool.Return(readd.Comp.Platform);
                readd.Comp.Platform = null;
            }
            foreach (var comp in CompsDelayed)
            {
                PlatFormPool.Return(comp.Platform);
                comp.Platform = null;
            }
            PlatFormPool.Clean();
            CompsToStart.ClearImmediate();

            CompsDelayed.Clear();
            CompReAdds.Clear();
            GridAiPool.Clean();

            Av.RipMap.Clear();
            foreach (var mess in Av.KeensBrokenParticles)
            {
                Av.KeenMessPool.Return(mess);
            }

            Av.KeensBrokenParticles.Clear();

            foreach (var av in Av.AvShots)
            {
                av.GlowSteps.Clear();
                Av.AvShotPool.Return(av);
            }
            Av.AvShotPool.Clean();
            Av.AvBarrels1.Clear();
            Av.AvBarrels2.Clear();
            Av.AvShots.Clear();
            Av.HitSounds.Clear();

            foreach (var errorpkt in ClientSideErrorPktList)
            {
                errorpkt.Packet.CleanUp();
            }
            ClientSideErrorPktList.Clear();

            GridEffectPool.Clean();
            GridEffectsPool.Clean();
            BlockTypePool.Clean();
            ConcurrentListPool.Clean();

            GroupInfoPool.Clean();
            TargetInfoPool.Clean();

            Projectiles.Clean();
            WeaponCoreBlockDefs.Clear();
            VanillaIds.Clear();
            VanillaCoreIds.Clear();
            WeaponCoreFixedBlockDefs.Clear();
            WeaponCoreTurretBlockDefs.Clear();

            foreach (var p in Projectiles.ProjectilePool)
            {
                p.AmmoEffect?.Stop();
            }

            Projectiles.ShrapnelToSpawn.Clear();
            Projectiles.ShrapnelPool.Clean();
            Projectiles.FragmentPool.Clean();
            Projectiles.ActiveProjetiles.ApplyChanges();
            Projectiles.ActiveProjetiles.Clear();
            Projectiles.ProjectilePool.Clear();
            Projectiles.HitEntityPool.Clean();
            Projectiles.CleanUp.Clear();
            Projectiles.VirtInfoPool.Clean();

            DbsToUpdate.Clear();
            GridTargetingAIs.Clear();

            DsUtil          = null;
            DsUtil2         = null;
            SlimsSortedList = null;
            Enforced        = null;
            StallReporter   = null;
            Proccessor      = null;
            Physics         = null;
            Camera          = null;
            Projectiles     = null;
            TrackingAi      = null;
            UiInput         = null;
            TargetUi        = null;
            Placer          = null;
            WheelUi         = null;
            TargetGps       = null;
            SApi.Unload();
            SApi                = null;
            Api                 = null;
            ApiServer           = null;
            Reporter            = null;
            WeaponDefinitions   = null;
            AnimationsToProcess = null;
            ProjectileTree.Clear();
            ProjectileTree     = null;
            Av                 = null;
            HudUi              = null;
            AllDefinitions     = null;
            SoundDefinitions   = null;
            ActiveCockPit      = null;
            ActiveControlBlock = null;
            ControlledEntity   = null;
        }