コード例 #1
0
 public void AddBehavior(Behavior b)
 {
     if (b == Behavior.NullBehavior) return;
     if (behaviors.ContainsKey(b.Id)) behaviors[b.Id] = b;
     else behaviors.Add(b.Id, b);
     DebugIf("behaviorLoad", "Added behavior '" + b.Id + "': " + b.ToString());
 }
コード例 #2
0
 public BehaviorExecutionContext(Behavior behavior, List<BehaviorNode> nodes) : this(behavior, nodes, new Character()) { }
コード例 #3
0
 public BehaviorExecutionContext(Behavior behavior, List<BehaviorNode> nodes, Character character)
 {
     Behavior = behavior;
     Nodes = nodes;
     Character = character;
 }
コード例 #4
0
        public void PublishEvent(string messageId, string clientId, string eventName, bool dontLogDescription, string[] parameters, string[] types, string[] values, string syncEvent = "")
        {
            ThalamusClientProxy sourceClient = null;
            inboundEventsCounter++;
            if (remoteClients.ContainsKey(clientId)) sourceClient = remoteClients[clientId];

            PML pml = new PML(eventName, parameters, types, values);
            pml.DontLogDescription = dontLogDescription;
            if (sourceClient != null)
            {
                Environment.Instance.DebugIf("messages", "[T][" + sourceClient.Name + "]Publishing... " + pml.ToString() + ".");
            }
            else
            {
                Environment.Instance.DebugIf("messages", "[T][Unknown]Publishing... " + pml.ToString() + ".");
            }
            Environment.Instance.LogEvent(false, character, sourceClient, pml);

            if (syncEvent != "")
            {
                Behavior b = new Behavior();
                b.AddNode(new Actions.SyncAction(new Actions.SyncPoint(eventName), sourceClient, pml));
                BehaviorPlan.Instance.Add(b);
            }
            else
            {
                Character.SendPerception(pml);
                BroadcastEvent(messageId, sourceClient, eventName, parameters, types, values, pml);
            }
        }
コード例 #5
0
		public float SolveSyncPoint(SyncPoint syncPoint, Behavior localBehavior) {
			if (syncPoint.Type==SyncPointType.Absolute) return syncPoint.AbsoluteValue;
			else {
				Behavior b = null;
				string[] references = syncPoint.ReferenceValue.Split(':');
				if (references.Length==3) {
					if (BehaviorManager.Instance.Behaviors.ContainsKey(references[0])) b = BehaviorManager.Instance.Behaviors[references[0]];
                }
                else if (references.Length == 2 && localBehavior != null)
                {
					b = localBehavior;
				}
				if (b!=null) {
					BehaviorNodes.Action a = b.GetActionById(references[1]);
					if(a!=null) {
						SyncPoint sp = a.GetEvent(references[2]);
						if (sp.Type==SyncPointType.Absolute) return sp.AbsoluteValue;
						else {
							//can support here recursive solving
							return -1;
						}
					}else{
						return -1;
					}
				}else{
					return -1;
				}
			}
		}
コード例 #6
0
        private void ReplaceBehavior(Behavior behavior, Character character)
        {
			DebugIf("all", "ReplaceBehavior '" + behavior.Id + "' on character '" + character.ToString() + "'");
            CancelCurrentPlan();
            List<BehaviorNode> nodes = SolveConstraints(behavior.Nodes);
            if (character != null) ScheduleBehavior(new BehaviorExecutionContext(behavior, nodes, character));
            else ScheduleBehavior(new BehaviorExecutionContext(behavior, nodes));
        }
コード例 #7
0
 public void Add(Behavior behavior, Character character)
 {
     switch (behavior.Composition)
     {
         case Behavior.CompositionType.Append:
             AppendBehavior(behavior, character);
             break;
         case Behavior.CompositionType.Merge:
             MergeBehavior(behavior, character);
             break;
         case Behavior.CompositionType.Replace:
             ReplaceBehavior(behavior, character);
             break;
     }
 }
コード例 #8
0
        public void Add(Behavior behavior)
        {
            if (!BehaviorManager.Instance.Behaviors.ContainsValue(behavior)) BehaviorManager.Instance.AddBehavior(behavior);

            if (defaultCharacter != null && behavior.Character==null) Add(behavior, defaultCharacter);
            else Add(behavior, behavior.Character);
        }