public void InitializeComps() { if (base.def.comps.Any()) { this.comps = new List <ThingComp>(); for (int i = 0; i < base.def.comps.Count; i++) { ThingComp thingComp = (ThingComp)Activator.CreateInstance(base.def.comps[i].compClass); thingComp.parent = this; this.comps.Add(thingComp); thingComp.Initialize(base.def.comps[i]); } } }
public void InitializeComps() { if (def.comps.Any()) { comps = new List <ThingComp>(); for (int i = 0; i < def.comps.Count; i++) { ThingComp thingComp = null; try { thingComp = (ThingComp)Activator.CreateInstance(def.comps[i].compClass); thingComp.parent = this; comps.Add(thingComp); thingComp.Initialize(def.comps[i]); } catch (Exception arg) { Log.Error("Could not instantiate or initialize a ThingComp: " + arg); comps.Remove(thingComp); } } } }