public void RegisterTrigger(ScriptObject node) { if (node.Children.Count > 0) { var idNodes = node.Children.Where(a => a.Name == "id"); var dayNodes = node.Children.Where(a => a.Name == "days"); var onActionNodes = node.Children.Where(a => a.Name == "on_action"); var n = new trigger_event(); if (dayNodes.Any()) { var val = dayNodes.First().GetStringValue(); if (val == null) { var c = dayNodes.First().Children; n.days_from = c[0].Name; n.days_to = c[1].Name; } else { n.days_from = val; n.days_to = val; } } string on_action = null; string id = null; if (idNodes.Any()) { id = idNodes.First().GetStringValue(); } if (onActionNodes.Any()) { on_action = onActionNodes.First().GetStringValue(); } n.on_action = on_action; n.Topmost = node.Topmost; n.Function = node; n.id = id; ReferenceManager.Instance.AddConnection(n.Topmost, n.Function, on_action != null ? on_action : id); } else { var n = new trigger_event(); n.Topmost = node.Topmost; n.Function = node; n.days_from = null; n.days_to = null; n.id = node.GetStringValue(); ReferenceManager.Instance.AddConnection(n.Topmost, n.Function, node.GetStringValue()); } }
public void Add(ScriptObject obj) { if (obj.Name != null && commandsValuesToExtract.Contains(obj.Name)) { toExport.Add(obj.GetStringValue()); } if (obj.Name != null && childExtractor.ContainsKey(obj.Name)) { toExport.Add(obj.GetChildStringValue(childExtractor[obj.Name])); } }
public void ProcessObject(BinaryWriter writer, BinaryReader reader, ScriptObject obj) { if (obj.Name == "root") { obj.SetScopeType(obj.Topmost.GetScopeType()); } BreakpointLine = 30; BreakpointFile = "events/kill_them_all_events/kill_them_all_events.txt"; if (obj.Filename.ToRelativeFilename().Contains(BreakpointFile)) { } if (obj.LineStart == BreakpointLine && obj.Filename.ToRelativeFilename().Contains(BreakpointFile)) { } var data = new ScriptObjectBehaviourData(); data.ScriptObject = obj; data.ScopeType = obj.GetScopeType(); if (obj.Parent != null) { data.ParentData = obj.Parent.BehaviourData; } obj.BehaviourData = data; data.lhs = obj.Name; if (obj.Parent != null) { data.ParentData = obj.Parent.BehaviourData; } if (data.lhs == "set_variable") { VariableStore.Instance.CompleteScopedVar(obj, data, obj.Parent.GetScopeType()); } data.rhs = obj.GetStringValue(); data.IsBlock = obj.IsBlock; if (reader == null) { DetermineBehaviourScope(obj, data); } else { ReadBehaviour(reader, obj); } if (data.lhs.Contains("var:")) { if (!VariableStore.Instance.HasScopedVariableComplete(data.lhs, obj.GetScopeType()) && obj.DeferedCount < 1) { obj.DeferedCount++; Core.Instance.BehaviourRecalculateList.Add(obj); } } if (data.rhs != null && data.rhs.Contains("var:")) { if (!VariableStore.Instance.HasScopedVariableComplete(data.rhs.Substring(data.rhs.IndexOf("var:")), data.deepestRHSScopeFound) && obj.DeferedCount < 1) { obj.DeferedCount++; Core.Instance.BehaviourRecalculateList.Add(obj); } } if (writer != null) { WriteBehaviour(writer, obj); } foreach (var scriptObject in obj.Children) { scriptObject.PostInitialize(writer, reader); } }