public override void Update(TimeSpan time)
            {
                _timer.Update(time);
                if (!_timer.Passed)
                {
                    return;
                }

                _timer.Reset();

                if (Interlocked.CompareExchange(ref _inProgress, 1, 0) == 1)
                {
                    return;
                }

                Task.Run(() =>
                {
                    try
                    {
                        DoReinforceEndCheck();
                    }
                    catch (Exception ex)
                    {
                        Logger.Exception(ex);
                    }
                }).ContinueWith(t => { _inProgress = 0; });
            }
        protected override void OnUpdate(TimeSpan time)
        {
            _timer.Update(time);
            if (!_timer.Passed)
            {
                return;
            }
            _timer.Reset();

            Logger.DebugInfo($" ---------- KEZDUNK ---------- [{Owner.InfoString}]");

            //itt ez az egesz arra kell, hogy amikor megindul a server akkor belemegy valami statebe
            //ott hasznal zonat, aztan csak nez, hogy nincs kinn az objekt, igen, mert az is epp pakolodik ki
            //
            //ez ugyan csak ragtapasz.


            if (Owner.Core < Owner.CoreUseHandler.CoreMinimum)
            {
                Owner.CoreUseHandler.ToWarmUpState();
                return;
            }

            Owner.CoreUseHandler.ToActiveState();
        }
            public override void Update(TimeSpan time)
            {
                base.Update(time);

                _timer.Update(time);
                if (!_timer.Passed)
                {
                    return;
                }
                _timer.Reset();


                if (ReinforceHandler._nextReinforceCounterIncrease < DateTime.Now)
                {
                    ReinforceHandler.SetNextReinforceCounterIncreaseFromNow(REINFORCE_COUNTER_INCREASE_MINUTES);

                    var oldValue = ReinforceHandler.ReinforceCounter;
                    ReinforceHandler.IncreaseReinforceCounter();
                    var newValue = ReinforceHandler.ReinforceCounter;

                    if (oldValue != newValue)
                    {
                        WriteLog("reinforce counter increased. " + ReinforceHandler._pbsUnit.ED.Name + "  " + oldValue + "->" + newValue);
                    }
                }
            }
예제 #4
0
        private void UpdateLogout(TimeSpan time)
        {
            if (_logoutTimer == null)
            {
                return;
            }

            _logoutTimer.Update(time);

            if (!_logoutTimer.Passed)
            {
                return;
            }

            _logoutTimer = null;

            if (_isInLogout)
            {
                return;
            }

            _isInLogout = true;

            Task.Run(() => LogoutPlayer());
        }
예제 #5
0
        public static Action <TimeSpan> CreateUpdateProfiler(TimeSpan interval, Action <TimeSpan> action)
        {
            var timer   = new IntervalTimer(interval);
            var updates = 0;

            return((e) =>
            {
                updates++;
                timer.Update(e);
                if (!timer.Passed)
                {
                    return;
                }

                try
                {
                    action(timer.Elapsed.Divide(updates));
                }
                finally
                {
                    updates = 0;
                    timer.Reset();
                }
            });
        }
예제 #6
0
        public void Update(TimeSpan time)
        {
            if (Expirable)
            {
                if (_expired)
                {
                    return;
                }

                _expiry.Update(time);

                if (_expiry.Expired)
                {
                    OnExpired();
                }
            }

            if (!_updated)
            {
                return;
            }

            _saveTimer.Update(time);

            if (!_saveTimer.Passed)
            {
                return;
            }

            _saveTimer.Reset();

            _updated = false;
            OnUpdated();
        }
        protected override void OnUpdate(TimeSpan time)
        {
            base.OnUpdate(time);

            _updateInterval.Update(time);

            if (!_updateInterval.Passed)
            {
                return;
            }

            _updateInterval.Interval = TimeSpan.FromMilliseconds(CycleTime + FastRandom.NextInt(-2, 2));
            _updateInterval.Reset();

            var onlineStatus = OnlineStatus;

            if (!this.IsFullyConstructed() || !onlineStatus)
            {
                return;
            }

            var zone = Zone;

            if (zone == null)
            {
                return;
            }

            if (Interlocked.CompareExchange(ref _inProgress, 1, 0) == 1)
            {
                return;
            }

            Task.Run(() => { PBSActiveObjectAction(zone); }).ContinueWith(t => { Interlocked.Exchange(ref _inProgress, 0); }).LogExceptions();
        }
        protected override void OnUpdate(TimeSpan time)
        {
            base.OnUpdate(time);

            _probingInterval.Update(time);

            if (!_probingInterval.Passed)
            {
                return;
            }

            _probingInterval.Reset();

            if (IsActive)
            {
                //detect
                var robotsNearMe = GetNoticedUnits();

                //do something
                OnUnitsFound(robotsNearMe);
            }

            if (_despawnHelper == null)
            {
                var m        = GetPropertyModifier(AggregateField.despawn_time);
                var timespan = TimeSpan.FromMilliseconds((int)m.Value);
                SetDespawnTime(timespan);
            }

            _despawnHelper.Update(time, this);
        }
예제 #9
0
            public override void Update(TimeSpan time)
            {
                _timer.Update(time);

                if (_timer.Passed)
                {
                    Module.ForceIdleState();
                }
            }
예제 #10
0
            private bool SelectPrimaryTarget(TimeSpan time)
            {
                var locks = _turret.GetLocks().Where(l => l.State == LockState.Locked).ToArray();

                if (locks.Length <= 0)
                {
                    return(false);
                }

                _primarySelectTimer.Update(time);

                if (_primarySelectTimer.Passed)
                {
                    _primarySelectTimer.Interval = FastRandom.NextTimeSpan(_minCycleTime);

                    var validLocks = new List <UnitLock>();

                    foreach (var l in locks)
                    {
                        var unitLock = (UnitLock)l;

                        if (unitLock.Primary)
                        {
                            continue;
                        }

                        var visibility = _turret.GetVisibility(unitLock.Target);
                        if (visibility == null)
                        {
                            continue;
                        }

                        var r = visibility.GetLineOfSight(false);
                        if (r != null)
                        {
                            if (r.hit && (r.blockingFlags & BlockingFlags.Plant) == 0)
                            {
                                continue;
                            }
                        }

                        validLocks.Add(unitLock);
                    }

                    if (validLocks.Count > 0)
                    {
                        var newPrimary = validLocks.RandomElement();
                        _turret.SetPrimaryLock(newPrimary);
                        return(true);
                    }
                }

                return(locks.Any(l => l.Primary));
            }
            public override void Update(TimeSpan time)
            {
                base.Update(time);

                _timer.Update(time);
                if (!_timer.Passed)
                {
                    return;
                }

                ToNormal();
            }
예제 #12
0
        public override void Update(TimeSpan time)
        {
            UpdateSessions(time);

            _updateUnitsTimer.Update(time).IsPassed(ProcessUpdatedUnits);

            UpdateUnits(time);

            RiftManager?.Update(time);
            MiningLogHandler.Update(time);
            MeasureUpdate(time);
        }
예제 #13
0
            public void Update(TimeSpan time)
            {
                _timer.Update(time);
                if (!_timer.Passed)
                {
                    return;
                }

                //20 masodperc mulva visszavalt emitbe
                _supplier._fsm.Pop();

                WriteLog("clean up state popped " + _supplier.ED.Name + " " + _supplier.Eid);
            }
        public void Update(TimeSpan time)
        {
            _productionCheckTimer.Update(time);

            if (!_productionCheckTimer.Passed)
            {
                return;
            }

            _productionCheckTimer.Reset();

            CheckProductions();
        }
예제 #15
0
        public override void Update(TimeSpan time)
        {
            _processHostilesTimer.Update(time);
            if (_processHostilesTimer.Passed)
            {
                _processHostilesTimer.Reset();
                ProcessHostiles();
            }

            foreach (var activator in _moduleActivators)
            {
                activator.Update(time);
            }
        }
예제 #16
0
        public void Update(TimeSpan time)
        {
            if (Timer != null)
            {
                Timer.Update(time);

                if (Timer.Passed)
                {
                    OnRemoved();
                    return;
                }
            }

            _tickTimer.Update(time).IsPassed(OnTick);
        }
예제 #17
0
        public void DelayedUpdate(uint diff)
        {
            i_delayTimer.Update((int)diff);
            if (!i_delayTimer.Passed())
            {
                return;
            }

            foreach (var map in i_maps.Values.ToList())
            {
                map.DelayedUpdate((uint)i_timer.GetCurrent());
            }

            i_delayTimer.SetCurrent(0);
        }
예제 #18
0
        public override void Update(TimeSpan time)
        {
            MissionAdministrator.Update(time);

            _transportAssignmentInterval.Update(time);

            if (!_transportAssignmentInterval.Passed)
            {
                return;
            }

            _transportAssignmentInterval.Reset();

            TransportAssignment.CleanUpExpiredAssignmentsAsync();
        }
예제 #19
0
        private void UpdatePlayerScores(TimeSpan time)
        {
            _updateScoreTimer.Update(time);

            if (!_updateScoreTimer.Passed)
            {
                return;
            }

            _updateScoreTimer.Reset();

            var playersInRange = GetPlayersInSAPRange();

            CheckPlayersInRange(playersInRange);
            CheckInactivePlayers(playersInRange);
        }
예제 #20
0
        public void Update(TimeSpan time, Unit unit)
        {
            _timer.Update(time).IsPassed(() =>
            {
                TryReApplyDespawnEffect(unit);

                if (unit.HasDespawnEffect)
                {
                    return;
                }

                CanApplyDespawnEffect = null;

                unit.States.Teleport = true; //kis villam visual amikor kiszedi
                unit.RemoveFromZone();
            });
        }
예제 #21
0
        protected override void OnUpdate(TimeSpan time)
        {
            base.OnUpdate(time);

            _despawnHelper.Update(time, this);

            _interval.Update(time);

            if (!_interval.Passed)
            {
                return;
            }

            _interval.Reset();

            Task.Run(() => HealWallsInRadius()).LogExceptions();
        }
예제 #22
0
        public void Update(TimeSpan time)
        {
            _timer.Update(time);

            if (!_timer.Passed)
            {
                return;
            }

            _timer.Reset();

            if (_module.State.Type != ModuleStateType.Idle)
            {
                return;
            }

            _module.AcceptVisitor(this);
        }
예제 #23
0
        public void Update(TimeSpan time)
        {
            _updateTimer.Update(time);

            if (!_updateTimer.Passed)
            {
                return;
            }

            OnUpdate(_updateTimer.Elapsed);

            foreach (var flock in _flocks)
            {
                flock.Update(_updateTimer.Elapsed);
            }

            _updateTimer.Reset();
        }
        public void Update(T pbsObject, TimeSpan time)
        {
            if (_running)
            {
                return;
            }

            _timer.Update(time);
            if (!_timer.Passed)
            {
                return;
            }
            _timer.Reset();

            _running = true;
            Task.Run(() => _entityRepository.Update(pbsObject))
            .ContinueWith(t => _running = false)
            .LogExceptions();
        }
        public override void Update(TimeSpan time)
        {
            _degradeTimer.Update(time);
            if (_degradeTimer.Passed)
            {
                _degradeTimer.Reset();
                var o = new TerrainDegradeOperation(_degradeArea);
                EnqueueTerraformingOperation(o);
            }

            DequeueTerraformingOperations();

            _timer.Update(time);
            if (_timer.Passed)
            {
                _timer.Reset();
                ProcessAffectedPositions();
            }
        }
예제 #26
0
        public void Update(TimeSpan time)
        {
            if (_cachedMissionTargets.Count == 0 || _enqueuedMissionEventInfos.Count == 0)
            {
                return;
            }

            _timerUpdateMissions.Update(time);

            if (!_timerUpdateMissions.Passed)
            {
                return;
            }
            _timerUpdateMissions.Reset();

            MissionEventInfo missionEventInfo;

            while (_enqueuedMissionEventInfos.TryDequeue(out missionEventInfo))
            {
                foreach (var missionTarget in _cachedMissionTargets.Values)
                {
                    if (missionTarget == null)
                    {
                        continue;
                    }

                    if (!missionTarget.HandleMissionEvent(missionEventInfo))
                    {
                        continue;
                    }

                    if (missionTarget.IsCompleted)
                    {
                        //the dequeued item finished a target
                        _cachedMissionTargets.Remove(missionTarget.Id);
                    }

                    //the event got used up
                    break;
                }
            }
        }
        private void WarmUpCycleWork(TimeSpan time)
        {
            _timer.Update(time);
            if (!_timer.Passed)
            {
                return;
            }
            _timer.Reset();

            Owner.CoreUseHandler.EnergyState = PBSEnergyState.warmup;
            Owner.CoreUseHandler.LastCoreUse = 0;

            if (Owner.CorePercentage > Owner.CoreUseHandler.GetKickStartCoreRatio())
            {
                Owner.CoreUseHandler.ToActiveState();
                return;
            }

            OnWarmUpCycle();
        }
예제 #28
0
        protected override void OnUpdate(TimeSpan time)
        {
            base.OnUpdate(time);

            if (!Enabled || IntrusionInProgress)
            {
                return;
            }

            _timerCheckIntrusionTime.Update(time);

            if (!_timerCheckIntrusionTime.Passed)
            {
                return;
            }

            _timerCheckIntrusionTime.Reset();

            CheckIntrusionStartTimeAsync();
        }
예제 #29
0
        public void Update(uint diff)
        {
            i_timer.Update((int)diff);
            if (!i_timer.Passed())
            {
                return;
            }

            foreach (var map in i_maps.Values.ToList())
            {
                map.Update((uint)i_timer.GetCurrent());
            }

            DelayedUpdate(diff);

            //sObjectAccessor->Update(uint32(i_timer.GetCurrent()));
            //for (TransportSet::iterator itr = m_Transports.begin(); itr != m_Transports.end(); ++itr)
            //(*itr)->Update(uint32(i_timer.GetCurrent()));

            i_timer.SetCurrent(0);
        }
        private void UpdateExpiredMissions(TimeSpan time)
        {
            _missionExpireTimer.Update(time);

            if (!_missionExpireTimer.Passed)
            {
                return;
            }

            _missionExpireTimer.Reset();

            if (!_expireInProgress)
            {
                _expireInProgress = true;

                Task.Run(() =>
                {
                    MissionExpireCycle();
                    _expireInProgress = false;
                }).LogExceptions();
            }
        }