public _ Init(string objType, State rootState, params ILootDef[] defs) { rootState.Resolve(new Dictionary<string, State>()); if (defs.Length > 0) { var loot = new Loot(); foreach (var i in defs) i.Populate(loot, loot); rootState.Death += (sender, e) => loot.Handle((Enemy)e.Host, e.Time); Definitions.Add(XmlDatas.IdToType[objType], new Tuple<State, Loot>(rootState, loot)); } else Definitions.Add(XmlDatas.IdToType[objType], new Tuple<State, Loot>(rootState, null)); return this; }
public ctor Init(string objType, State rootState, params ILootDef[] defs) { var d = new Dictionary<string, State>(); rootState.Resolve(d); rootState.ResolveChildren(d); var dat = InitDb.Manager.GameData; if (defs.Length > 0) { var loot = new Loot(defs); rootState.Death += (sender, e) => loot.Handle((Enemy)e.Host, e.Time); InitDb.Definitions.Add(dat.IdToObjectType[objType], new Tuple<State, Loot>(rootState, loot)); } else InitDb.Definitions.Add(dat.IdToObjectType[objType], new Tuple<State, Loot>(rootState, null)); return this; }
private static State _CommonParent(State current, State a, State b) { if (b.Is(current)) return current; if (a.Parent == null) return null; return _CommonParent(current.Parent, a, b); }
//child is parent //parent is not child public bool Is(State state) { if (this == state) return true; if (Parent != null) return Parent.Is(state); return false; }
public static State CommonParent(State a, State b) { if (a == null || b == null) return null; return _CommonParent(a, a, b); }
internal void Resolve(IDictionary<string, State> states) { TargetState = states[targetStateName]; }
//child is parent //parent is not child public bool Is(State state) { if (this == state) return true; else if (this.Parent != null) return this.Parent.Is(state); else return false; }
protected internal virtual void Resolve(State parent) { }