Act(Person s, Verb v, Noun o1, Noun o2, Act c, System.Action<Act> R) : this() { //Debug.Assert(Arity(v) == 2 || o2, v.ToString() + " is a ternary verb."); subject = s; verb = v; primaryObject = o1; secondaryObject = o2; parent = c; Register = R; args = new VerbArguments(this); Register(this); }
public NPC(int x, int y, Act.Controller ac) : base(x, y, ac) { spritePath = "dc_caveman"; name = "weird caveman"; var hungry = actController.FirstCause(this, Verb.NEED, Noun.FOOD); actController.Confirm(hungry); memory.Add(hungry); }
public void Confirm(Act hasHappened) { Debug.Assert(Allocated.Contains(hasHappened)); Debug.Assert(!hasHappened.parent || History.Contains(hasHappened.parent)); if (hasHappened.Happened) return; Debug.Assert(TalkedAbout.Contains(hasHappened)); hasHappened.TimeStamp = nextTimeStamp++; hasHappened.Happened = true; // Past now finds the current Act, Present doesn't. dependencies[hasHappened] = NO_ACT; // Present now finds the consequent Act, Future doesn't. }
public VerbArguments(Act client) { this.client = client; }
public bool Descendant(Act rootCause) { Debug.Assert(this != rootCause, "not how the algorithm was intended to work."); if (parent == rootCause) return true; return parent ? parent.Descendant(rootCause) : false; }
protected void Enlist(Person other, Act need) { Listener = other; Debug.Assert(need.verb == Verb.NEED); var gimme = need.Cause(this, Verb.ASK_FOR, other, need.args.What); Commit(gimme); }
protected void Commit(Act what) { Debug.Assert(what); memory.Add(what); actController.Confirm(what); ShowLastSentence(what); }
Act Babble(Act ignoredContext) { if (!ignoredContext) return Babble(); return ignoredContext.Cause(this, Verb.TALK, Listener, this); }
protected void Query(Person other, Noun about, Act because) { Listener = other; Commit(because.Cause(this, Verb.ASK_WHY, other, about)); }
/// <summary> preCondition.Happened => NO_ACT </summary> public Act Consequence(Act preCondition) { return dependencies[preCondition]; }
void Register(Act what) { dependencies[what] = NO_ACT; var parent = what.parent; if (parent && !parent.Happened) dependencies[parent] = what; acters.Add(what.subject); if (what.secondaryObject is Person) acters.Add(what.secondaryObject as Person); }
public static Query Make(Person from, Person to, Act about) { throw new Exception(); //return new Query(about.Cause(from, Verb.TALK, to)); }