Exemple #1
0
        [ProtoMember(6)] public int AmmoCycleId;     //save

        public bool Sync(Weapon w, AmmoValues sync)
        {
            if (sync.Revision > Revision)
            {
                Revision = sync.Revision;

                if (CurrentAmmo != sync.CurrentAmmo)
                {
                    var ammoSpent      = w.ClientLastShotId == w.Reload.StartId && CurrentAmmo == 0;
                    var notShotBlocked = !w.PreFired && !w.Reloading && !w.FinishBurst && !w.IsShooting;
                    if (!notShotBlocked && !ammoSpent)
                    {
                        //Log.Line($"Syncing AmmoValues: - currentAmmo:{CurrentAmmo}({sync.CurrentAmmo}) - Charge:{CurrentCharge}({sync.CurrentCharge}) - Mags:{CurrentMags}({sync.CurrentMags}) - LastShootTick:{w.System.Session.Tick - w.LastShootTick} - IsShooting:{w.IsShooting} - finish:{w.FinishBurst} - start:{w.ClientStartId}({w.Reload.StartId})[{w.ClientLastShotId}] - end:{w.ClientEndId}({w.Reload.EndId})");
                        CurrentAmmo = sync.CurrentAmmo;
                    }
                    //else Log.Line($"spent:{ammoSpent} - notBlocked:{notShotBlocked} - syncAmmo:{sync.CurrentAmmo} - endIdMatch:{w.Reload.EndId == w.ClientEndId}() - startIdMatch:{w.Reload.StartId == w.ClientStartId}");
                }

                CurrentCharge = sync.CurrentCharge;

                if (sync.CurrentMags <= 0 && CurrentMags != sync.CurrentMags)
                {
                    w.ClientReload(true);
                }

                CurrentMags = sync.CurrentMags;
                AmmoTypeId  = sync.AmmoTypeId;

                if (sync.AmmoCycleId > AmmoCycleId)
                {
                    w.ChangeActiveAmmoClient();
                }

                AmmoCycleId = sync.AmmoCycleId;
                return(true);
            }
            return(false);
        }
Exemple #2
0
        [ProtoMember(6)] public int AmmoCycleId;     //save

        public void Sync(Weapon w, AmmoValues sync)
        {
            if (sync.Revision > Revision)
            {
                Revision      = sync.Revision;
                CurrentAmmo   = sync.CurrentAmmo;
                CurrentCharge = sync.CurrentCharge;

                if (sync.CurrentMags <= 0 && CurrentMags != sync.CurrentMags)
                {
                    w.ClientReload(true);
                }

                CurrentMags = sync.CurrentMags;
                AmmoTypeId  = sync.AmmoTypeId;

                if (sync.AmmoCycleId > AmmoCycleId)
                {
                    w.ChangeActiveAmmoClient();
                }

                AmmoCycleId = sync.AmmoCycleId;
            }
        }
Exemple #3
0
 public override void CleanUp()
 {
     base.CleanUp();
     Data     = null;
     WeaponId = 0;
 }