コード例 #1
0
	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);
			}
		}
	}
コード例 #2
0
    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);
    }
コード例 #3
0
	public virtual void AddState(BaseAIBrain<T>.BasicAIState newState, int newIndex)
	{
		newState.SetIndex(newIndex);
		this.AIStates[newIndex] = newState;
		newState.brain = this;
		newState.Reset();
	}
コード例 #4
0
 public void OnDrawGizmos()
 {
     BaseAIBrain <CH47HelicopterAIController> .BasicAIState currentState = base.GetCurrentState();
     if (currentState != null)
     {
         currentState.DrawGizmos();
     }
 }
コード例 #5
0
ファイル: BaseAnimalNPC.cs プロジェクト: Ailtop/RustDocuments
 public override void ServerInit()
 {
     base.ServerInit();
     brain = GetComponent <BaseAIBrain <BaseAnimalNPC> >();
     if (!base.isClient)
     {
         AIThinkManager.AddAnimal(this);
     }
 }
コード例 #6
0
ファイル: HumanNPCNew.cs プロジェクト: Ailtop/RustDocuments
 public override void ServerInit()
 {
     base.ServerInit();
     Brain = GetComponent <BaseAIBrain <HumanNPCNew> >();
     if (!base.isClient)
     {
         AIThinkManager.Add(this);
     }
 }
コード例 #7
0
ファイル: HumanNPC.cs プロジェクト: Ailtop/RustDocuments
 public override void ServerInit()
 {
     base.ServerInit();
     _brain = GetComponent <BaseAIBrain <HumanNPC> >();
     if (!base.isClient)
     {
         AIThinkManager.Add(this);
         Invoke(EnableNavAgent, 0.25f);
         spawnPos = base.transform.position;
     }
 }
コード例 #8
0
 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();
 }