示例#1
0
 private void RunOutputChanges(Agent agent, WorldObjectType.State newState, WorldObjectType.State currentState)
 {
     for (int i = 0; i < worldObjectType.statesOutputChanges.Count; i++)
     {
         OutputChange outputChange = worldObjectType.statesOutputChanges[i];
         // currentState can be null on Start
         if (newState.enterOutputChangesIndexes.Contains(i) || (currentState != null && currentState.exitOutputChangesIndexes.Contains(i)))
         {
             float amount = outputChange.outputChangeType.CalculateAmount(agent, this, outputChange, null);
             if (!outputChange.CheckConditions(this, agent, null, amount))
             {
                 Debug.Log(agent + ": WorldObject.RunOutputChanges - output conditions failed - " + this);
                 if (outputChange.stopType == OutputChange.StopType.OnOCCFailed)
                 {
                     return;
                 }
             }
             bool succeeded = outputChange.outputChangeType.MakeChange(agent, this, outputChange, null, amount, out bool forceStop);
             Debug.Log(agent + ": WorldObject.RunOutputChanges - output condition " + outputChange.outputChangeType.name + " - " + succeeded);
             if ((forceStop && !outputChange.blockMakeChangeForcedStop) ||
                 (outputChange.stopType == OutputChange.StopType.OnChangeFailed && !succeeded))
             {
                 return;
             }
         }
     }
 }