コード例 #1
0
        private void RegisterAllComponentsOf(ThingWithComps parentThing)
        {
            CompShieldTrader comp = parentThing.GetComp <CompShieldTrader>();

            if (comp != null)
            {
                if (this.powerComps.Contains(comp))
                {
                    Log.Error("PowerNet adding powerComp " + comp + " which it already has.");
                }
                else
                {
                    this.powerComps.Add(comp);
                }
            }
            CompShieldBattery comp2 = parentThing.GetComp <CompShieldBattery>();

            if (comp2 != null)
            {
                if (this.batteryComps.Contains(comp2))
                {
                    Log.Error("PowerNet adding batteryComp " + comp2 + " which it already has.");
                }
                else
                {
                    this.batteryComps.Add(comp2);
                }
            }
        }
コード例 #2
0
        private void DeregisterAllComponentsOf(ThingWithComps parentThing)
        {
            CompShieldTrader comp = parentThing.GetComp <CompShieldTrader>();

            if (comp != null)
            {
                this.powerComps.Remove(comp);
            }
            CompShieldBattery comp2 = parentThing.GetComp <CompShieldBattery>();

            if (comp2 != null)
            {
                this.batteryComps.Remove(comp2);
            }
        }