// public override void OnDropObjects(UnityEngine.Object[] objects) { var drag = UnityEditor.DragAndDrop.objectReferences[0]; Debug.Log(drag.GetType().ToString()); if (drag is MAction) { Debug.Log("drag is MAction"); a = drag as MAction; draggedType = drag.GetType(); dragAcceptPending = true; } if (drag is MGoal) { Debug.Log("drag is goal"); g = drag as MGoal; draggedType = drag.GetType(); dragAcceptPending = true; } if (drag is MNorm) { Debug.Log("drag is norm"); n = drag as MNorm; draggedType = drag.GetType(); dragAcceptPending = true; } Vector2 pos = NodeEditorWindow.current.WindowToGridPosition(Event.current.mousePosition); // dragged = objects; }
public virtual void init(BaseAgentBehavior owner) { this.owner = owner; cachedContext.Clear(); foreach (mEntity ent in context) { cachedContext.Add(ECUtils.getMatchingEntity(ent, owner.entities)); } if (targetAction != null) { cachedTargetAction = owner.actions.getAction(targetAction); } if (targetGoal != null) { cachedTargetGoal = owner.goals.getGoal(targetGoal); } }
public override void init(BaseAgentBehavior owner) { //cache required info from owner //these are reference types because this is not an independent object //it needs to reason on data from the owner and return a decision to it this.owner = owner; entities.Clear(); foreach (mEntity e in owner.entities) { entities.Add(e); } goals = owner.goals; foreach (MGoal g in goals) { // qGoals.Enqueue(g); } actions = owner.actions; //find the actual actions and goals from the owner and replace the template refplan = new Plan(); plan = ((GoalReasoner)owner.reasonerTemplate).plan; foreach (KeyValuePair <MGoal, List <MAction> > entry in plan.plan) { MGoal key = goals.getGoal(entry.Key); List <MAction> value = new List <MAction>(); foreach (MAction a in entry.Value) { value.Add(actions.getAction(a)); } // KeyValuePair<MGoal, List<MAction>> newEntry = new KeyValuePair<MGoal, List<MAction>>(key, value); refplan.plan.Add(key, value); } }
void accedpDraggedGoal(Type type, MGoal goal) { if (dragAcceptPending) { if (Event.current.type == EventType.Repaint) { Convert.ChangeType(goal, type); Vector2 pos = NodeEditorWindow.current.WindowToGridPosition(Event.current.mousePosition); GoalNode node = CreateNode(typeof(GoalNode), pos) as GoalNode; node.sourceGoal = goal; node.goalType = type; node.filter = node.populateFilter(node.filter, goal.filter, PortOrientation.In); Debug.Log("Dragged goal"); dragAcceptPending = false; g = null; draggedType = null; } } }
public override float distanceToGoal(BaseAgentBehavior owner, MGoal goal) { return(goal.distance(owner, this)); }
public override float distanceToGoal(BaseAgentBehavior owner, MGoal goal) { throw new System.NotImplementedException(); }
public abstract float distanceToGoal(BaseAgentBehavior owner, MGoal goal);
public override void setActiveGoal() { if (activeGoal == null) { if (qGoals.Count == 0) { if (continuous) { foreach (MGoal g in goals) { { qGoals.Enqueue(g); } } } else { if (log != "") { Debug.Log(log); log = ""; } } /* * if(qGoals.Count == 0) * { * Debug.Log("Now actionable goal found. Reconsidering all goals for next reasoning cycle"); * foreach(MGoal g in goals) * { * qGoals.Enqueue(g); * } * } */ } else { if (qGoals.Count >= 1) { MGoal g = qGoals.Peek(); if (g.distance(owner) >= 0) { if (refplan.plan[g][0].isDoable(owner)) { //this is where we check for norm compliance for norms that target goals activeGoal = g; log += "Set active goal " + g.ToString() + "; "; } else { Debug.Log("Droping goal " + g + ". Plan not feasible. Moved to back of queue "); log += "Droping goal " + g.ToString() + " . Plan not feasible. Moved to back of queue; "; qGoals.Dequeue(); qGoals.Enqueue(g); } } else { Debug.Log("Goal " + g.ToString() + " is fulfiled. Moving to end of queue"); qGoals.Dequeue(); // qGoals.Enqueue(g); } } } } }