public override bool Display(Verb verb, Actor actor, GameObject target, FrameworkContentElement span) { if (target == verb.self) { return; } if (Check(target) < CheckResult.RESTRICTED) { return; } string actionLabel = verb.displayLabel; if (verb.self.container.GetParent() == target && target.container != null) { actionLabel = verb.displayLabel + " out"; DisplayForPoint(verb, actionLabel, target.container, span); } Physical physical = target as Physical; if (physical != null) { foreach (AttachmentPoint point in physical.GetAttachmentPoints()) { actionLabel = verb.displayLabel + " into " + point.name; DisplayForPoint(verb, actionLabel, point, span); } } return(true); }
public override CheckResult Check(Verb verb, GameObject target) { CheckResult check = CheckResult.INVALID; if (verb.self.container.GetParent() == target && target.container != null && target.container != verb.self.container) { check = target.container.CanAttach(verb.self); if (check >= CheckResult.RESTRICTED) { return(check); } } Physical physical = target as Physical; if (physical != null) { Physical physicalSelf = verb.self as Physical; if (physicalSelf != null && physicalSelf.Contains(physical)) { return(CheckResult.INVALID); } foreach (AttachmentPoint point in physical.GetAttachmentPoints()) { if (point == verb.self.container) { continue; } CheckResult pointCheck = point.CanAttach(verb.self); check = pointCheck > check ? pointCheck : check; if (check >= CheckResult.RESTRICTED) { return(check); } } } return(check); }
public override bool Action(Verb verb, Dictionary <string, object> data) { bool success = false; GameObject target = null; if (data.ContainsKey("target")) { target = data["target"] as GameObject; success = true; } if (!success) { success = false; if (data.ContainsKey("point")) { AttachmentPoint point = data["point"] as AttachmentPoint; if (point != null) { success = Action(verb, point); } } } if (!success) { return(false); } Physical physical = target as Physical; if (physical != null) { success = Action(verb, physical.GetAttachmentPoints()[0]); } return(success); }