Exemplo n.º 1
0
 private static void Postfix(ref bool __result, Map ___map)
 {
     if (!__result && JPUtility.GetJPSkyFOnMap(___map))
     {
         __result = true;
     }
 }
Exemplo n.º 2
0
 // Token: 0x06000027 RID: 39 RVA: 0x00002B44 File Offset: 0x00000D44
 public void UseJetPack(Pawn pilot, Thing JP, IntVec3 targCell)
 {
     if (!this.JPComposMentis(pilot, JP, out string Reason))
     {
         Messages.Message(TranslatorFormattedStringExtensions.Translate("JetPack.CantDo", pilot, Reason), pilot, MessageTypeDefOf.NeutralEvent, false);
         SoundStarter.PlayOneShotOnCamera(SoundDefOf.ClickReject, null);
         return;
     }
     if (!this.FlightChecksOK(pilot, JP, out string ChecksReason))
     {
         Messages.Message(TranslatorFormattedStringExtensions.Translate("JetPack.ChecksReason", GenText.CapitalizeFirst(pilot.LabelShort), ChecksReason), pilot, MessageTypeDefOf.NeutralEvent, false);
         SoundStarter.PlayOneShotOnCamera(SoundDefOf.ClickReject, null);
         return;
     }
     if (JPUtility.ChkForDissallowed(pilot, out string DAllowReason))
     {
         Messages.Message(TranslatorFormattedStringExtensions.Translate("JetPack.DAllowReason", GenText.CapitalizeFirst(pilot.LabelShort), DAllowReason), pilot, MessageTypeDefOf.NeutralEvent, false);
         SoundStarter.PlayOneShotOnCamera(SoundDefOf.ClickReject, null);
         return;
     }
     if (!this.FlightCellCheck(pilot, targCell, this.JPFuelAmount, this.JPFuelRate, this.JPJumpRangeMin, this.JPJumpRangeMax, out string JumpReason))
     {
         Messages.Message(TranslatorFormattedStringExtensions.Translate("JetPack.JumpReason", JumpReason), pilot, MessageTypeDefOf.NeutralEvent, false);
         SoundStarter.PlayOneShotOnCamera(SoundDefOf.ClickReject, null);
         return;
     }
     if (!JPInjury.CheckForExplosion(this))
     {
         this.DoJumpJet(pilot, targCell);
         return;
     }
     JPInjury.DoJPExplosion(pilot, this.JPFuelAmount, this.JPFuelItem);
     this.JPFuelAmount = 0;
 }
Exemplo n.º 3
0
        // Token: 0x06000053 RID: 83 RVA: 0x00004800 File Offset: 0x00002A00
        public void JPIgnite(IntVec3 cell, Map map)
        {
            var pilot = GetThingForGraphic();

            if (pilot == null)
            {
                return;
            }

            var JP = JPUtility.GetWornJP(pilot);

            if (JP == null)
            {
                return;
            }

            var jetPackApparel = JP as JetPackApparel;
            var fuel           = jetPackApparel?.JPFuelItem;

            if (fuel == null)
            {
                return;
            }

            var factor = JPUtility.GetIgnitionFactor(fuel);
            var Rnd    = Rand.Range(1, 100);

            if (Rnd < factor)
            {
                FireUtility.TryStartFireIn(cell, map, Math.Max(10f, factor - Rnd) / 100f);
            }
        }
 public static void PostFix(ref bool __result, ThingDef A, ThingDef B, BodyDef body)
 {
     if (__result && JPUtility.GetIsJPApparel(A) && JPUtility.GetIsJPApparel(B))
     {
         __result = false;
     }
 }
Exemplo n.º 5
0
        // Token: 0x0600004C RID: 76 RVA: 0x0000435C File Offset: 0x0000255C
        internal void JPApplyCooldown(Thing pilot, int cd)
        {
            var JP = JPUtility.GetWornJP(pilot);

            if (JP is JetPackApparel apparel)
            {
                apparel.JPCooldownTicks = Math.Max(0, 60 * cd);
            }
        }
Exemplo n.º 6
0
        // Token: 0x0600004C RID: 76 RVA: 0x0000435C File Offset: 0x0000255C
        internal void JPApplyCooldown(Thing pilot, int cd)
        {
            Apparel JP = JPUtility.GetWornJP(pilot);

            if (JP != null && JP is JetPackApparel)
            {
                (JP as JetPackApparel).JPCooldownTicks = Math.Max(0, 60 * cd);
            }
        }
Exemplo n.º 7
0
 // Token: 0x0600002D RID: 45 RVA: 0x000032F0 File Offset: 0x000014F0
 public void ChangeFuelJP(Pawn pilot, Thing JP, ThingDef fueldef, float MinRange)
 {
     if (this.JPFuelItem != fueldef)
     {
         this.RemoveFuel(pilot);
         this.JPFuelAmount   = 0;
         this.JPFuelItem     = fueldef;
         this.JPFuelRate     = JPUtility.GetFuelRate(fueldef);
         this.JPJumpRangeMax = (float)JPUtility.GetJumpRange(pilot, JP.def, fueldef, MinRange);
     }
 }
Exemplo n.º 8
0
 // Token: 0x0600004E RID: 78 RVA: 0x000043C4 File Offset: 0x000025C4
 internal void CheckDrafting(Thing pilot)
 {
     if (pilot != null && pilot is Pawn)
     {
         Apparel JP = JPUtility.GetWornJP(pilot);
         if (JP != null && (JP as JetPackApparel).JPPilotIsDrafted)
         {
             (JP as JetPackApparel).JPPilotIsDrafted = false;
             (pilot as Pawn).drafter.Drafted         = true;
         }
     }
 }
Exemplo n.º 9
0
        // Token: 0x0600002D RID: 45 RVA: 0x000032F0 File Offset: 0x000014F0
        public void ChangeFuelJP(Pawn pilot, Thing JP, ThingDef fueldef, float MinRange)
        {
            if (JPFuelItem == fueldef)
            {
                return;
            }

            RemoveFuel(pilot);
            JPFuelAmount   = 0;
            JPFuelItem     = fueldef;
            JPFuelRate     = JPUtility.GetFuelRate(fueldef);
            JPJumpRangeMax = JPUtility.GetJumpRange(pilot, JP.def, fueldef, MinRange);
        }
Exemplo n.º 10
0
        // Token: 0x0600003E RID: 62 RVA: 0x000038C0 File Offset: 0x00001AC0
        protected override Job TryGiveJob(Pawn pawn)
        {
            if (!Settings.DoAutoRefuel || !pawn.IsColonistPlayerControlled)
            {
                return(null);
            }

            if (pawn.InMentalState)
            {
                return(null);
            }

            if (pawn.Map == null)
            {
                return(null);
            }

            var jobdef = DefDatabase <JobDef> .GetNamed("JPRefuel");

            if (pawn.CurJobDef == jobdef)
            {
                return(null);
            }

            var JP = JPUtility.GetWornJP(pawn);

            if (JP == null)
            {
                return(null);
            }

            var FuelMax  = ((JetPackApparel)JP).JPFuelMax;
            var Fuel     = (JP as JetPackApparel).JPFuelAmount;
            var FuelItem = (JP as JetPackApparel).JPFuelItem;

            if (FuelMax <= 0 || Fuel >= FuelMax || Fuel * 100 / FuelMax > Settings.RefuelPCT)
            {
                return(null);
            }

            FindBestRefuel(pawn, FuelItem, FuelMax, Fuel, out var targ);
            if (targ != null)
            {
                return(new Job(jobdef, targ));
            }

            return(null);
        }
Exemplo n.º 11
0
        public static void PostFix(ref float __result, StatWorker __instance, StatDef ___stat, StatRequest req)
        {
            if (!req.HasThing)
            {
                return;
            }
            Thing thing = req.Thing;

            if (!(thing is Pawn))
            {
                return;
            }
            if (___stat == StatDefOf.MoveSpeed)
            {
                __result += JPUtility.GetSlowBurn(thing as Pawn);
            }
        }
Exemplo n.º 12
0
        // Token: 0x0600004E RID: 78 RVA: 0x000043C4 File Offset: 0x000025C4
        internal void CheckDrafting(Thing pilot)
        {
            if (pilot is not Pawn)
            {
                return;
            }

            var JP = JPUtility.GetWornJP(pilot);

            if (JP == null || !((JetPackApparel)JP).JPPilotIsDrafted)
            {
                return;
            }

            (JP as JetPackApparel).JPPilotIsDrafted = false;
            ((Pawn)pilot).drafter.Drafted           = true;
        }
Exemplo n.º 13
0
        // Token: 0x06000023 RID: 35 RVA: 0x000029F0 File Offset: 0x00000BF0
        public override void Tick()
        {
            base.Tick();
            if (JPCooldownTicks > 0)
            {
                JPCooldownTicks--;
            }

            if (Settings.AllowSlowBurn)
            {
                if (Wearer == null)
                {
                    JPSlowBurn = false;
                    return;
                }

                if (!JPSlowBurn || !Wearer.Spawned || Wearer.GetPosture() == PawnPosture.LayingInBed ||
                    Wearer.GetPosture() == PawnPosture.LayingOnGroundFaceUp ||
                    Wearer.GetPosture() == PawnPosture.LayingOnGroundNormal)
                {
                    return;
                }

                if (JPSlowBurnTicks > 0)
                {
                    JPSlowBurnTicks--;
                    return;
                }

                if (JPFuelAmount > 0)
                {
                    JPFuelAmount--;
                    JPSlowBurnTicks = JPUtility.GetSlowBurnTicks(JPFuelItem);
                    return;
                }

                JPSlowBurn = false;
                Messages.Message(
                    "JetPack.SBOutOfFuel".Translate(Wearer.LabelShort.CapitalizeFirst(), Label.CapitalizeFirst()),
                    Wearer, MessageTypeDefOf.NeutralEvent, false);
            }
            else
            {
                JPSlowBurn = false;
            }
        }
Exemplo n.º 14
0
        // Token: 0x0600002B RID: 43 RVA: 0x0000302C File Offset: 0x0000122C
        internal void RefuelJetPack(Pawn pilot, ThingWithComps thing)
        {
            List <FloatMenuOption> list = new List <FloatMenuOption>();
            string text = Translator.Translate("JetPack.JPDoNothing");

            list.Add(new FloatMenuOption(text, delegate()
            {
                this.RefuelJP(pilot, thing, false);
            }, MenuOptionPriority.Default, null, null, 29f, null, null));
            if (this.JPFuelAmount < this.JPFuelMax)
            {
                text = Translator.Translate("JetPack.JPDoRefuel");
                list.Add(new FloatMenuOption(text, delegate()
                {
                    this.RefuelJP(pilot, thing, true);
                }, MenuOptionPriority.Default, null, null, 29f, null, null));
            }
            if (this.JPFuelAmount > 0)
            {
                text = Translator.Translate("JetPack.JPDropFuel");
                list.Add(new FloatMenuOption(text, delegate()
                {
                    this.DropFuelJP(pilot, thing);
                }, MenuOptionPriority.Default, null, null, 29f, null, null));
            }
            List <string> fuels = JPUtility.ListFuelTypes(this.def);

            if (fuels.Count > 0)
            {
                for (int i = 0; i < fuels.Count; i++)
                {
                    ThingDef fuelref = DefDatabase <ThingDef> .GetNamed(fuels[i], true);

                    if (fuelref != (thing as JetPackApparel).JPFuelItem)
                    {
                        text = TranslatorFormattedStringExtensions.Translate("JetPack.JPDoChangeFuel", GenText.CapitalizeFirst(fuelref.label));
                        list.Add(new FloatMenuOption(text, delegate()
                        {
                            this.ChangeFuelJP(pilot, thing, fuelref, this.JPJumpRangeMin);
                        }, MenuOptionPriority.Default, null, null, 29f, null, null));
                    }
                }
            }
            Find.WindowStack.Add(new FloatMenu(list));
        }
Exemplo n.º 15
0
        // Token: 0x06000027 RID: 39 RVA: 0x00002B44 File Offset: 0x00000D44
        public void UseJetPack(Pawn pilot, Thing JP, IntVec3 targCell)
        {
            if (!JPComposMentis(pilot, JP, out var Reason))
            {
                Messages.Message("JetPack.CantDo".Translate(pilot, Reason), pilot, MessageTypeDefOf.NeutralEvent,
                                 false);
                SoundDefOf.ClickReject.PlayOneShotOnCamera();
                return;
            }

            if (!FlightChecksOK(pilot, JP, out var ChecksReason))
            {
                Messages.Message("JetPack.ChecksReason".Translate(pilot.LabelShort.CapitalizeFirst(), ChecksReason),
                                 pilot, MessageTypeDefOf.NeutralEvent, false);
                SoundDefOf.ClickReject.PlayOneShotOnCamera();
                return;
            }

            if (JPUtility.ChkForDissallowed(pilot, out var DAllowReason))
            {
                Messages.Message("JetPack.DAllowReason".Translate(pilot.LabelShort.CapitalizeFirst(), DAllowReason),
                                 pilot, MessageTypeDefOf.NeutralEvent, false);
                SoundDefOf.ClickReject.PlayOneShotOnCamera();
                return;
            }

            if (!FlightCellCheck(pilot, targCell, JPFuelAmount, JPFuelRate, JPJumpRangeMin, JPJumpRangeMax,
                                 out var JumpReason))
            {
                Messages.Message("JetPack.JumpReason".Translate(JumpReason), pilot, MessageTypeDefOf.NeutralEvent,
                                 false);
                SoundDefOf.ClickReject.PlayOneShotOnCamera();
                return;
            }

            if (!JPInjury.CheckForExplosion(this))
            {
                DoJumpJet(pilot, targCell);
                return;
            }

            JPInjury.DoJPExplosion(pilot, JPFuelAmount, JPFuelItem);
            JPFuelAmount = 0;
        }
Exemplo n.º 16
0
        // Token: 0x0600002B RID: 43 RVA: 0x0000302C File Offset: 0x0000122C
        internal void RefuelJetPack(Pawn pilot, ThingWithComps thing)
        {
            var    list = new List <FloatMenuOption>();
            string text = "JetPack.JPDoNothing".Translate();

            list.Add(new FloatMenuOption(text, delegate { RefuelJP(pilot, thing, false); }, MenuOptionPriority.Default,
                                         null, null, 29f));
            if (JPFuelAmount < JPFuelMax)
            {
                text = "JetPack.JPDoRefuel".Translate();
                list.Add(new FloatMenuOption(text, delegate { RefuelJP(pilot, thing, true); },
                                             MenuOptionPriority.Default, null, null, 29f));
            }

            if (JPFuelAmount > 0)
            {
                text = "JetPack.JPDropFuel".Translate();
                list.Add(new FloatMenuOption(text, delegate { DropFuelJP(pilot, thing); }, MenuOptionPriority.Default,
                                             null, null, 29f));
            }

            var fuels = JPUtility.ListFuelTypes(def);

            if (fuels.Count > 0)
            {
                foreach (var defName in fuels)
                {
                    var fuelref = DefDatabase <ThingDef> .GetNamed(defName);

                    if (fuelref == (thing as JetPackApparel)?.JPFuelItem)
                    {
                        continue;
                    }

                    text = "JetPack.JPDoChangeFuel".Translate(fuelref.label.CapitalizeFirst());
                    list.Add(new FloatMenuOption(text,
                                                 delegate { ChangeFuelJP(pilot, thing, fuelref, JPJumpRangeMin); },
                                                 MenuOptionPriority.Default, null, null, 29f));
                }
            }

            Find.WindowStack.Add(new FloatMenu(list));
        }
Exemplo n.º 17
0
        // Token: 0x0600003E RID: 62 RVA: 0x000038C0 File Offset: 0x00001AC0
        protected override Job TryGiveJob(Pawn pawn)
        {
            if (!Settings.DoAutoRefuel || !pawn.IsColonistPlayerControlled)
            {
                return(null);
            }
            if (pawn.InMentalState)
            {
                return(null);
            }
            if ((pawn?.Map) == null)
            {
                return(null);
            }
            JobDef jobdef = DefDatabase <JobDef> .GetNamed("JPRefuel", true);

            if ((pawn?.CurJobDef) == jobdef)
            {
                return(null);
            }
            Apparel JP = JPUtility.GetWornJP(pawn);

            if (JP != null)
            {
                int      FuelMax  = (JP as JetPackApparel).JPFuelMax;
                int      Fuel     = (JP as JetPackApparel).JPFuelAmount;
                ThingDef FuelItem = (JP as JetPackApparel).JPFuelItem;
                if (FuelMax > 0 && Fuel < FuelMax && Fuel * 100 / FuelMax <= Settings.RefuelPCT)
                {
                    this.FindBestRefuel(pawn, FuelItem, FuelMax, Fuel, out Thing targ);
                    if (targ != null)
                    {
                        return(new Job(jobdef, targ));
                    }
                }
            }
            return(null);
        }
Exemplo n.º 18
0
        // Token: 0x06000053 RID: 83 RVA: 0x00004800 File Offset: 0x00002A00
        public void JPIgnite(IntVec3 cell, Map map)
        {
            Thing pilot = this.GetThingForGraphic();

            if (pilot != null)
            {
                Apparel JP = JPUtility.GetWornJP(pilot);
                if (JP != null)
                {
                    JetPackApparel jetPackApparel = JP as JetPackApparel;
                    ThingDef       fuel           = jetPackApparel?.JPFuelItem;
                    if (fuel != null)
                    {
                        float factor = JPUtility.GetIgnitionFactor(fuel);
                        int   Rnd    = Rand.Range(1, 100);
                        if ((float)Rnd < factor)
                        {
                            FireUtility.TryStartFireIn(cell, map, Math.Max(10f, factor - (float)Rnd) / 100f);
                        }
                    }
                }
            }
        }
Exemplo n.º 19
0
 // Token: 0x06000023 RID: 35 RVA: 0x000029F0 File Offset: 0x00000BF0
 public override void Tick()
 {
     base.Tick();
     if (this.JPCooldownTicks > 0)
     {
         this.JPCooldownTicks--;
     }
     if (Settings.AllowSlowBurn)
     {
         if (base.Wearer == null)
         {
             this.JPSlowBurn = false;
             return;
         }
         if (this.JPSlowBurn && base.Wearer.Spawned && PawnUtility.GetPosture(base.Wearer) != PawnPosture.LayingInBed && PawnUtility.GetPosture(base.Wearer) != PawnPosture.LayingOnGroundFaceUp && PawnUtility.GetPosture(base.Wearer) != PawnPosture.LayingOnGroundNormal)
         {
             if (this.JPSlowBurnTicks > 0)
             {
                 this.JPSlowBurnTicks--;
                 return;
             }
             if (this.JPFuelAmount > 0)
             {
                 this.JPFuelAmount--;
                 this.JPSlowBurnTicks = JPUtility.GetSlowBurnTicks(this.JPFuelItem);
                 return;
             }
             this.JPSlowBurn = false;
             Messages.Message(TranslatorFormattedStringExtensions.Translate("JetPack.SBOutOfFuel", GenText.CapitalizeFirst(base.Wearer.LabelShort), GenText.CapitalizeFirst(this.Label)), base.Wearer, MessageTypeDefOf.NeutralEvent, false);
             return;
         }
     }
     else
     {
         this.JPSlowBurn = false;
     }
 }
Exemplo n.º 20
0
        // Token: 0x06000025 RID: 37 RVA: 0x00002B27 File Offset: 0x00000D27
        public override IEnumerable <Gizmo> GetWornGizmos()
        {
            Texture2D fuelicon = this.JPFuelItem.uiIcon;

            if (fuelicon == null)
            {
                ThingDef chkFuelItem = null;
                if (this.JPFuelItem == null)
                {
                    chkFuelItem = DefDatabase <ThingDef> .GetNamed(base.GetComp <CompJetPack>().Props.JPFuel, false);
                }
                if (chkFuelItem != null && chkFuelItem != this.JPFuelItem)
                {
                    this.JPFuelItem = chkFuelItem;
                    int chkFuelMax = base.GetComp <CompJetPack>().Props.JPFuelMaximum;
                    if (chkFuelMax != this.JPFuelMax)
                    {
                        this.JPFuelMax = chkFuelMax;
                        if (this.JPFuelAmount > this.JPFuelMax)
                        {
                            this.JPFuelAmount = this.JPFuelMax;
                        }
                    }
                }
                fuelicon = this.JPFuelItem.uiIcon;
                if (fuelicon == null)
                {
                    this.JPFuelItem = ThingDefOf.Chemfuel;
                    fuelicon        = this.JPFuelItem.uiIcon;
                    if (fuelicon == null)
                    {
                        fuelicon = this.def.uiIcon;
                        Log.Message("Error: Jet Pack fuel definition not found.", false);
                    }
                }
            }
            string chkSkyFallType = base.GetComp <CompJetPack>().Props.JPSKType;

            if (chkSkyFallType == null || chkSkyFallType == "")
            {
                this.JPSkyFallType = "SFJetPack";
            }
            else if (chkSkyFallType != this.JPSkyFallType)
            {
                this.JPSkyFallType = chkSkyFallType;
            }
            Pawn pilot = base.Wearer;

            this.JPJumpRangeMax = (float)JPUtility.GetJumpRange(pilot, this.def, this.JPFuelItem, this.JPJumpRangeMin);
            this.JPFuelRate     = JPUtility.GetFuelRate(this.JPFuelItem);
            if (base.Wearer != null && base.Wearer.IsColonistPlayerControlled)
            {
                Pawn wearer = base.Wearer;
                if ((wearer?.Map) != null && !base.Wearer.Downed && base.Wearer.Spawned && !JPUtility.IsInMeleeWithJP(base.Wearer))
                {
                    if (Find.Selector.SingleSelectedThing == base.Wearer)
                    {
                        string text;
                        if (this.JPOnCooldown)
                        {
                            text = TranslatorFormattedStringExtensions.Translate("JetPack.CooldownTicks", this.JPCooldownTicks.ToString());
                        }
                        else
                        {
                            text = Translator.Translate("JetPack.JPJump");
                        }
                        string desc = TranslatorFormattedStringExtensions.Translate("JetPack.JPDesc", GenText.CapitalizeFirst(this.def.label));
                        yield return(new Command_JetPack
                        {
                            defaultLabel = text,
                            defaultDesc = desc,
                            icon = this.def.uiIcon,
                            Pilot = base.Wearer,
                            JPFuel = this.JPFuelAmount,
                            JPFRate = this.JPFuelRate,
                            JPMaxJump = this.JPJumpRangeMax,
                            JPMinJump = this.JPJumpRangeMin,
                            JPSKFStr = this.JPSkyFallType,
                            action = delegate(IntVec3 cell)
                            {
                                SoundStarter.PlayOneShotOnCamera(SoundDefOf.Click, null);
                                this.UseJetPack(base.Wearer, this, cell);
                            }
                        });

                        if (Settings.AllowSlowBurn)
                        {
                            text = Translator.Translate("JetPack.JPSBSet");
                            desc = Translator.Translate("JetPack.JPSBDesc");
                            yield return(new Command_Toggle
                            {
                                icon = ContentFinder <Texture2D> .Get(this.JPSBTexPath, true),
                                defaultLabel = text,
                                defaultDesc = desc,
                                isActive = (() => this.JPSlowBurn),
                                toggleAction = delegate()
                                {
                                    this.ToggleSlowBurn(this.JPSlowBurn);
                                }
                            });
                        }
                        text = TranslatorFormattedStringExtensions.Translate("JetPack.JPLabel", GenText.CapitalizeFirst(this.def.label), this.JPFuelAmount.ToString(), this.JPFuelMax.ToString());
                        desc = TranslatorFormattedStringExtensions.Translate("JetPack.JPDesc", GenText.CapitalizeFirst(this.def.label));
                        yield return(new Command_Action
                        {
                            defaultLabel = text,
                            defaultDesc = desc,
                            icon = fuelicon,
                            action = delegate()
                            {
                                SoundStarter.PlayOneShotOnCamera(SoundDefOf.Click, null);
                                this.RefuelJetPack(base.Wearer, this);
                            }
                        });

                        if (Prefs.DevMode)
                        {
                            yield return(new Command_Action
                            {
                                defaultLabel = "Debug Settings",
                                defaultDesc = "Debug Commands",
                                icon = fuelicon,
                                action = delegate()
                                {
                                    SoundStarter.PlayOneShotOnCamera(SoundDefOf.Click, null);
                                    this.DoJetPackDebug(base.Wearer, this);
                                }
                            });
                        }
                    }
                    yield break;
                }
            }
            yield break;
        }
Exemplo n.º 21
0
        // Token: 0x06000024 RID: 36 RVA: 0x00002B1F File Offset: 0x00000D1F

        // Token: 0x06000025 RID: 37 RVA: 0x00002B27 File Offset: 0x00000D27
        public override IEnumerable <Gizmo> GetWornGizmos()
        {
            var fuelicon = JPFuelItem.uiIcon;

            if (fuelicon == null)
            {
                ThingDef chkFuelItem = null;
                if (JPFuelItem == null)
                {
                    chkFuelItem = DefDatabase <ThingDef> .GetNamed(GetComp <CompJetPack>().Props.JPFuel, false);
                }

                if (chkFuelItem != null && chkFuelItem != JPFuelItem)
                {
                    JPFuelItem = chkFuelItem;
                    var chkFuelMax = GetComp <CompJetPack>().Props.JPFuelMaximum;
                    if (chkFuelMax != JPFuelMax)
                    {
                        JPFuelMax = chkFuelMax;
                        if (JPFuelAmount > JPFuelMax)
                        {
                            JPFuelAmount = JPFuelMax;
                        }
                    }
                }

                fuelicon = JPFuelItem.uiIcon;
                if (fuelicon == null)
                {
                    JPFuelItem = ThingDefOf.Chemfuel;
                    fuelicon   = JPFuelItem.uiIcon;
                    if (fuelicon == null)
                    {
                        fuelicon = def.uiIcon;
                        Log.Message("Error: Jet Pack fuel definition not found.");
                    }
                }
            }

            var chkSkyFallType = GetComp <CompJetPack>().Props.JPSKType;

            JPSkyFallType = string.IsNullOrEmpty(chkSkyFallType) ? "SFJetPack" : chkSkyFallType;

            var pilot = Wearer;

            JPJumpRangeMax = JPUtility.GetJumpRange(pilot, def, JPFuelItem, JPJumpRangeMin);
            JPFuelRate     = JPUtility.GetFuelRate(JPFuelItem);
            if (Wearer == null || !Wearer.IsColonistPlayerControlled)
            {
                yield break;
            }

            var wearer = Wearer;

            if (wearer?.Map == null || Wearer.Downed || !Wearer.Spawned || JPUtility.IsInMeleeWithJP(Wearer))
            {
                yield break;
            }

            if (Find.Selector.SingleSelectedThing != Wearer)
            {
                yield break;
            }

            string text = JPOnCooldown
                ? "JetPack.CooldownTicks".Translate(JPCooldownTicks.ToString())
                : "JetPack.JPJump".Translate();

            string desc = "JetPack.JPDesc".Translate(def.label.CapitalizeFirst());

            yield return(new Command_JetPack
            {
                defaultLabel = text,
                defaultDesc = desc,
                icon = def.uiIcon,
                Pilot = Wearer,
                JPFuel = JPFuelAmount,
                JPFRate = JPFuelRate,
                JPMaxJump = JPJumpRangeMax,
                JPMinJump = JPJumpRangeMin,
                JPSKFStr = JPSkyFallType,
                action = delegate(IntVec3 cell)
                {
                    SoundDefOf.Click.PlayOneShotOnCamera();
                    UseJetPack(Wearer, this, cell);
                }
            });

            if (Settings.AllowSlowBurn)
            {
                text = "JetPack.JPSBSet".Translate();
                desc = "JetPack.JPSBDesc".Translate();
                yield return(new Command_Toggle
                {
                    icon = ContentFinder <Texture2D> .Get(JPSBTexPath),
                    defaultLabel = text,
                    defaultDesc = desc,
                    isActive = () => JPSlowBurn,
                    toggleAction = delegate { ToggleSlowBurn(JPSlowBurn); }
                });
            }

            text = "JetPack.JPLabel".Translate(def.label.CapitalizeFirst(), JPFuelAmount.ToString(),
                                               JPFuelMax.ToString());
            desc = "JetPack.JPDesc".Translate(def.label.CapitalizeFirst());
            yield return(new Command_Action
            {
                defaultLabel = text,
                defaultDesc = desc,
                icon = fuelicon,
                action = delegate
                {
                    SoundDefOf.Click.PlayOneShotOnCamera();
                    RefuelJetPack(Wearer, this);
                }
            });

            if (Prefs.DevMode)
            {
                yield return(new Command_Action
                {
                    defaultLabel = "Debug Settings",
                    defaultDesc = "Debug Commands",
                    icon = fuelicon,
                    action = delegate
                    {
                        SoundDefOf.Click.PlayOneShotOnCamera();
                        DoJetPackDebug(Wearer, this);
                    }
                });
            }
        }
Exemplo n.º 22
0
        // Token: 0x06000021 RID: 33 RVA: 0x000025DC File Offset: 0x000007DC
        public override void PostMake()
        {
            base.PostMake();
            JPFuelItem = DefDatabase <ThingDef> .GetNamed(GetComp <CompJetPack>().Props.JPFuel, false);

            JPFuelAmount     = GetComp <CompJetPack>().Props.JPFuelLevel;
            JPFuelMax        = GetComp <CompJetPack>().Props.JPFuelMaximum;
            JPFuelMin        = GetComp <CompJetPack>().Props.JPFuelMinimum;
            JPFuelRate       = GetComp <CompJetPack>().Props.JPFuelBurnRate;
            JPJumpRangeMax   = GetComp <CompJetPack>().Props.JPJumpMax;
            JPJumpRangeMin   = GetComp <CompJetPack>().Props.JPJumpMin;
            JPSkyFallType    = GetComp <CompJetPack>().Props.JPSKType;
            JPPilotIsDrafted = false;
            JPSlowBurn       = false;
            JPSlowBurnTicks  = 0;
            if (JPFuelItem == null)
            {
                JPFuelItem = ThingDefOf.Chemfuel;
                Log.Message("Warning: Jet pack fuel item not defined, defaulting to chemfuel");
            }
            else
            {
                var pilot = Wearer;
                if (JPFuelItem == DefDatabase <ThingDef> .GetNamed("MSHydrogenPeroxide", false))
                {
                    JPJumpRangeMax = JPUtility.GetJumpRange(pilot, def, JPFuelItem, JPJumpRangeMin);
                    JPFuelRate     = JPUtility.GetFuelRate(JPFuelItem);
                }
                else if (JPFuelItem == DefDatabase <ThingDef> .GetNamed("JPKerosene"))
                {
                    JPJumpRangeMax = JPUtility.GetJumpRange(pilot, def, JPFuelItem, JPJumpRangeMin);
                    JPFuelRate     = JPUtility.GetFuelRate(JPFuelItem);
                }
            }

            if (JPFuelAmount < 0)
            {
                JPFuelAmount = 0;
            }

            if (JPFuelMax < 75)
            {
                JPFuelMax = 75;
            }

            if (JPFuelMax > 150)
            {
                JPFuelMax = 150;
            }

            if (JPFuelMin < 5)
            {
                JPFuelMin = 5;
            }

            if (JPFuelMin > JPFuelMax)
            {
                JPFuelMin = JPFuelMax;
            }

            if (JPFuelRate < 0.1f)
            {
                JPFuelRate = 0.1f;
            }

            if (JPFuelRate > 1f)
            {
                JPFuelRate = 1f;
            }

            if (JPJumpRangeMax > 30f)
            {
                JPJumpRangeMax = 30f;
            }

            if (JPJumpRangeMax < 10f)
            {
                JPJumpRangeMax = 10f;
            }

            if (JPJumpRangeMin < 5f)
            {
                JPJumpRangeMin = 5f;
            }

            if (JPJumpRangeMin > 9f)
            {
                JPJumpRangeMin = 9f;
            }

            if (def.defName != "Apparel_PowArmCGearJetPack")
            {
                if (def.defName != "Apparel_PowArmJetPack")
                {
                    if (def.defName != "Apparel_BoosterJetPack")
                    {
                        if (JPSkyFallType != null && JPSkyFallType != "SFJetPack")
                        {
                            JPSkyFallType = "SFJetPack";
                        }
                    }
                    else
                    {
                        JPSkyFallType = "SFBoostPack";
                    }
                }
                else
                {
                    JPSkyFallType = "SFJetPackPowArm";
                }
            }
            else
            {
                JPSkyFallType = "SFJetPackCGear";
            }

            if (JPFuelAmount > JPFuelMax)
            {
                JPFuelAmount = JPFuelMax;
            }
        }