Esempio n. 1
0
        internal void SendActionShootUpdate(WeaponComponent comp, ManualShootActionState state, int weaponId = -1)
        {
            if (!HandlesInput)
            {
                return;
            }

            var mId = 0u;

            if (weaponId == -1)
            {
                comp.SyncIds.MIds[(int)PacketType.CompToolbarShootState]++;
                mId = comp.SyncIds.MIds[(int)PacketType.CompToolbarShootState];
            }
            else
            {
                comp.SyncIds.MIds[(int)PacketType.WeaponToolbarShootState]++;
                mId = comp.SyncIds.MIds[(int)PacketType.WeaponToolbarShootState];
            }

            if (IsClient)
            {
                comp.Session.PacketsToServer.Add(new ShootStatePacket
                {
                    EntityId = comp.MyCube.EntityId,
                    SenderId = comp.Session.MultiplayerId,
                    PType    = weaponId == -1 ? PacketType.CompToolbarShootState : PacketType.WeaponToolbarShootState,
                    MId      = mId,
                    Data     = state,
                    WeaponId = weaponId,
                });
            }
            else
            {
                comp.Session.PacketsToClient.Add(new PacketInfo
                {
                    Entity = comp.MyCube,
                    Packet = new ShootStatePacket
                    {
                        EntityId = comp.MyCube.EntityId,
                        SenderId = comp.Session.MultiplayerId,
                        PType    = weaponId == -1 ? PacketType.CompToolbarShootState : PacketType.WeaponToolbarShootState,
                        MId      = mId,
                        Data     = state,
                        WeaponId = weaponId,
                    }
                });
            }
        }
 public override void CleanUp()
 {
     base.CleanUp();
     Data     = ManualShootActionState.ShootOff;
     WeaponId = -1;
 }