Exemple #1
0
        public static bool CanRefuel(Pawn pawn, Thing t, bool forced = false)
        {
            CompRefuelable compRefuelable = t.TryGetComp <CompRefuelable>();

            if (compRefuelable == null || compRefuelable.IsFull || (!forced && !compRefuelable.allowAutoRefuel))
            {
                return(false);
            }
            if (!forced && !compRefuelable.ShouldAutoRefuelNow)
            {
                return(false);
            }
            if (t.IsForbidden(pawn) || !pawn.CanReserve(t, 1, -1, null, forced))
            {
                return(false);
            }
            if (t.Faction != pawn.Faction)
            {
                return(false);
            }
            if (FindBestFuel(pawn, t) == null)
            {
                ThingFilter fuelFilter = t.TryGetComp <CompRefuelable>().Props.fuelFilter;
                JobFailReason.Is("NoFuelToRefuel".Translate(fuelFilter.Summary));
                return(false);
            }
            if (t.TryGetComp <CompRefuelable>().Props.atomicFueling&& FindAllFuel(pawn, t) == null)
            {
                ThingFilter fuelFilter2 = t.TryGetComp <CompRefuelable>().Props.fuelFilter;
                JobFailReason.Is("NoFuelToRefuel".Translate(fuelFilter2.Summary));
                return(false);
            }
            return(true);
        }
 public override void SpawnSetup(Map map, bool respawningAfterLoad)
 {
     base.SpawnSetup(map, respawningAfterLoad);
     this.powerComp         = base.GetComp <CompPowerTrader>();
     this.refuelableComp    = base.GetComp <CompRefuelable>();
     this.breakdownableComp = base.GetComp <CompBreakdownable>();
 }
Exemple #3
0
        public override Job JobOnThing(Pawn pawn, Thing thing, bool forced = false)
        {
            IBillGiver billGiver = thing as IBillGiver;

            if (billGiver != null && ThingIsUsableBillGiver(thing) && billGiver.BillStack.AnyShouldDoNow && billGiver.UsableForBillsAfterFueling())
            {
                LocalTargetInfo target = thing;
                bool            ignoreOtherReservations = forced;
                if (pawn.CanReserve(target, 1, -1, null, ignoreOtherReservations) && !thing.IsBurning() && !thing.IsForbidden(pawn))
                {
                    CompRefuelable compRefuelable = thing.TryGetComp <CompRefuelable>();
                    if (compRefuelable != null && !compRefuelable.HasFuel)
                    {
                        if (!RefuelWorkGiverUtility.CanRefuel(pawn, thing, forced))
                        {
                            return(null);
                        }
                        return(RefuelWorkGiverUtility.RefuelJob(pawn, thing, forced));
                    }
                    billGiver.BillStack.RemoveIncompletableBills();
                    return(StartOrResumeBillJob(pawn, billGiver));
                }
            }
            return(null);
        }
        private void RenderOutOfFuelOverlay(Thing t)
        {
            CompRefuelable compRefuelable = t.TryGetComp <CompRefuelable>();
            Material       mat            = MaterialPool.MatFrom((compRefuelable == null) ? ThingDefOf.Chemfuel.uiIcon : compRefuelable.Props.FuelIcon, ShaderDatabase.MetaOverlay, Color.white);

            this.RenderPulsingOverlay(t, mat, 5, false);
            this.RenderPulsingOverlay(t, OverlayDrawer.OutOfFuelMat, 6, true);
        }
Exemple #5
0
        private void RenderOutOfFuelOverlay(Thing t)
        {
            CompRefuelable compRefuelable = t.TryGetComp <CompRefuelable>();
            Material       mat            = MaterialPool.MatFrom((compRefuelable != null) ? compRefuelable.Props.FuelIcon : ThingDefOf.Chemfuel.uiIcon, ShaderDatabase.MetaOverlay, Color.white);

            RenderPulsingOverlay(t, mat, 5, incrementOffset: false);
            RenderPulsingOverlay(t, OutOfFuelMat, 6);
        }
Exemple #6
0
        public static bool CanRefuel(Pawn pawn, Thing t, bool forced = false)
        {
            CompRefuelable compRefuelable = t.TryGetComp <CompRefuelable>();
            bool           result;

            if (compRefuelable == null || compRefuelable.IsFull)
            {
                result = false;
            }
            else
            {
                bool flag = !forced;
                if (flag && !compRefuelable.ShouldAutoRefuelNow)
                {
                    result = false;
                }
                else
                {
                    if (!t.IsForbidden(pawn))
                    {
                        LocalTargetInfo target = t;
                        if (pawn.CanReserve(target, 1, -1, null, forced))
                        {
                            if (t.Faction != pawn.Faction)
                            {
                                return(false);
                            }
                            if (RefuelWorkGiverUtility.FindBestFuel(pawn, t) == null)
                            {
                                ThingFilter fuelFilter = t.TryGetComp <CompRefuelable>().Props.fuelFilter;
                                JobFailReason.Is("NoFuelToRefuel".Translate(new object[]
                                {
                                    fuelFilter.Summary
                                }), null);
                                return(false);
                            }
                            if (t.TryGetComp <CompRefuelable>().Props.atomicFueling)
                            {
                                if (RefuelWorkGiverUtility.FindAllFuel(pawn, t) == null)
                                {
                                    ThingFilter fuelFilter2 = t.TryGetComp <CompRefuelable>().Props.fuelFilter;
                                    JobFailReason.Is("NoFuelToRefuel".Translate(new object[]
                                    {
                                        fuelFilter2.Summary
                                    }), null);
                                    return(false);
                                }
                            }
                            return(true);
                        }
                    }
                    result = false;
                }
            }
            return(result);
        }
 public override void PostSpawnSetup(bool respawningAfterLoad)
 {
     base.PostSpawnSetup(respawningAfterLoad);
     this.refuelableComp    = this.parent.GetComp <CompRefuelable>();
     this.breakdownableComp = this.parent.GetComp <CompBreakdownable>();
     if (base.Props.basePowerConsumption < 0f && !this.parent.IsBrokenDown() && FlickUtility.WantsToBeOn(this.parent))
     {
         base.PowerOn = true;
     }
 }
Exemple #8
0
 public override void SpawnSetup(Map map, bool respawningAfterLoad)
 {
     base.SpawnSetup(map, respawningAfterLoad);
     this.powerComp         = base.GetComp <CompPowerTrader>();
     this.refuelableComp    = base.GetComp <CompRefuelable>();
     this.breakdownableComp = base.GetComp <CompBreakdownable>();
     foreach (Bill bill in this.billStack)
     {
         bill.ValidateSettings();
     }
 }
Exemple #9
0
 public override void SpawnSetup(Map map, bool respawningAfterLoad)
 {
     base.SpawnSetup(map, respawningAfterLoad);
     powerComp         = GetComp <CompPowerTrader>();
     refuelableComp    = GetComp <CompRefuelable>();
     breakdownableComp = GetComp <CompBreakdownable>();
     foreach (Bill item in billStack)
     {
         item.ValidateSettings();
     }
 }
Exemple #10
0
        private void RenderForbiddenRefuelOverlay(Thing t)
        {
            CompRefuelable compRefuelable = t.TryGetComp <CompRefuelable>();
            Material       material       = MaterialPool.MatFrom((compRefuelable != null) ? compRefuelable.Props.FuelIcon : ThingDefOf.Chemfuel.uiIcon, ShaderDatabase.MetaOverlayDesaturated, Color.white);
            Vector3        position       = t.TrueCenter();

            position.y = BaseAlt + 3f / 14f;
            Vector3 position2 = new Vector3(position.x, position.y + 3f / 70f, position.z);

            Graphics.DrawMesh(MeshPool.plane08, position, Quaternion.identity, material, 0);
            Graphics.DrawMesh(MeshPool.plane08, position2, Quaternion.identity, ForbiddenMat, 0);
        }
        public override bool HasJobOnThing(Pawn pawn, Thing t, bool forced = false)
        {
            CompRefuelable compRefuelable = t.TryGetComp <CompRefuelable>();

            if (compRefuelable != null && !compRefuelable.IsFull)
            {
                if (!forced && !compRefuelable.ShouldAutoRefuelNow)
                {
                    return(false);
                }
                if (!t.IsForbidden(pawn))
                {
                    LocalTargetInfo target = t;
                    if (!pawn.CanReserve(target, 1, -1, null, forced))
                    {
                        goto IL_005b;
                    }
                    if (t.Faction != pawn.Faction)
                    {
                        return(false);
                    }
                    ThingWithComps thingWithComps = t as ThingWithComps;
                    if (thingWithComps != null)
                    {
                        CompFlickable comp = thingWithComps.GetComp <CompFlickable>();
                        if (comp != null && !comp.SwitchIsOn)
                        {
                            return(false);
                        }
                    }
                    Thing thing = this.FindBestFuel(pawn, t);
                    if (thing == null)
                    {
                        ThingFilter fuelFilter = t.TryGetComp <CompRefuelable>().Props.fuelFilter;
                        JobFailReason.Is("NoFuelToRefuel".Translate(fuelFilter.Summary));
                        return(false);
                    }
                    return(true);
                }
                goto IL_005b;
            }
            return(false);

IL_005b:
            return(false);
        }
        private void RenderOutOfFuelOverlay(Thing t)
        {
            CompRefuelable compRefuelable = t.TryGetComp <CompRefuelable>();
            ThingDef       thingDef;

            if (compRefuelable != null && compRefuelable.Props.fuelFilter.AnyAllowedDef != null)
            {
                thingDef = compRefuelable.Props.fuelFilter.AnyAllowedDef;
            }
            else
            {
                thingDef = ThingDefOf.Chemfuel;
            }
            Material mat = MaterialPool.MatFrom(thingDef.uiIcon, ShaderDatabase.MetaOverlay, Color.white);

            this.RenderPulsingOverlay(t, mat, 5, false);
            this.RenderPulsingOverlay(t, OverlayDrawer.OutOfFuelMat, 6, true);
        }
Exemple #13
0
        public override Job JobOnThing(Pawn pawn, Thing thing, bool forced = false)
        {
            IBillGiver billGiver = thing as IBillGiver;

            if (billGiver == null || !ThingIsUsableBillGiver(thing) || !billGiver.BillStack.AnyShouldDoNow || !billGiver.UsableForBillsAfterFueling() || !pawn.CanReserve(thing, 1, -1, null, forced) || thing.IsBurning() || thing.IsForbidden(pawn))
            {
                return(null);
            }
            CompRefuelable compRefuelable = thing.TryGetComp <CompRefuelable>();

            if (compRefuelable != null && !compRefuelable.HasFuel)
            {
                if (!RefuelWorkGiverUtility.CanRefuel(pawn, thing, forced))
                {
                    return(null);
                }
                return(RefuelWorkGiverUtility.RefuelJob(pawn, thing, forced));
            }
            billGiver.BillStack.RemoveIncompletableBills();
            return(StartOrResumeBillJob(pawn, billGiver));
        }
        public static bool CanRefuel(Pawn pawn, Thing t, bool forced = false)
        {
            CompRefuelable compRefuelable = t.TryGetComp <CompRefuelable>();

            if (compRefuelable == null || compRefuelable.IsFull)
            {
                return(false);
            }
            if (!forced && !compRefuelable.ShouldAutoRefuelNow)
            {
                return(false);
            }
            if (!t.IsForbidden(pawn))
            {
                LocalTargetInfo target = t;
                bool            ignoreOtherReservations = forced;
                if (pawn.CanReserve(target, 1, -1, null, ignoreOtherReservations))
                {
                    if (t.Faction != pawn.Faction)
                    {
                        return(false);
                    }
                    Thing thing = FindBestFuel(pawn, t);
                    if (thing == null)
                    {
                        ThingFilter fuelFilter = t.TryGetComp <CompRefuelable>().Props.fuelFilter;
                        JobFailReason.Is("NoFuelToRefuel".Translate(fuelFilter.Summary));
                        return(false);
                    }
                    if (t.TryGetComp <CompRefuelable>().Props.atomicFueling&& FindAllFuel(pawn, t) == null)
                    {
                        ThingFilter fuelFilter2 = t.TryGetComp <CompRefuelable>().Props.fuelFilter;
                        JobFailReason.Is("NoFuelToRefuel".Translate(fuelFilter2.Summary));
                        return(false);
                    }
                    return(true);
                }
            }
            return(false);
        }
Exemple #15
0
 public override void PostSpawnSetup(bool respawningAfterLoad)
 {
     base.PostSpawnSetup(respawningAfterLoad);
     this.refuelableComp = this.parent.GetComp <CompRefuelable>();
 }