Beispiel #1
0
        private void UpdateHitData(HitNode weapon, TargetingData targetingData, bool skipTimeoutCheck)
        {
            StreamHitConfigComponent   streamHitConfig   = weapon.streamHitConfig;
            StreamHitCheckingComponent streamHitChecking = weapon.streamHitChecking;
            StreamHitComponent         streamHit         = weapon.streamHit;
            HitTarget     tankHit       = GetTankHit(targetingData);
            DirectionData bestDirection = targetingData.BestDirection;

            weapon.streamHitChecking.LastCheckTime = UnityTime.time;
            streamHit.TankHit   = tankHit;
            streamHit.StaticHit = bestDirection.StaticHit;
            StaticHit staticHit = !streamHitConfig.DetectStaticHit ? null : bestDirection.StaticHit;
            bool      flag      = false;
            bool      flag2     = false;

            if (!this.IsSameTank(tankHit, streamHitChecking.LastSentTankHit))
            {
                flag = true;
            }
            else if (skipTimeoutCheck || ((streamHitChecking.LastSendToServerTime + streamHitConfig.SendToServerPeriod) < UnityTime.time))
            {
                if (!IsAlmostEqual(staticHit, streamHitChecking.LastSentStaticHit))
                {
                    flag2 = true;
                }
                else if (!this.IsAlmostEqual(tankHit, streamHitChecking.LastSentTankHit))
                {
                    flag2 = true;
                }
            }
            if (flag)
            {
                weapon.Entity.RemoveComponent <StreamHitComponent>();
                this.AddStreamHit(weapon.Entity, targetingData, streamHitConfig, streamHitChecking);
            }
            else if (flag2)
            {
                base.ScheduleEvent(new SelfUpdateStreamHitEvent(tankHit, staticHit), weapon);
                this.SaveHitSentToServer(streamHitChecking, streamHit);
            }
        }
Beispiel #2
0
 private void SaveHitSentToServer(StreamHitCheckingComponent checking, StreamHitComponent streamHit)
 {
     checking.LastSendToServerTime = UnityTime.time;
     checking.LastSentTankHit      = streamHit.TankHit;
     checking.LastSentStaticHit    = streamHit.StaticHit;
 }
Beispiel #3
0
        private void AddStreamHit(Entity weapon, TargetingData targetingData, StreamHitConfigComponent config, StreamHitCheckingComponent checking)
        {
            if (!targetingData.HasAnyHit())
            {
                throw new Exception("No hit in StreamHit " + weapon);
            }
            if (!config.DetectStaticHit && !targetingData.HasTargetHit())
            {
                throw new Exception("No tank in StreamHit" + weapon);
            }
            StreamHitComponent hit = new StreamHitComponent();

            this.FillStreamHit(hit, targetingData);
            this.SaveHitSentToServer(checking, hit);
            weapon.AddComponent(hit);
        }