Beispiel #1
0
 static void Prefix(CompRefuelable __instance, ref Thing fuelThing)
 {
     if (BlackFuelUtil.IsCarbonThing(fuelThing))
     {
         fuelThing.stackCount *= 3;
     }
 }
Beispiel #2
0
 static void Postfix(WorkGiver_Refuel __instance, ref Job __result)
 {
     if (BlackFuelUtil.IsCarbonThing(__result.targetB.Thing))
     {
         __result.count /= 3;
     }
 }
Beispiel #3
0
        public override void CompTick()
        {
            base.CompTick();
            ticker++;
            if (ticker >= Props.scuttlePollInTicks)
            {
                ticker = 0;

                if (compRefuelable == null)
                {
                    compRefuelable = parent.TryGetComp <CompRefuelable>();
                }

                if (compRefuelable == null || !BlackFuelUtil.CarbonThingsExist || compRefuelable.IsFull)
                {
                    return;
                }
                if (parent.IsForbidden(parent.Faction))
                {
                    return;
                }

                CompFlickable compFlickable = parent.GetComp <CompFlickable>();
                if (compFlickable != null && !compFlickable.SwitchIsOn)
                {
                    return;
                }

                if (!compRefuelable.ShouldAutoRefuelNow)
                {
                    return;
                }

                Thing fuelThing = FindFuelInAnyScuttle();
                if (fuelThing != null)
                {
                    // should I check if the item is forbidden first? Core hopper logic doesn't seem to...
                    int fuelNeeded     = compRefuelable.GetFuelCountToFullyRefuel();
                    int fuelThingValue = fuelThing.stackCount;

                    if (BlackFuelUtil.IsCarbonThing(fuelThing))
                    {
                        fuelNeeded     /= 3;
                        fuelThingValue *= 3;
                    }

                    if (fuelThingValue <= fuelNeeded)
                    {
                        compRefuelable.Refuel(fuelThingValue);
                        fuelThing.Destroy();
                    }
                    else
                    {
                        compRefuelable.Refuel(fuelThingValue);
                        fuelThing.stackCount -= fuelNeeded;
                    }
                }
            }
        }