Пример #1
0
 /// <summary>
 /// The default canPerform method. 
 /// Should be used to check if all dependent subsystems can perform and extended by subsystem implementations.
 /// </summary>
 /// <param name="oldState"></param>
 /// <param name="newState"></param>
 /// <param name="tasks"></param>
 /// <param name="environment"></param>
 /// <returns></returns>
 public virtual bool CanPerform(Event proposedEvent, Universe environment)
 {
     foreach (var sub in DependentSubsystems)
     {
         if (!sub.IsEvaluated)// && !sub.GetType().Equals(typeof(ScriptedSubsystem)))
             if (sub.CanPerform(proposedEvent, environment) == false)
                 return false;
     }
     _task = proposedEvent.GetAssetTask(Asset); //Find the correct task for the subsystem
     _newState = proposedEvent.State;
     IsEvaluated = true;
     return true;
 }
Пример #2
0
        public override bool CanPerform(Event proposedEvent,  Universe environment)
        {
            if (IsEvaluated)
                return true;

            // Check all dependent subsystems
            foreach (var sub in DependentSubsystems)
            {
                if (!sub.IsEvaluated)
                    if (sub.CanPerform(proposedEvent, environment) == false)
                        return false;
            }

            _task = proposedEvent.GetAssetTask(Asset); //Find the correct task for the subsystem
            _newState = proposedEvent.State;
            IsEvaluated = true;

            // Call the can perform method that is in the python class
            dynamic perform = _pythonInstance.CanPerform(proposedEvent, environment);
            return (bool)perform;
        }