Beispiel #1
0
        static void Inject()
        {
            var defs = DefDatabase <ThingDef> .AllDefs.Where(InjectPredicate).ToList();

            var tabType        = typeof(ITab_Infused);
            var tab            = InspectTabManager.GetSharedInstance(tabType);
            var compProperties = new Verse.CompProperties {
                compClass = typeof(CompInfused)
            };

            foreach (var def in defs)
            {
                def.comps.Add(compProperties);
                #if DEBUG
                Log.Message("Infused :: Component added to " + def.label);
                #endif

                if (def.inspectorTabs == null || def.inspectorTabs.Count == 0)
                {
                    def.inspectorTabs         = new List <Type>();
                    def.inspectorTabsResolved = new List <InspectTabBase>();
                }

                def.inspectorTabs.Add(tabType);
                def.inspectorTabsResolved.Add(tab);
            }
            #if DEBUG
            Log.Message("Infused :: Injected " + defs.Count + "/" + DefDatabase <ThingDef> .AllDefs.Count());
            #endif
        }
Beispiel #2
0
        public override void Initialize(Verse.CompProperties props)
        {
            base.Initialize(props);
            Building_TurretGun turret = parent as Building_TurretGun;

            if (turret != null && turret.gun == null)
            {
                gun        = (Thing)ThingMaker.MakeThing(parent.def.building.turretGunDef);
                turret.gun = gun;
                turret.GunCompEq.verbTracker.InitVerbs();
            }
        }
Beispiel #3
0
        public override void Initialize(Verse.CompProperties props)
        {
            base.Initialize(props);
            // Do 4 things
            //   1.  Create Controller for saving/loading in proper order (do once)
            //   2.  most important: give each compRefuelable from the def a unique id for save/load
            //   3.  make linked list
            //   4.  make sure the fuel has a decent label
            CompRefuelable_Multi crm = this.parent.GetComp <CompRefuelable_Multi>();

            if (crm == this) // "first post!"
            {
                id = 0;
                this.controller = (LWM.Multi_Fuel_Requirement.Controller)Activator.
                                  CreateInstance(typeof(LWM.Multi_Fuel_Requirement.Controller));
                controller.parent = parent;
                controller.Initialize(new PlaceHolder());
                parent.AllComps.Add(controller);
                controller.fuels.Add(this);
            }
            else
            {
                this.controller = crm.controller;
                controller.fuels.Add(this);
                // Build a linked list of the CompRefuelable_Multis this parent has:
                //   This will give us a faster way to check all of the than searching the whole
                //   List<> by way of GetComps<CompRefuelable_Multi>
                int count = 1;
                while (crm.next != null)
                {
                    crm = crm.next;
                    count++;
                }
                crm.next = this;
                id       = count; // unique label for save/load
                // Move the controller to the end of the list: (slightly inefficient, but necessary)
                var c = parent.GetComp <LWM.Multi_Fuel_Requirement.Controller>();
                parent.AllComps.Remove(c);
                parent.AllComps.Add(c);
            }

            // It would be nice to tell the fuels apart:
            //   (we do this here because we can override Initialize.
            //    we can't override for CompProperties_Refuelable?)
            if (this.Props.fuelLabel.NullOrEmpty())
            {
                this.Props.fuelLabel = this.Props.fuelFilter.Summary;
            }
        } // initialize
Beispiel #4
0
        // Searches for haulable items and adds the CompStripChecker
        static void InjectComp()
        {
            var compProperties = new Verse.CompProperties {
                compClass = typeof(CompStripChecker)
            };
            var defs = DefDatabase <ThingDef> .AllDefs.Where(
                def => typeof(ThingWithComps).IsAssignableFrom(def.thingClass) &&
                def.EverHaulable &&
                !def.HasComp(typeof(CompStripChecker))
                );

            foreach (var def in defs)
            {
                def.comps.Add(compProperties);
            }
        }
Beispiel #5
0
 public virtual void Initialize(CompProperties props)
 {
     this.props = props;
 }