コード例 #1
0
        private static Thing MakeThingSimple(TSP pair)
        {
            ThingWithComps thing       = new ThingWithComps();
            CompQuality    compQuality = new CompQuality
            {
                parent = thing
            };

            Traverse.Create(thing).Field("comps").SetValue(new List <ThingComp>()).Method("Add", compQuality).GetValue();
            Trace.WriteLine(thing.AllComps.Count);
            thing.def = pair.thing;
            thing.SetStuffDirect(pair.stuff);
            if (thing.TryGetComp <CompQuality>() == null)
            {
                Trace.WriteLine(thing.AllComps[0].GetType());
                Trace.WriteLine(thing.AllComps[0] as CompQuality == null ? "null" : "no");
                Trace.WriteLine(typeof(CompQuality));
                Trace.WriteLine("quality is null");
            }
            thing.TryGetComp <CompQuality>().SetQuality(pair.Quality, ArtGenerationContext.Outsider);
            return(thing);
        }