Ejemplo n.º 1
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,
                 }
             });
         }
     }
 }
Ejemplo n.º 2
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
             }
         });
     }
 }
Ejemplo n.º 3
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
             }
         });
     }
 }
Ejemplo n.º 4
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
             }
         });
     }
 }
Ejemplo n.º 5
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,
             }
         });
     }
 }
Ejemplo n.º 6
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]
                    }
                });
            }
        }
Ejemplo n.º 7
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
             }
         });
     }
 }
Ejemplo n.º 8
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
                    }
                });
            }
        }
Ejemplo n.º 9
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
             }
         });
     }
 }
Ejemplo n.º 10
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,
                 }
             });
         }
     }
 }
Ejemplo n.º 11
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
             }
         });
     }
 }
Ejemplo n.º 12
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
             }
         });
     }
 }
Ejemplo n.º 13
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
             }
         });
     }
 }
Ejemplo n.º 14
0
        internal void SendClientNotify(long id, string message, bool singleClient = false, string color = null, int duration = 0)
        {
            ulong     senderId = 0;
            IMyPlayer player   = null;

            if (singleClient && Players.TryGetValue(id, out player))
            {
                senderId = player.SteamUserId;
            }

            PacketsToClient.Add(new PacketInfo
            {
                Entity       = null,
                SingleClient = singleClient,
                Packet       = new ClientNotifyPacket
                {
                    EntityId = id,
                    SenderId = senderId,
                    PType    = PacketType.ClientNotify,
                    Message  = message,
                    Color    = color,
                    Duration = duration,
                }
            });
        }
Ejemplo n.º 15
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,
             }
         });
     }
 }
Ejemplo n.º 16
0
        internal void ProccessServerPacketsForClients()
        {
            if ((!IsServer || !MpActive))
            {
                Log.Line($"trying to process server packets on a non-server");
                return;
            }

            PacketsToClient.AddRange(PrunedPacketsToClient.Values);
            for (int i = 0; i < PacketsToClient.Count; i++)
            {
                var packetInfo = PacketsToClient[i];
                var bytes      = MyAPIGateway.Utilities.SerializeToBinary(packetInfo.Packet);
                if (packetInfo.SingleClient)
                {
                    MyModAPIHelper.MyMultiplayer.Static.SendMessageTo(ClientPacketId, bytes, packetInfo.Packet.SenderId, true);
                }
                else
                {
                    long entityId = packetInfo.Entity?.GetTopMostParent().EntityId ?? -1;

                    foreach (var p in Players.Values)
                    {
                        var notSender  = p.SteamUserId != packetInfo.Packet.SenderId;
                        var sendPacket = notSender && packetInfo.Entity == null;
                        if (!sendPacket && notSender)
                        {
                            if (PlayerEntityIdInRange.ContainsKey(p.SteamUserId))
                            {
                                if (PlayerEntityIdInRange[p.SteamUserId].Contains(entityId))
                                {
                                    sendPacket = true;
                                }
                                else
                                {
                                    GridAi rootAi;
                                    var    grid = packetInfo.Entity.GetTopMostParent() as MyCubeGrid;
                                    if (grid != null && GridToMasterAi.TryGetValue(grid, out rootAi) && PlayerEntityIdInRange[p.SteamUserId].Contains(rootAi.MyGrid.EntityId))
                                    {
                                        sendPacket = true;
                                    }
                                }
                            }
                        }

                        if (sendPacket)
                        {
                            MyModAPIHelper.MyMultiplayer.Static.SendMessageTo(ClientPacketId, bytes, p.SteamUserId, true);
                        }
                    }
                }
            }

            ServerPacketsForClientsClean();
        }
Ejemplo n.º 17
0
        private bool ServerClientMouseEvent(PacketObj data)
        {
            var packet      = data.Packet;
            var inputPacket = (InputPacket)packet;
            var ent         = MyEntities.GetEntityByIdOrDefault(packet.EntityId);

            if (ent == null)
            {
                return(Error(data, Msg("Entity")));
            }
            if (inputPacket.Data == null)
            {
                return(Error(data, Msg("Data")));
            }

            long playerId;

            if (SteamToPlayer.TryGetValue(packet.SenderId, out playerId))
            {
                uint[] mIds;
                if (PlayerMIds.TryGetValue(packet.SenderId, out mIds) && mIds[(int)packet.PType] < packet.MId)
                {
                    mIds[(int)packet.PType] = packet.MId;

                    if (PlayerMouseStates.ContainsKey(playerId))
                    {
                        PlayerMouseStates[playerId].Sync(inputPacket.Data);
                    }
                    else
                    {
                        PlayerMouseStates[playerId] = new InputStateData(inputPacket.Data);
                    }

                    PacketsToClient.Add(new PacketInfo {
                        Entity = ent, Packet = inputPacket
                    });

                    data.Report.PacketValid = true;
                }
                else
                {
                    Log.Line($"ServerClientMouseEvent: MidsHasSenderId:{PlayerMIds.ContainsKey(packet.SenderId)} - midsNull:{mIds == null} - senderId:{packet.SenderId}");
                }
            }
            else
            {
                return(Error(data, Msg("Player Not Found")));
            }

            return(true);
        }
Ejemplo n.º 18
0
 internal void SendTargetExpiredUpdate(WeaponComponent comp, int weaponId)
 {
     PacketsToClient.Add(new PacketInfo
     {
         Entity = comp.MyCube,
         Packet = new WeaponIdPacket
         {
             EntityId = comp.MyCube.EntityId,
             SenderId = 0,
             PType    = PacketType.TargetExpireUpdate,
             WeaponId = weaponId,
         }
     });
 }
Ejemplo n.º 19
0
 internal void SendPlayerConnectionUpdate(long id, bool connected)
 {
     PacketsToClient.Add(new PacketInfo
     {
         Entity = null,
         Packet = new BoolUpdatePacket
         {
             EntityId = id,
             SenderId = 0,
             PType    = PacketType.PlayerIdUpdate,
             Data     = connected
         }
     });
 }
Ejemplo n.º 20
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)
     {
         PacketsToClient.Add(new PacketInfo
         {
             Entity = comp.MyCube,
             Packet = new PlayerControlRequestPacket
             {
                 MId      = ++comp.MIds[(int)PacketType.PlayerControlRequest],
                 EntityId = comp.MyCube.EntityId,
                 SenderId = MultiplayerId,
                 PType    = PacketType.PlayerControlRequest,
                 PlayerId = playerId,
                 Mode     = mode,
             }
         });
     }
     else
     {
         Log.Line($"SendPlayerControlRequest should never be called on Server");
     }
 }
Ejemplo n.º 21
0
 internal void SendActionShootUpdate(WeaponComponent comp, ShootActions action)
 {
     if (IsClient)
     {
         uint[] mIds;
         if (PlayerMIds.TryGetValue(MultiplayerId, out mIds))
         {
             comp.Session.PacketsToServer.Add(new ShootStatePacket
             {
                 MId      = ++mIds[(int)PacketType.RequestShootUpdate],
                 EntityId = comp.MyCube.EntityId,
                 SenderId = comp.Session.MultiplayerId,
                 PType    = PacketType.RequestShootUpdate,
                 Action   = action,
                 PlayerId = PlayerId,
             });
         }
         else
         {
             Log.Line($"SendActionShootUpdate no player MIds found");
         }
     }
     else if (HandlesInput)
     {
         PacketsToClient.Add(new PacketInfo
         {
             Entity = comp.MyCube,
             Packet = new ShootStatePacket
             {
                 MId      = ++comp.MIds[(int)PacketType.RequestShootUpdate],
                 EntityId = comp.MyCube.EntityId,
                 SenderId = comp.Session.MultiplayerId,
                 PType    = PacketType.RequestShootUpdate,
                 Action   = action,
                 PlayerId = PlayerId,
             }
         });
     }
     else
     {
         Log.Line($"SendActionShootUpdate should never be called on Dedicated");
     }
 }
Ejemplo n.º 22
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");
     }
 }
Ejemplo n.º 23
0
        private bool ServerMarkedTargetUpdate(PacketObj data)
        {
            var packet       = data.Packet;
            var targetPacket = (FakeTargetPacket)packet;
            var myGrid       = MyEntities.GetEntityByIdOrDefault(packet.EntityId) as MyCubeGrid;

            if (myGrid == null)
            {
                return(Error(data, Msg($"GridId:{packet.EntityId} - entityExists:{MyEntities.EntityExists(packet.EntityId)}")));
            }


            GridAi ai;
            long   playerId;

            if (GridTargetingAIs.TryGetValue(myGrid, out ai) && SteamToPlayer.TryGetValue(packet.SenderId, out playerId))
            {
                GridAi.FakeTargets fakeTargets;
                uint[]             mIds;
                if (PlayerMIds.TryGetValue(packet.SenderId, out mIds) && mIds[(int)packet.PType] < packet.MId && PlayerDummyTargets.TryGetValue(playerId, out fakeTargets))
                {
                    mIds[(int)packet.PType] = packet.MId;

                    fakeTargets.PaintedTarget.Sync(targetPacket, ai);
                    PacketsToClient.Add(new PacketInfo {
                        Entity = myGrid, Packet = targetPacket
                    });

                    data.Report.PacketValid = true;
                }
                else
                {
                    Log.Line($"ServerFakeTargetUpdate: MidsHasSenderId:{PlayerMIds.ContainsKey(packet.SenderId)} - midsNull:{mIds == null} - senderId:{packet.SenderId}");
                }
            }
            else
            {
                return(Error(data, Msg($"GridAi not found, is marked:{myGrid.MarkedForClose}, has root:{GridToMasterAi.ContainsKey(myGrid)}")));
            }

            return(true);
        }
Ejemplo n.º 24
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");
     }
 }
Ejemplo n.º 25
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)
     {
         PacketsToClient.Add(new PacketInfo
         {
             Entity = controlBlock,
             Packet = new BoolUpdatePacket
             {
                 MId      = ++ai.MIds[(int)PacketType.ActiveControlUpdate],
                 EntityId = controlBlock.EntityId,
                 SenderId = MultiplayerId,
                 PType    = PacketType.ActiveControlUpdate,
                 Data     = active
             }
         });
     }
     else
     {
         Log.Line($"SendActiveControlUpdate should never be called on Dedicated");
     }
 }
Ejemplo n.º 26
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");
     }
 }
Ejemplo n.º 27
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");
     }
 }
Ejemplo n.º 28
0
 internal void SendPlayerConnectionUpdate(long id, bool connected)
 {
     if (IsServer)
     {
         PacketsToClient.Add(new PacketInfo
         {
             Entity = null,
             Packet = new BoolUpdatePacket
             {
                 EntityId = id,
                 SenderId = MultiplayerId,
                 PType    = PacketType.PlayerIdUpdate,
                 Data     = connected
             }
         });
     }
     else
     {
         Log.Line("SendPlayerConnectionUpdate should only be called on server");
     }
 }
Ejemplo n.º 29
0
        internal void SendEwaredBlocks()
        {
            if (IsServer)
            {
                _cachedEwarPacket.CleanUp();
                _cachedEwarPacket.SenderId = MultiplayerId;
                _cachedEwarPacket.PType    = PacketType.EwaredBlocks;
                _cachedEwarPacket.Data.AddRange(DirtyEwarData.Values);

                DirtyEwarData.Clear();
                EwarNetDataDirty = false;

                PacketsToClient.Add(new PacketInfo {
                    Packet = _cachedEwarPacket
                });
            }
            else
            {
                Log.Line($"SendEwaredBlocks should never be called on Client");
            }
        }
Ejemplo n.º 30
0
 internal void SendQueuedShot(Weapon w)
 {
     if (IsServer)
     {
         PacketsToClient.Add(new PacketInfo
         {
             Entity = w.Comp.MyCube,
             Packet = new QueuedShotPacket
             {
                 EntityId = w.Comp.MyCube.EntityId,
                 SenderId = MultiplayerId,
                 PType    = PacketType.QueueShot,
                 WeaponId = w.WeaponId,
                 PlayerId = w.Comp.Data.Repo.Base.State.PlayerId,
             }
         });
     }
     else
     {
         Log.Line($"SendAmmoCycleRequest should never be called on Client");
     }
 }