public static GameObject[] ResolveTargets(GameObject source, IEnumerable<string> TargetIds, GameObjectCollection parent, GameConsole console, bool DeepProcess) { // If it passed, find all targets and activate them List<GameObject> foundTargets = new List<GameObject>(5); foreach (var item in parent) { if (item.Value != source && TargetIds.Contains(item.Value.GetSetting("id"))) foundTargets.Add(item.Value); } // Process all known collections if (DeepProcess) { for (int i = 0; i < console.LayeredTextSurface.LayerCount; i++) { var objects = console.GetObjectCollection(i); if (objects != parent) { foreach (var item in objects) { if (item.Value != source && TargetIds.Contains(item.Value.GetSetting("id"))) foundTargets.Add(item.Value); } } } } return foundTargets.ToArray(); }
public void Triggered(GameObject source, GameConsole console) { GameObjectCollection parent = null; Parent.TryGetTarget(out parent); ResolvedTargets = GameObjectParser.ResolveTargets(this, TargetIds, parent, console, DeepProcess); for (int i = 0; i < ResolvedTargets.Length; i++) { if (ResolvedTargets[i] is ITarget) ((ITarget)ResolvedTargets[i]).Triggered(this, console); } }
public void CopyTo(GameObject destination) { destination.Name = Name; destination.Character = Character.Clone(); destination.Settings = new List<Setting>(Settings.Count); destination.Position = Position; foreach (var item in Settings) { destination.Settings.Add(new Setting() { Name = item.Name, Value = item.Value }); } }
public static GameObject Parse(GameObject source) { string name = source.Name.ToLower(); if (Conversions.ContainsKey(name)) { var type = Conversions[name]; return System.Activator.CreateInstance(type, source) as GameObject; } return source; }
public GameObject Clone() { var newObject = new GameObject(); newObject.Name = Name; newObject.Character = Character.Clone(); newObject.Settings = new List<Setting>(Settings.Count); newObject.Position = Position; foreach (var item in Settings) { newObject.Settings.Add(new Setting() { Name = item.Name, Value = item.Value }); } return newObject; }
public Action(GameObject source) { Id = ""; Script = ""; StringBuilder targets = new StringBuilder(); foreach (var setting in source.Settings) { string name = setting.Name.ToLower().Trim(); if (name == "id") Id = setting.Value; else if (name == "script") Script = setting.Value; } source.CopyTo(this); }
public Trigger(GameObject source) { Id = ""; StringBuilder targets = new StringBuilder(); foreach (var setting in source.Settings) { string name = setting.Name.ToLower().Trim(); if (name == "target") targets.Append(String.Format("{0};", setting.Value)); else if (name == "type") Type = setting.Value; } TargetNames = targets.ToString().Trim(';').Trim().Split(';'); source.CopyTo(this); }
public virtual void Triggered(GameObject source, GameObjectTextSurface ) { // Check for condition pass if (Condition(this, console)) { GameObjectCollection parent = null; Parent.TryGetTarget(out parent); ResolvedTargets = GameObjectParser.ResolveTargets(this, TargetIds, parent, console, DeepProcess); //Result(this, parent, console); for (int i = 0; i < ResolvedTargets.Length; i++) { if (ResolvedTargets[i] is ITarget) ((ITarget)ResolvedTargets[i]).Triggered(this, console); } } }
public Processor(GameObject source) { Id = ""; StringBuilder targets = new StringBuilder(); foreach (var setting in source.Settings) { string name = setting.Name.ToLower().Trim(); if (name == "id") Id = setting.Value; else if (name == "target") targets.Append(string.Format("{0};", setting.Value)); else if (name == "deep") DeepProcess = string.IsNullOrWhiteSpace(setting.Value) ? false : setting.Value.ToBool(); } TargetIds = targets.ToString().Trim(';').Trim().Split(';'); source.CopyTo(this); }
public void Triggered(GameObject source, GameConsole console) { System.Diagnostics.Debugger.Break(); }