public virtual void AIThink(float delta) { BaseAIBrain<T>.BasicAIState currentState = this.GetCurrentState(); if (currentState != null) { currentState.StateThink(delta); } if (currentState == null || currentState.CanInterrupt()) { float single = 0f; int num = 0; BaseAIBrain<T>.BasicAIState basicAIState = null; for (int i = 0; i < (int)this.AIStates.Length; i++) { BaseAIBrain<T>.BasicAIState aIStates = this.AIStates[i]; if (aIStates != null) { float weight = aIStates.GetWeight(); if (weight > single) { single = weight; num = i; basicAIState = aIStates; } } } if (basicAIState != currentState) { this.SwitchToState(num); } } }
public virtual void AIThink(float delta) { BaseAIBrain <T> .BasicAIState currentState = this.GetCurrentState(); currentState?.StateThink(delta); if (currentState != null && !currentState.CanInterrupt()) { return; } float num = 0.0f; int newState = 0; BaseAIBrain <T> .BasicAIState basicAiState = (BaseAIBrain <T> .BasicAIState)null; for (int index = 0; index < this.AIStates.Length; ++index) { BaseAIBrain <T> .BasicAIState aiState = this.AIStates[index]; if (aiState != null) { float weight = aiState.GetWeight(); if ((double)weight > (double)num) { num = weight; newState = index; basicAiState = aiState; } } } if (basicAiState == currentState) { return; } this.SwitchToState(newState); }
public virtual void AddState(BaseAIBrain<T>.BasicAIState newState, int newIndex) { newState.SetIndex(newIndex); this.AIStates[newIndex] = newState; newState.brain = this; newState.Reset(); }
public void OnDrawGizmos() { BaseAIBrain <CH47HelicopterAIController> .BasicAIState currentState = base.GetCurrentState(); if (currentState != null) { currentState.DrawGizmos(); } }
public override void ServerInit() { base.ServerInit(); brain = GetComponent <BaseAIBrain <BaseAnimalNPC> >(); if (!base.isClient) { AIThinkManager.AddAnimal(this); } }
public override void ServerInit() { base.ServerInit(); Brain = GetComponent <BaseAIBrain <HumanNPCNew> >(); if (!base.isClient) { AIThinkManager.Add(this); } }
public override void ServerInit() { base.ServerInit(); _brain = GetComponent <BaseAIBrain <HumanNPC> >(); if (!base.isClient) { AIThinkManager.Add(this); Invoke(EnableNavAgent, 0.25f); spawnPos = base.transform.position; } }
public void SwitchToState(int newState) { BaseAIBrain <T> .BasicAIState currentState = this.GetCurrentState(); BaseAIBrain <T> .BasicAIState state = this.GetState(newState); if (currentState != null) { if (currentState == state || !currentState.CanInterrupt()) { return; } currentState.StateLeave(); } this._currentState = newState; state.StateEnter(); }