Example #1
0
        public HealingAuraAgentComponent(Agent agent, Mission mission) : base(agent)
        {
            currentMission = mission;
            float time = MBCommon.GetTime(MBCommon.TimeType.Mission);

            this.healTimer = new Timer(time, secondsBetweenHealProcs, true);
        }
 private void OnEscapeMenuToggled(bool isOpened)
 {
     if (isOpened)
     {
         if (!GameNetwork.IsMultiplayer)
         {
             MBCommon.PauseGameEngine();
         }
     }
     else
     {
         MBCommon.UnPauseGameEngine();
     }
     if (isOpened)
     {
         _dataSource    = new OptionsModOptionsViewModel(new OptionsVM(GameNetwork.IsMultiplayer, OnCloseOptions, OnKeybindRequest), new ModOptionsVM());
         _gauntletLayer = new GauntletLayer(ViewOrderPriorty, "GauntletLayer");
         _gauntletLayer.InputRestrictions.SetInputRestrictions(true, InputUsageMask.All);
         _gauntletLayer.Input.RegisterHotKeyCategory(HotKeyManager.GetCategory("GenericPanelGameKeyCategory"));
         _movie = _gauntletLayer.LoadMovie("OptionsWithModOptionsView_v3", _dataSource);
         MissionScreen.AddLayer(_gauntletLayer);
         _gauntletLayer.IsFocusLayer = true;
         ScreenManager.TrySetFocus(_gauntletLayer);
         return;
     }
     _gauntletLayer.InputRestrictions.ResetInputRestrictions();
     _gauntletLayer.IsFocusLayer = false;
     ScreenManager.TryLoseFocus(_gauntletLayer);
     MissionScreen.RemoveLayer(_gauntletLayer);
     _keybindingPopup?.OnToggle(false);
     _gauntletLayer = null !;
     _dataSource?.OnFinalize();
     _dataSource    = null !;
     _gauntletLayer = null !;
 }
Example #3
0
        protected override void Initialize()
        {
            base.Initialize();
            float time = MBCommon.GetTime(MBCommon.TimeType.Mission);

            crumbleTimer = new Timer(time, crumbleFrequencyInSeconds, true);
            InitializeMorale();
        }
 protected override void OnBehaviorActivatedAux()
 {
     this.formation.ArrangementOrder = this.formation.QuerySystem.HasShield ? ArrangementOrder.ArrangementOrderShieldWall : ArrangementOrder.ArrangementOrderLine;
     this.formation.FacingOrder      = FacingOrder.FacingOrderLookAtEnemy;
     this.formation.FiringOrder      = FiringOrder.FiringOrderFireAtWill;
     this.formation.FormOrder        = FormOrder.FormOrderDeep;
     this.formation.WeaponUsageOrder = WeaponUsageOrder.WeaponUsageOrderUseAny;
     this._lastPlayerInformTime      = MBCommon.GetTime(MBCommon.TimeType.Mission);
 }
 public void CreateWarningWidget()
 {
     if (!GameNetwork.IsClient)
     {
         MBCommon.PauseGameEngine();
     }
     InformationManager.ShowInquiry(this._retreatPopUpData, true);
     this.IsWarningWidgetOpened = true;
 }
Example #6
0
 public T GetCachedValueWithMaxAge(float age)
 {
     if (MBCommon.GetTime(MBCommon.TimeType.Application) <= _expireTime - (double)_lifetime + Math.Min(_lifetime, age))
     {
         return(_cachedValue);
     }
     Expire();
     return(Value);
 }
Example #7
0
        public void UnPauseGame()
        {
            if (!MBCommon.IsPaused)
            {
                return;
            }

            MBCommon.UnPauseGameEngine();
            Game.Current.GameStateManager.ActiveStateDisabledByUser = false;
        }
Example #8
0
        public void PauseGame()
        {
            if (MBCommon.IsPaused)
            {
                return;
            }

            MBCommon.PauseGameEngine();
            Game.Current.GameStateManager.ActiveStateDisabledByUser = true;
        }
Example #9
0
 public override void OnTick(float dt)
 {
     if (this.IsSpawningEnabled && this._spawnCheckTimer.Check(MBCommon.GetTime(MBCommon.TimeType.Mission)))
     {
         this.SpawnAgents();
     }
     if (this.IsSpawningEnabled && this._spawnCheckTimer.Check(MBCommon.GetTime(MBCommon.TimeType.Mission)))
     {
         this.SpawnItems();
     }
     base.OnTick(dt);
 }
 private void CloseSelectionWidget()
 {
     if (!this.IsWarningWidgetOpened)
     {
         return;
     }
     this.IsWarningWidgetOpened = false;
     if (GameNetwork.IsClient)
     {
         return;
     }
     MBCommon.UnPauseGameEngine();
 }
 protected override void OnTickAsAI(float dt)
 {
     if (base.Morale < 20f)
     {
         canCrumble = crumbleTimer.Check(MBCommon.GetTime(MBCommon.TimeType.Mission));
         if (canCrumble)
         {
             float damageTaken = 0.01f / base.Morale;
             damageTaken        = MBMath.ClampFloat(damageTaken, 0, 1);
             this.Agent.Health -= damageTaken;
             crumbleTimer.Reset(MBCommon.GetTime(MBCommon.TimeType.Mission));
             Helpers.Say(this.Agent.Name + " took " + damageTaken + " damage from low morale.");
         }
     }
 }
Example #12
0
 protected override void OnTickAsAI(float dt)
 {
     if (Morale < 20f)
     {
         canCrumble = crumbleTimer.Check(MBCommon.GetTime(MBCommon.TimeType.Mission));
         if (canCrumble)
         {
             float damageTaken = 0.01f / Morale;
             damageTaken = MBMath.ClampFloat(damageTaken, 0, 1);
             Agent.ApplyDamage(damageTaken);
             crumbleTimer.Reset(MBCommon.GetTime(MBCommon.TimeType.Mission));
             //Helpers.Say(Agent.Name + " took " + damageTaken + " crumbling damage from low binding");
         }
     }
 }
Example #13
0
 private void EndSelection()
 {
     if (!_isActive)
     {
         return;
     }
     _isActive = false;
     RemoveLayer();
     if (!_isLastActiveGameStatePaused)
     {
         return;
     }
     GameStateManager.Current.ActiveStateDisabledByUser = _isLastActiveGameStateActive;
     MBCommon.UnPauseGameEngine();
 }
        private static void OnApply(ref ArrangementOrder __instance, Formation formation)
        {
            var instanceOrderEnum  = __instance.GetOrderEnumField();
            var formationOrderEnum = formation.MovementOrder.GetOrderEnumField();

            formation.SetPositioning(new WorldPosition?(), new Vec2?(), new int?(__instance.GetUnitSpacingField()));
            __instance.Rearrange(formation);

            if (instanceOrderEnum == ArrangementOrderEnum.Scatter)
            {
                __instance.TickOccasionally(formation);
            }

            foreach (Agent agent in formation.Units.Where(u => u.IsAIControlled))
            {
                Agent.UsageDirection shieldDirectionOfUnit = __instance.GetShieldDirectionOfUnit(formation, agent);
                agent.EnforceShieldUsage(shieldDirectionOfUnit);
            }

            if (formationOrderEnum != MovementOrderEnum.Charge && formationOrderEnum != MovementOrderEnum.ChargeToTarget)
            {
                if (instanceOrderEnum != ArrangementOrderEnum.Circle && instanceOrderEnum != ArrangementOrderEnum.ShieldWall && instanceOrderEnum != ArrangementOrderEnum.Square && instanceOrderEnum != ArrangementOrderEnum.Column)
                {
                    foreach (Agent unit in formation.Units)
                    {
                        MovementOrderMethods.SetDefaultMoveBehaviorValues(unit);
                    }
                }
                else if (instanceOrderEnum != ArrangementOrderEnum.Column)
                {
                    foreach (Agent unit in formation.Units)
                    {
                        MovementOrderMethods.SetDefensiveArrangementMoveBehaviorValues(unit);
                    }
                }
                else
                {
                    foreach (Agent unit in formation.Units)
                    {
                        MovementOrderMethods.SetFollowBehaviorValues(unit);
                    }
                }
            }

            __instance.SetTickTimerField(new Timer(MBCommon.GetTime(MBCommon.TimeType.Mission), 0.5f, true));
        }
Example #15
0
 public void BeginSelection(CharacterSelectionData data)
 {
     if (_isActive)
     {
         return;
     }
     _isActive = true;
     CreateLayer();
     _isLastActiveGameStatePaused = data.PauseGameActiveState;
     if (!_isLastActiveGameStatePaused)
     {
         return;
     }
     _isLastActiveGameStateActive = GameStateManager.Current.ActiveStateDisabledByUser;
     GameStateManager.Current.ActiveStateDisabledByUser = true;
     MBCommon.PauseGameEngine();
 }
Example #16
0
 protected override void OnTickAsAI(float dt)
 {
     canHeal = healTimer.Check(MBCommon.GetTime(MBCommon.TimeType.Mission));
     if (canHeal)
     {
         IEnumerable <Agent> nearbyAgents = currentMission.GetNearbyAgents(Agent.GetWorldPosition().AsVec2, healRadius);
         foreach (Agent agent in nearbyAgents)
         {
             if (!agent.Team.IsEnemyOf(Agent.Team))
             {
                 float maxHitPoints = agent.Character.MaxHitPoints();
                 agent.Health = Math.Min(agent.Health + healAmount, maxHitPoints);
                 Helpers.Say(Agent.Name + " healed " + agent.Character.Name + " from " + (agent.Health - 1) + " to " + agent.Health);
             }
         }
         healTimer.Reset(MBCommon.GetTime(MBCommon.TimeType.Mission));
     }
 }
 public bool CheckRemove()
 {
     if (config.Duration.HasValue &&
         MBCommon.GetTime(MBCommon.TimeType.Mission) > config.Duration.Value + started)
     {
         Log.LogFeedEvent($"{config.Name} expired on {agent.Name}!");
         if (!string.IsNullOrEmpty(config.DeactivateParticleEffect))
         {
             Mission.Current.Scene.CreateBurstParticle(ParticleSystemManager.GetRuntimeIdByName(config.DeactivateParticleEffect), agent.AgentVisuals.GetGlobalFrame());
         }
         if (!string.IsNullOrEmpty(config.DeactivateSound))
         {
             Mission.Current.MakeSound(SoundEvent.GetEventIdFromString(config.DeactivateSound), agent.AgentVisuals.GetGlobalFrame().origin, false, true, agent.Index, -1);
         }
         Stop();
         return(true);
     }
     return(false);
 }
            protected override void CalculateCurrentOrder()
            {
                FieldInfo property = typeof(BehaviorComponent).GetField("formation", BindingFlags.NonPublic | BindingFlags.Instance);

                property.DeclaringType.GetField("formation");
                property.SetValue(this, attackingFormation, BindingFlags.NonPublic | BindingFlags.SetProperty, null, null);

                PropertyInfo PreserveExpireTimeInfo = typeof(BehaviorComponent).GetProperty("PreserveExpireTime", BindingFlags.NonPublic | BindingFlags.Instance);

                PreserveExpireTimeInfo.DeclaringType.GetProperty("PreserveExpireTime");
                PreserveExpireTimeInfo.SetValue(this, 0f, BindingFlags.NonPublic, null, null, null);

                FieldInfo _navmeshlessTargetPenaltyTimeInfo = typeof(BehaviorComponent).GetField("_navmeshlessTargetPenaltyTime", BindingFlags.NonPublic | BindingFlags.Instance);

                _navmeshlessTargetPenaltyTimeInfo.DeclaringType.GetField("_navmeshlessTargetPenaltyTime");
                _navmeshlessTargetPenaltyTimeInfo.SetValue(this, new Timer(MBCommon.GetTime(MBCommon.TimeType.Mission), 20f), BindingFlags.NonPublic, null, null);

                WorldPosition position;

                if (attackingFormation != null && victimFormation != null && attackingFormation.QuerySystem.ClosestEnemyFormation != null)
                {
                    Vec2 vec;
                    if (attackingFormation.AI.Side == FormationAI.BehaviorSide.Left)
                    {
                        Vec2 v = (attackingFormation.QuerySystem.Team.MedianTargetFormationPosition.AsVec2 - victimFormation.QuerySystem.MedianPosition.AsVec2).Normalized();
                        vec  = victimFormation.CurrentPosition + v.LeftVec().Normalized() * (victimFormation.Width + attackingFormation.Width + 5f);
                        vec -= v * (victimFormation.Depth + attackingFormation.Depth);
                    }
                    else
                    {
                        Vec2 v = (attackingFormation.QuerySystem.Team.MedianTargetFormationPosition.AsVec2 - victimFormation.QuerySystem.MedianPosition.AsVec2).Normalized();
                        vec  = victimFormation.CurrentPosition + v.RightVec().Normalized() * (victimFormation.Width + attackingFormation.Width + 5f);
                        vec -= v * (victimFormation.Depth + attackingFormation.Depth);
                    }

                    WorldPosition medianPosition = victimFormation.QuerySystem.MedianPosition;
                    medianPosition.SetVec2(vec);
                    //position = (attackingFormation.AI.Side == FormationAI.BehaviorSide.Right) ? victimFormation.QuerySystem.Team.RightFlankEdgePosition : victimFormation.QuerySystem.Team.LeftFlankEdgePosition;
                    //Vec2 direction = (position.AsVec2 - attackingFormation.QuerySystem.AveragePosition).Normalized();
                    base.CurrentOrder = MovementOrder.MovementOrderMove(medianPosition);
                }
                //CurrentFacingOrder = FacingOrder.FacingOrderLookAtDirection(direction);
            }
Example #19
0
        protected override void OnTickAsAI(float dt)
        {
            healReady = healTimer.Check(MBCommon.GetTime(MBCommon.TimeType.Mission));
            if (healReady)
            {
                IEnumerable <Agent> nearbyAgents = currentMission.GetNearbyAgents(Agent.GetWorldPosition().AsVec2, healRadius);
                foreach (Agent agent in nearbyAgents)
                {
                    float maxHitPoints = agent.Character.MaxHitPoints();
                    if (!agent.Team.IsEnemyOf(Agent.Team) && agent.Health != maxHitPoints)
                    {
                        string origHealth = agent.Health.ToString();

                        //Prevent overhealing with Math.Min
                        agent.SyncHealthToClient();
                        agent.Heal(healAmount);
                        //Helpers.Say(Agent.Name + " healed " + agent.Character.Name + " from " + origHealth + " to " + agent.Health);
                    }
                }
                healTimer.Reset(MBCommon.GetTime(MBCommon.TimeType.Mission));
            }
        }
Example #20
0
 private void UnpauseGame()
 {
     MBCommon.UnPauseGameEngine();
 }
Example #21
0
 private void PauseGame()
 {
     MBCommon.PauseGameEngine();
 }
Example #22
0
        protected override void SpawnAgents()
        {
            BasicCultureObject cultureTeam  = MBMultiplayerOptionsAccessor.GetCultureTeam1(MBMultiplayerOptionsAccessor.MultiplayerOptionsAccessMode.CurrentMapOptions);
            BasicCultureObject cultureTeam2 = MBMultiplayerOptionsAccessor.GetCultureTeam2(MBMultiplayerOptionsAccessor.MultiplayerOptionsAccessMode.CurrentMapOptions);
            var availableCultures           = MBObjectManager.Instance.GetObjectTypeList <BasicCultureObject>()
                                              .Where(x => x.IsMainCulture).ToList();

            foreach (MissionPeer missionPeer in VirtualPlayer.Peers <MissionPeer>())
            {
                NetworkCommunicator networkPeer = missionPeer.GetNetworkPeer();
                if (networkPeer.IsSynchronized && missionPeer.ControlledAgent == null && !missionPeer.HasSpawnedAgentVisuals && missionPeer.Team != null && missionPeer.Team != base.Mission.SpectatorTeam && missionPeer.SpawnTimer.Check(MBCommon.GetTime(MBCommon.TimeType.Mission)))
                {
                    BasicCultureObject basicCultureObject = (missionPeer.Team.Side == BattleSideEnum.Attacker) ? cultureTeam : cultureTeam2;
                    MultiplayerClassDivisions.MPHeroClass mpheroClassForPeer =
                        MultiplayerClassDivisions.GetMPHeroClasses().GetRandomElement();                        // MultiplayerClassDivisions.GetMPHeroClassForPeer(missionPeer);


                    BasicCharacterObject heroCharacter = mpheroClassForPeer.HeroCharacter;

                    AgentBuildData agentBuildData = new AgentBuildData(heroCharacter);
                    agentBuildData.MissionPeer(missionPeer);

                    agentBuildData.EquipmentSeed(
                        this.MissionLobbyComponent.GetRandomFaceSeedForCharacter(heroCharacter, 0));
                    agentBuildData.Equipment(Equipment.GetRandomEquipmentElements(heroCharacter, true, false, agentBuildData.AgentEquipmentSeed));
                    agentBuildData.Team(missionPeer.Team);
                    agentBuildData.IsFemale(missionPeer.Peer.IsFemale);
                    agentBuildData.BodyProperties(base.GetBodyProperties(missionPeer, (missionPeer.Team == base.Mission.AttackerTeam) ? cultureTeam : cultureTeam2));
                    agentBuildData.VisualsIndex(0);
                    agentBuildData.ClothingColor1(availableCultures.GetRandomElement().Color);
                    agentBuildData.ClothingColor2(availableCultures.GetRandomElement().Color2);

                    agentBuildData.TroopOrigin(new BasicBattleAgentOrigin(heroCharacter));
                    if (this.GameMode.ShouldSpawnVisualsForServer(networkPeer))
                    {
                        base.AgentVisualSpawnComponent.SpawnAgentVisualsForPeer(missionPeer, agentBuildData, missionPeer.SelectedTroopIndex, false, 0);
                    }
                    this.GameMode.HandleAgentVisualSpawning(networkPeer, agentBuildData, 0);
                }
            }
            if (base.Mission.AttackerTeam != null)
            {
                int num = 0;
                foreach (Agent agent in base.Mission.AttackerTeam.ActiveAgents)
                {
                    if (agent.Character != null && agent.MissionPeer == null)
                    {
                        num++;
                    }
                }
                if (num < MBMultiplayerOptionsAccessor.GetNumberOfBotsTeam1(MBMultiplayerOptionsAccessor.MultiplayerOptionsAccessMode.CurrentMapOptions))
                {
                    base.SpawnBot(base.Mission.AttackerTeam, cultureTeam);
                }
            }
            if (base.Mission.DefenderTeam != null)
            {
                int num2 = 0;
                foreach (Agent agent2 in base.Mission.DefenderTeam.ActiveAgents)
                {
                    if (agent2.Character != null && agent2.MissionPeer == null)
                    {
                        num2++;
                    }
                }
                if (num2 < MBMultiplayerOptionsAccessor.GetNumberOfBotsTeam2(MBMultiplayerOptionsAccessor.MultiplayerOptionsAccessMode.CurrentMapOptions))
                {
                    var agent = SpawnBot(base.Mission.DefenderTeam, cultureTeam2);
                }
            }
        }
Example #23
0
 /// <summary>
 /// Get a random float between 0 and the healing frequency so agents that have healing auras won't all heal simultaneously.
 /// Otherwise, there's a periodic high CPU load.
 /// </summary>
 /// <returns>float between 0 and the healing frequency</returns>
 private float GetHealStartTime()
 {
     return(MBCommon.GetTime(MBCommon.TimeType.Mission) - (float)Helpers.rng.NextDouble() * secondsBetweenHealProcs);
 }
Example #24
0
 public PeaceGameSpawningBehavior()
 {
     this._spawnCheckTimer  = new Timer(MBCommon.GetTime(MBCommon.TimeType.Mission), 0.2f, true);
     this.IsSpawningEnabled = true;
 }
Example #25
0
        private WorldPosition GetTargetPosition(Agent agent)
        {
            try
            {
                var unit = agent;
                if (!unit.IsActive())
                {
                    return(WorldPosition.Invalid);
                }
                var formation = unit.Formation;
                if (formation == null)
                {
                    return(WorldPosition.Invalid);
                }
                var targetFormation = QueryDataStore.Get(formation.TargetFormation);

                Vec2 offset;
                if (QueryLibrary.IsCavalry(unit) || QueryLibrary.IsRangedCavalry(unit) &&
                    formation.FiringOrder.OrderType == OrderType.HoldFire)
                {
                    var averageOfTargetAgents = QueryDataStore.Get(formation).AverageOfTargetAgents.Value;

                    offset = averageOfTargetAgents.IsValid ? formation.TargetFormation.QuerySystem.AveragePosition * 0.2f + averageOfTargetAgents * 0.8f - formation.QuerySystem.AveragePosition : Vec2.Zero;
                }
                else if (QueryLibrary.IsInfantry(unit) || QueryLibrary.IsRanged(unit) &&
                         formation.FiringOrder.OrderType == OrderType.HoldFire)
                {
                    var targetCenterAgent =
                        targetFormation.NearestAgent(formation.CurrentPosition);
                    if (targetCenterAgent == null)
                    {
                        return(WorldPosition.Invalid);
                    }
                    offset = targetCenterAgent.Position.AsVec2 - formation.CurrentPosition;
                }
                else
                {
                    return(WorldPosition.Invalid);
                }

                Vec2 targetPosition = formation.GetCurrentGlobalPositionOfUnit(unit, true) + offset;

                var targetAgent = targetFormation.NearestAgent(targetPosition);
                var result      = targetAgent?.GetWorldPosition() ?? WorldPosition.Invalid;
                PositionOfTargetAgent.SetValue(result.AsVec2, MBCommon.GetTime(MBCommon.TimeType.Mission));
                if (targetAgent == null || !result.IsValid || result.GetNavMesh() == UIntPtr.Zero)
                {
                    result = unit.GetWorldPosition();
                    result.SetVec2(result.AsVec2 + unit.GetMovementDirection().AsVec2 * 0.1f);
                    return(result);
                }

                if (QueryLibrary.IsInfantry(unit) || QueryLibrary.IsRanged(unit) &&
                    formation.FiringOrder.OrderType == OrderType.HoldFire)
                {
                    result.SetVec2((unit.Position.AsVec2 - result.AsVec2).Normalized() * 0.8f + result.AsVec2 +
                                   targetAgent.Velocity.AsVec2 * 1);
                }
                else if (QueryLibrary.IsCavalry(unit) || QueryLibrary.IsRangedCavalry(unit) &&
                         formation.FiringOrder.OrderType == OrderType.HoldFire)
                {
                    result.SetVec2((result.AsVec2 - unit.Position.AsVec2).Normalized() * 3f + result.AsVec2 +
                                   targetAgent.Velocity.AsVec2 * 1 + unit.Velocity.AsVec2 * 1);
                }
                else
                {
                    return(WorldPosition.Invalid);
                }
                return(result);
            }
            catch (Exception e)
            {
                Utility.DisplayMessage(e.ToString());
            }

            return(WorldPosition.Invalid);
        }
Example #26
0
        private async void ReactToIssuedOrder(OrderType orderType, IEnumerable <Formation> appliedFormations, params object[] delegateParams)
        {
            if (Mission.Current == null)
            {
                return;
            }

            _orderType = orderType;
            var randomAgent = appliedFormations.GetRandomElement().Team.ActiveAgents.GetRandomElement();

            PlayHornBasedOnCulture(randomAgent, Agent.Main, orderType);

            var shouldContinuouslyYell = _config.ResponsiveOrders.ContinuousChargeYell &&
                                         (orderType == OrderType.Charge ||
                                          orderType == OrderType.ChargeWithTarget);

            if (shouldContinuouslyYell)
            {
                var rng = MBRandom.RandomInt(8, 15);

                for (int i = 0; i < rng; i++)
                {
                    for (int f = 0; f <= appliedFormations.Count(); f++)
                    {
                        Formation formation = null;
                        try {
                            formation = appliedFormations.ElementAt(f);
                        } catch { }
                        if (formation == null)
                        {
                            return;
                        }

                        var timeGate = MBCommon.GetTime(MBCommon.TimeType.Mission) + (MBRandom.RandomInt(3, 9) / 10f);
                        while (Mission.Current != null)
                        {
                            if (timeGate > MBCommon.GetTime(MBCommon.TimeType.Mission))
                            {
                                await Task.Delay(300);

                                continue;
                            }
                            formation.ApplyActionOnEachUnit(Charge);
                            break;
                        }
                    }
                }
                _affirmativeAgentCounter = 0;
            }
            else
            {
                // default reaction
                for (int f = 0; f <= appliedFormations.Count(); f++)
                {
                    var formation = appliedFormations.ElementAt(f);
                    if (formation == null)
                    {
                        return;
                    }

                    formation.ApplyActionOnEachUnit(Affirmative);
                    _affirmativeAgentCounter = 0;
                }
            }
        }
Example #27
0
 public BasicTimer(MBCommon.TimeType timeType)
 {
     this._timeType  = timeType;
     this._startTime = MBCommon.GetTime(timeType);
 }
Example #28
0
 public void Reset() => this._startTime = MBCommon.GetTime(this._timeType);
Example #29
0
        public void Tick(float dt)
        {
            float time = MBCommon.GetTime(MBCommon.TimeType.Mission);

            if (this._tickOccasionallyTimer == null || this._tickOccasionallyTimer.Check(time))
            {
                float dt1 = dt;
                if (this._tickOccasionallyTimer != null)
                {
                    dt1 = this._tickOccasionallyTimer.ElapsedTime();
                }
                this._tickOccasionallyTimer = new Timer(time, (float)(0.100000001490116 + (double)MBRandom.RandomFloat * 0.100000001490116));
                this.TickOccasionally(dt1);
            }
            bool flag = false;

            foreach (Agent nearbyAgent in this._nearbyAgents)
            {
                Vec3 position = nearbyAgent.Position;
                if ((this._teamToCollect == BattleSideEnum.None || nearbyAgent.Team != null && nearbyAgent.Team.Side == this._teamToCollect) && nearbyAgent.IsAIControlled)
                {
                    if (nearbyAgent.GetCurrentNavigationFaceId() == this._navMeshId)
                    {
                        flag = true;
                        break;
                    }
                    if (this._isBeingUsed && (double)position.DistanceSquared(this._pathFrameToCheck.origin) < (double)this._radiusToCheck * (double)this._radiusToCheck)
                    {
                        flag = true;
                        break;
                    }
                    if ((double)nearbyAgent.MovementVelocity.LengthSquared > 0.00999999977648258)
                    {
                        Vec2 direction = this._directionToCollect != AgentPathNavMeshChecker.Direction.ForwardOnly ? (this._directionToCollect != AgentPathNavMeshChecker.Direction.BackwardOnly ? Vec2.Zero : -this._pathFrameToCheck.rotation.f.AsVec2) : this._pathFrameToCheck.rotation.f.AsVec2;
                        if (nearbyAgent.HasPathThroughNavigationFaceIdFromDirection(this._navMeshId, direction))
                        {
                            float num = nearbyAgent.GetPathDistanceToPoint(ref this._pathFrameToCheck.origin);
                            if ((double)num >= 100000.0)
                            {
                                num = nearbyAgent.Position.Distance(this._pathFrameToCheck.origin);
                            }
                            float forwardUnlimitedSpeed = nearbyAgent.MaximumForwardUnlimitedSpeed;
                            if ((double)num < (double)this._radiusToCheck * 2.0 || (double)num / (double)forwardUnlimitedSpeed < (double)this._agentMoveTime)
                            {
                                flag = true;
                            }
                        }
                    }
                }
            }
            if (flag)
            {
                this._isBeingUsed = true;
                this._setBeingUsedToFalseTimer = (Timer)null;
            }
            else if (this._setBeingUsedToFalseTimer == null)
            {
                this._setBeingUsedToFalseTimer = new Timer(time, 1f);
            }
            if (this._setBeingUsedToFalseTimer == null || !this._setBeingUsedToFalseTimer.Check(time))
            {
                return;
            }
            this._setBeingUsedToFalseTimer = (Timer)null;
            this._isBeingUsed = false;
        }
 private void UnpauseGame()
 {
     MBCommon.UnPauseGameEngine();
     Game.Current.GameStateManager.ActiveStateDisabledByUser = _oldGameStatusDisabledStatus;
 }