コード例 #1
0
			public ActionEvent(BehaviorNodes.Action action, ActionEventType type, BehaviorExecutionContext bec) {
				this.Type = type;
				this.Action = action;
                this.BEC = bec;
			}
コード例 #2
0
		public void TerminateBehavior(BehaviorExecutionContext bec) {
			RunningBehaviors.Remove(bec);
			int total = bec.Nodes.Count;
			int remaining = bec.RemainingNodes.Count;
			DebugIf("all", "Terminated behavior '" + bec.Behavior.Id + "': " + (total-remaining) + " of " + total + "nodes executed.");
		}
コード例 #3
0
        private void ScheduleBehavior(BehaviorExecutionContext context)
        {
            DebugIf("behaviorSchedule", "ScheduleBehavior '" + context.ToString() + "'");
			try {
				scheduler.WaitOne();
	            foreach (BehaviorNode node in context.Nodes)
	            {
	                if (node is BehaviorNodes.Required)
	                {
	                    if ((node as BehaviorNodes.Required).IsValid())
	                    {
	                        foreach (BehaviorNodes.Action a in (node as BehaviorNodes.Required).Actions)
	                        {
	                            a.RequiredAction = true;
	                            a.ParentNode = node;
	                            ScheduleAction(a, context);
	                        }
	                    }
	                }
	                else
	                {
	                    (node as BehaviorNodes.Action).RequiredAction = false;
	                    ScheduleAction((node as BehaviorNodes.Action), context);
	                }
	            }
				scheduler.ReleaseMutex();
				RunningBehaviors.Add(context);
			}catch(Exception e){
				DebugIf("error", "Failed to schedule behavior '" + context.Behavior.Id + "' on character '" + context.Character.Name + "': " + e.Message);
			}
        }
コード例 #4
0
        private void ScheduleAction(BehaviorNodes.Action a, BehaviorExecutionContext bec)
        {
            if (a.StartTime.Type == SyncPointType.Unspecified)
            {
                a.Event(ActionEventType.start, bec);
                RunningActions.Add(a);
            }
            else
            {
                if (a.StartTime.Type == SyncPointType.Absolute) AddTimeline(a.StartTime.AbsoluteValue * Properties.Settings.Default.PlanFPS + currentFrame, new ActionEvent(a, ActionEventType.start, bec));
                else if (a.StartTime.Type == SyncPointType.Reference) AddEventline(a.StartTime.ReferenceValue, new ActionEvent(a, ActionEventType.start, bec));

                if (a.EndTime.Type == SyncPointType.Absolute) AddTimeline(a.EndTime.AbsoluteValue * Properties.Settings.Default.PlanFPS + currentFrame, new ActionEvent(a, ActionEventType.end, bec));
                else if (a.EndTime.Type == SyncPointType.Reference) AddEventline(a.EndTime.ReferenceValue, new ActionEvent(a, ActionEventType.end, bec));
            }
        }