コード例 #1
0
ファイル: CompState.cs プロジェクト: natepizzle/WeaponCore
        internal void ResetShootState(ShootActions action, long playerId)
        {
            var cycleShootClick = Data.Repo.Base.State.TerminalAction == ShootActions.ShootClick && action == ShootActions.ShootClick;
            var cycleShootOn    = Data.Repo.Base.State.TerminalAction == ShootActions.ShootOn && action == ShootActions.ShootOn;
            var cycleSomething  = cycleShootOn || cycleShootClick;

            Data.Repo.Base.Set.Overrides.Control = GroupOverrides.ControlModes.Auto;

            Data.Repo.Base.State.TerminalActionSetter(this, cycleSomething ? ShootActions.ShootOff : action);

            if (action == ShootActions.ShootClick && HasTurret && !cycleShootClick)
            {
                Data.Repo.Base.State.Control = CompStateValues.ControlMode.Ui;
            }
            else if (action == ShootActions.ShootClick && !cycleShootClick || action == ShootActions.ShootOnce || action == ShootActions.ShootOn)
            {
                Data.Repo.Base.State.Control = CompStateValues.ControlMode.Toolbar;
            }
            else
            {
                Data.Repo.Base.State.Control = CompStateValues.ControlMode.None;
            }

            playerId = Session.HandlesInput && playerId == -1 ? Session.PlayerId : playerId;
            var noReset = !Data.Repo.Base.State.TrackingReticle;
            var newId   = action == ShootActions.ShootOff && noReset ? -1 : playerId;

            Data.Repo.Base.State.PlayerId = newId;
        }
コード例 #2
0
        public void WeaponMode(WeaponComponent comp, ShootActions action, bool resetTerminalAction = true, bool syncCompState = true)
        {
            if (resetTerminalAction)
            {
                comp.Data.Repo.Base.State.TerminalAction = ShootActions.ShootOff;
            }

            Action = action;
            if (comp.Session.MpActive && comp.Session.IsServer && syncCompState)
            {
                comp.Session.SendCompState(comp);
            }
        }
コード例 #3
0
        public void TerminalActionSetter(WeaponComponent comp, ShootActions action, bool syncWeapons = false, bool updateWeapons = true)
        {
            TerminalAction = action;
            if (updateWeapons)
            {
                for (int i = 0; i < Weapons.Length; i++)
                {
                    Weapons[i].Action = action;
                }
            }

            if (syncWeapons)
            {
                comp.Session.SendCompState(comp);
            }
        }
コード例 #4
0
 public void Sync(WeaponComponent comp, CompStateValues sync, Caller caller)
 {
     if (sync.Revision > Revision)
     {
         Revision        = sync.Revision;
         TrackingReticle = sync.TrackingReticle;
         PlayerId        = sync.PlayerId;
         Control         = sync.Control;
         TerminalAction  = sync.TerminalAction;
         for (int i = 0; i < sync.Weapons.Length; i++)
         {
             comp.Platform.Weapons[i].State.Sync(sync.Weapons[i]);
         }
     }
     //else Log.Line($"CompStateValues older revision: {sync.Revision} > {Revision} - caller:{caller}");
 }
コード例 #5
0
        public bool Sync(WeaponComponent comp, CompStateValues sync, Caller caller)
        {
            if (sync.Revision > Revision || caller == Caller.CompData)
            {
                Revision        = sync.Revision;
                TrackingReticle = sync.TrackingReticle;
                PlayerId        = sync.PlayerId;
                Control         = sync.Control;
                TerminalAction  = sync.TerminalAction;
                for (int i = 0; i < sync.Weapons.Length; i++)
                {
                    comp.Platform.Weapons[i].State.Sync(sync.Weapons[i]);
                }

                return(true);
            }
            return(false);
        }
コード例 #6
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");
     }
 }
コード例 #7
0
ファイル: CompState.cs プロジェクト: natepizzle/WeaponCore
        internal void RequestShootUpdate(ShootActions action, long playerId)
        {
            if (IsDisabled)
            {
                return;
            }

            if (Session.HandlesInput)
            {
                Session.TerminalMon.HandleInputUpdate(this);
            }

            if (Session.IsServer)
            {
                ResetShootState(action, playerId);

                if (action == ShootActions.ShootOnce)
                {
                    ShootOnceCheck();
                }

                if (Session.MpActive)
                {
                    Session.SendCompBaseData(this);
                    if (action == ShootActions.ShootClick || action == ShootActions.ShootOn)
                    {
                        foreach (var w in Platform.Weapons)
                        {
                            Session.SendWeaponAmmoData(w);
                        }
                    }
                }
            }
            else if (action == ShootActions.ShootOnce)
            {
                ShootOnceCheck();
            }
            else
            {
                Session.SendActionShootUpdate(this, action);
            }
        }
コード例 #8
0
 public override void CleanUp()
 {
     base.CleanUp();
     Action   = ShootActions.ShootOff;
     PlayerId = -1;
 }
コード例 #9
0
        [ProtoMember(3), DefaultValue(ShootActions.ShootOff)] public ShootActions Action = ShootActions.ShootOff; // save

        public void Sync(WeaponStateValues sync)
        {
            Heat       = sync.Heat;
            Overheated = sync.Overheated;
            Action     = sync.Action;
        }