public override void Unswizzle(IList <EventNode> nodes) { if (NextIfFalse is DummyEventNode dummy) { if (dummy.Id >= nodes.Count) { ApiUtil.Assert($"Invalid event id: {Id} links to {dummy.Id} when false, but the set only contains {nodes.Count} events"); NextIfFalse = null; } else { NextIfFalse = nodes[dummy.Id]; } } base.Unswizzle(nodes); }
EventDefSettingsCommand(IEventNode eventNode, EventDefOptions options) { this.eventNode = eventNode; this.newOptions = options; this.origOptions = new EventDefOptions(eventNode.EventDef); this.origParentNode = (IFileTreeNodeData)eventNode.TreeNode.Parent.Data; this.origParentChildIndex = this.origParentNode.TreeNode.Children.IndexOf(eventNode.TreeNode); Debug.Assert(this.origParentChildIndex >= 0); if (this.origParentChildIndex < 0) { throw new InvalidOperationException(); } this.nameChanged = origOptions.Name != newOptions.Name; }
public virtual void Unswizzle(IList <EventNode> nodes) { if (!(Next is DummyEventNode dummy)) { return; } if (dummy.Id >= nodes.Count) { ApiUtil.Assert($"Invalid event id: {Id} links to {dummy.Id}, but the set only contains {nodes.Count} events"); Next = null; } else { Next = nodes[dummy.Id]; } }
public void FormatChain(StringBuilder sb, IEventNode firstEvent, int indent = 0) { if (sb == null) { throw new ArgumentNullException(nameof(sb)); } if (firstEvent == null) { return; } var uniqueEvents = ExploreGraph(firstEvent); var sorted = uniqueEvents.OrderBy(x => x.Id).ToList(); foreach (var e in sorted) { sb.Append(new string(' ', 4 * indent)); sb.AppendLine(Format(e, sorted[0].Id)); } }
public ControlFlowGraph(IEventNode node) { var entryNode = new EventNode(-1, null) { NextEvent = node }; var terminalNode = new EventNode(-2, null); //var leaders = new HashSet<IEventNode> { entryNode, node, terminalNode }; // Entry and exit nodes are always leaders //FindLeaders(entryNode, leaders, terminalNode); BuildBlocks(entryNode, terminalNode);//, leaders); LinkBlocks(); Start = Blocks[entryNode]; if (!Blocks.ContainsKey(terminalNode)) { throw new InvalidOperationException("Invalid procedure: never exits"); } End = Blocks[terminalNode]; CombineBlocks(); }
public virtual void Unswizzle(IList <EventNode> nodes) { if (nodes == null) { throw new ArgumentNullException(nameof(nodes)); } if (Next is not DummyEventNode dummy) { return; } if (dummy.Id >= nodes.Count) { ApiUtil.Assert($"Invalid event id: {Id} links to {dummy.Id}, but the set only contains {nodes.Count} events"); Next = null; } else { Next = nodes[dummy.Id]; } }
public void Unswizzle(MapId mapId, Func <ushort, IEventNode> getEvent, Func <ushort, ushort> getChain) { if (getEvent == null) { throw new ArgumentNullException(nameof(getEvent)); } if (getChain == null) { throw new ArgumentNullException(nameof(getChain)); } ChainSource = mapId; if (Node is DummyEventNode dummy) { Node = getEvent(dummy.Id); } if (Node != null) { Chain = getChain(Node.Id); } }
static void PrintChain(StreamWriter sw, EventFormatter formatter, IEventNode e, int indent) { do { sw.Write($"{e.Id:000}"); sw.Write("".PadRight(indent * 4)); if (e is IBranchNode branch) { sw.WriteLine($"if (!{formatter.GetText(e)}) {{"); if (branch.NextIfFalse != null) { PrintChain(sw, formatter, branch.NextIfFalse, indent + 1); } sw.WriteLine("}".PadLeft(4 + indent * 4)); sw.WriteLine("else...".PadLeft(10 + indent * 4)); } else { sw.WriteLine(formatter.GetText(e)); } e = e.Next; } while (e != null); }
static void PrintChain(EventFormatter formatter, IEventNode e, int indent) { do { Console.Write($"{e.Id:000}"); Console.Write("".PadRight(indent * 4)); if (e is IBranchNode branch) { Console.WriteLine($"if (!{formatter.GetText(e)}) {{"); if (branch.NextEventWhenFalse != null) { PrintChain(formatter, branch.NextEventWhenFalse, indent + 1); } Console.WriteLine("}".PadLeft(4 + indent * 4)); Console.WriteLine("else...".PadLeft(10 + indent * 4)); } else { Console.WriteLine(formatter.GetText(e)); } e = e.NextEvent; } while (e != null); }
public void FormatChainDecompiled(StringBuilder sb, IEventNode firstEvent, IList <IEventNode> additionalEntryPoints, int indent) { var events = ExploreGraph(firstEvent); events.Remove(firstEvent); var sorted = new List <IEventNode> { firstEvent }; sorted.AddRange(events); List <(string, ControlFlowGraph)> steps = new(); try { var tree = Decompiler.Decompile(sorted, steps); var inner = new StringBuilder(); tree.ToPseudocode(inner, true, false); ScriptUtil.PrettyPrintScript(sb, inner.ToString(), indent); } catch (ControlFlowGraphException) { FormatChain(sb, firstEvent, indent); // Fallback to raw view } }
CreateEventDefCommand(ITypeNode ownerNode, EventDefOptions options) { this.ownerNode = ownerNode; this.eventNode = ownerNode.Create(options.CreateEventDef(ownerNode.TypeDef.Module)); }
DeleteEventDefCommand(IEventNode[] eventNodes) { this.nodes = new DeletableNodes<IEventNode>(eventNodes); }
public void Restore(IEventNode[] nodes) { Debug.Assert(infos != null); if (infos == null) throw new InvalidOperationException(); Debug.Assert(infos.Length == nodes.Length); if (infos.Length != nodes.Length) throw new InvalidOperationException(); for (int i = infos.Length - 1; i >= 0; i--) { var node = nodes[i]; var info = infos[i]; info.OwnerType.Events.Insert(info.EventIndex, node.EventDef); for (int j = info.Methods.Length - 1; j >= 0; j--) info.OwnerType.Methods.Insert(info.MethodIndexes[j], info.Methods[j]); } infos = null; }
public override void OnEventReceiver(IEventNode @event) { }
public EvntInfo GetEvent(IEventNode ev) { return (EvntInfo)defs[ev]; }
public EventNodeCreator(IModuleDocumentNode modNode, ITypeNode ownerNode, EventDef @event) { this.ownerNode = ownerNode; this.eventNode = modNode.Context.DocumentTreeView.Create(@event); }
public override void OnEventReceiver(IEventNode @event) { var lst = (@event as RoleEventNode).Data; Debug.Log($"{lst[0]} {lst[1]}"); }
public void Add(IEventNode node) { Nodes.Add(node); }
public void visit(IEventNode value) { }
/// <summary> /// 负责接收外部传来的事件内容 /// </summary> /// <param name="node">事件节点</param> public void OnEventReceiver(IEventNode @event) { OnEventDispatch(@event); }
public void visit(IEventNode value) { throw new System.NotSupportedException(value.GetType().ToString()); }
EventDefSettingsCommand(IEventNode eventNode, EventDefOptions options) { this.eventNode = eventNode; this.newOptions = options; this.origOptions = new EventDefOptions(eventNode.EventDef); this.origParentNode = (IFileTreeNodeData)eventNode.TreeNode.Parent.Data; this.origParentChildIndex = this.origParentNode.TreeNode.Children.IndexOf(eventNode.TreeNode); Debug.Assert(this.origParentChildIndex >= 0); if (this.origParentChildIndex < 0) throw new InvalidOperationException(); this.nameChanged = origOptions.Name != newOptions.Name; }
/// <summary> /// 负责接收外部传来的事件内容 /// </summary> /// <param name="node">事件节点</param> public void OnEventReceiver(RoleNumber number, IEventNode @event) { OnEventDispatch(number, @event); }
public TriggerChainEvent(EventChain chain, IEventNode node, NpcCharacterId npcId) : this(chain, node, new EventSource.Npc(npcId)) { }
public TriggerChainEvent(EventChain chain, IEventNode node, EventSource source) { Chain = chain ?? throw new ArgumentNullException(nameof(chain)); Node = node ?? throw new ArgumentNullException(nameof(node)); Source = source ?? throw new ArgumentNullException(nameof(source)); }
public TriggerChainEvent(EventChain chain, IEventNode node, EventSetId eventSetId) : this(chain, node, new EventSource.EventSet(eventSetId)) { }
public EvntInfo AddEvent(IEventNode ev, EventBuilder eb) { EvntInfo ei = new EvntInfo(eb); defs[ev] = ei; return ei; }
public void Delete(IEventNode[] nodes) { Debug.Assert(infos == null); if (infos != null) throw new InvalidOperationException(); infos = new ModelInfo[nodes.Length]; for (int i = 0; i < infos.Length; i++) { var node = nodes[i]; var info = new ModelInfo(node.EventDef); infos[i] = info; info.OwnerType.Events.RemoveAt(info.EventIndex); for (int j = 0; j < info.Methods.Length; j++) { int index = info.OwnerType.Methods.IndexOf(info.Methods[j]); Debug.Assert(index >= 0); if (index < 0) throw new InvalidOperationException(); info.OwnerType.Methods.RemoveAt(index); info.MethodIndexes[j] = index; } } }
public virtual void OnEventReceiver(IEventNode @event) { }
public virtual void visit(IEventNode value) { }
public virtual void OnEventDispatch(IEventNode @event) { }
public EvntInfo GetEvent(IEventNode ev) { return((EvntInfo)defs[ev]); }
public TriggerChainEvent(EventChain chain, IEventNode node, TriggerType trigger, MapDataId mapId, int x, int y) : this(chain, node, new EventSource.Map(mapId, trigger, x, y)) { }