コード例 #1
0
        // Token: 0x06000069 RID: 105 RVA: 0x00005238 File Offset: 0x00003438
        public static float JPCarryFactor(Pawn pilot, ThingDef JP, ThingDef fuel)
        {
            JPWeightUtility.GetTotalPilotWeight(pilot);
            JPWeightUtility.GetJPCarry(JP, fuel);
            float carryFactor = Mathf.Min(1f, JPWeightUtility.GetJPCarry(JP, fuel) / JPWeightUtility.GetTotalPilotWeight(pilot) * JPWeightUtility.GetGravityFactor());

            return(Mathf.Lerp(0.5f, 1f, carryFactor));
        }
コード例 #2
0
        // Token: 0x06000028 RID: 40 RVA: 0x00002CB8 File Offset: 0x00000EB8
        public void DoJumpJet(Pawn Pilot, IntVec3 targCell)
        {
            JPRotatePilot(Pilot, targCell, out var angle);
            if (JPSkyFallType == null)
            {
                JPSkyFallType = "SFJetPack";
            }

            var JPSF = DefDatabase <ThingDef> .GetNamed(JPSkyFallType, false);

            if (JPSF == null)
            {
                JPSF = DefDatabase <ThingDef> .GetNamed("SFJetPack");

                JPSkyFallType = "SFJetPack";
            }

            var SFspeed = JPSF.skyfaller.speed;

            if (SFspeed <= 0f)
            {
                SFspeed = 1f;
            }

            var distance   = Pilot.Position.DistanceTo(targCell);
            var timeToLand = (int)(distance / SFspeed);

            angle += 270f;
            if (angle >= 360f)
            {
                angle -= 360f;
            }

            int fuelUsed;

            if (Settings.UseCarry)
            {
                fuelUsed = (int)Math.Floor(distance * JPFuelRate /
                                           JPWeightUtility.JPCarryFactor(Pilot, def, JPFuelItem));
            }
            else
            {
                fuelUsed = (int)Math.Floor(distance * JPFuelRate);
            }

            JPFuelAmount -= fuelUsed;
            var skyfaller = SkyfallerMaker.SpawnSkyfaller(JPSF, targCell, Pilot.Map);

            skyfaller.ticksToImpact = timeToLand;
            skyfaller.angle         = angle;
            JPPilotIsDrafted        = Pilot.Drafted;
            Pilot.DeSpawn();
            skyfaller.innerContainer.TryAdd(Pilot, false);
        }
コード例 #3
0
 // Token: 0x0600006A RID: 106 RVA: 0x0000528B File Offset: 0x0000348B
 public static float GetTotalPilotWeight(Pawn pilot)
 {
     return(0f + JPWeightUtility.GetPilotWeight(pilot) + JPWeightUtility.GetInventoryWeight(pilot, true) + JPWeightUtility.GetEquipmentWeight(pilot) + JPWeightUtility.GetApparelWeight(pilot));
 }
コード例 #4
0
 // Token: 0x0600006F RID: 111 RVA: 0x00005468 File Offset: 0x00003668
 public static float GetJPCarry(ThingDef JP, ThingDef fuel)
 {
     return(JPWeightUtility.GetJPBaseCarry(JP) * JPWeightUtility.GetJPFuelCarryFactor(fuel));
 }
コード例 #5
0
        // Token: 0x0600002A RID: 42 RVA: 0x00002E28 File Offset: 0x00001028
        internal bool FlightCellCheck(Pawn pilot, IntVec3 tCell, int fuel, float fRate, float minJump, float maxJump,
                                      out string cantReason)
        {
            cantReason = "";
            if (!tCell.InBounds(pilot.Map))
            {
                cantReason = "JetPack.JumpReasonInvalid".Translate();
                return(false);
            }

            if (JPOnCooldown)
            {
                cantReason = "JetPack.JumpReasonOnCooldown".Translate();
                return(false);
            }

            if (!pilot.CanReserve(tCell))
            {
                cantReason = "JetPack.JumpReasonReserved".Translate();
                return(false);
            }

            if (tCell.Roofed(pilot.Map))
            {
                if (!Settings.RoofPunch)
                {
                    cantReason = "JetPack.JumpReasonRoofed".Translate();
                    return(false);
                }

                var chkSKF = DefDatabase <ThingDef> .GetNamed(JPSkyFallType, false);

                if (chkSKF == null || !chkSKF.skyfaller.hitRoof)
                {
                    cantReason =
                        "JetPack.JumpReasonSFNotRPunch".Translate(
                            chkSKF?.label.CapitalizeFirst());
                    return(false);
                }
            }

            if (!tCell.Walkable(pilot.Map))
            {
                cantReason = "JetPack.JumpReasonNotWalk".Translate();
                return(false);
            }

            if (tCell.GetDangerFor(pilot, pilot.Map) == Danger.Deadly)
            {
                cantReason = "JetPack.JumpReasonDeadly".Translate();
                return(false);
            }

            var distance = pilot.Position.DistanceTo(tCell);

            if (distance < minJump)
            {
                cantReason = "JetPack.JumpReasonMinRange".Translate(((int)minJump).ToString());
                return(false);
            }

            if (distance > maxJump)
            {
                cantReason = "JetPack.JumpReasonMaxRange".Translate(((int)maxJump).ToString());
                return(false);
            }

            if (fRate <= 0f)
            {
                cantReason = "JetPack.JumpFuelRateInvalid".Translate(fRate.ToString());
                return(false);
            }

            float distCanJump;

            if (Settings.UseCarry)
            {
                distCanJump = fuel / fRate * JPWeightUtility.JPCarryFactor(pilot, def, JPFuelItem);
            }
            else
            {
                distCanJump = fuel / fRate;
            }

            if (distCanJump > maxJump)
            {
                distCanJump = maxJump;
            }

            if (!(distCanJump < distance))
            {
                return(true);
            }

            cantReason = "JetPack.JumpNotEnoughfuel".Translate();
            return(false);
        }
コード例 #6
0
        // Token: 0x0600002A RID: 42 RVA: 0x00002E28 File Offset: 0x00001028
        internal bool FlightCellCheck(Pawn pilot, IntVec3 tCell, int fuel, float fRate, float minJump, float maxJump, out string cantReason)
        {
            cantReason = "";
            if (!GenGrid.InBounds(tCell, pilot.Map))
            {
                cantReason = Translator.Translate("JetPack.JumpReasonInvalid");
                return(false);
            }
            if (this.JPOnCooldown)
            {
                cantReason = Translator.Translate("JetPack.JumpReasonOnCooldown");
                return(false);
            }
            if (!ReservationUtility.CanReserve(pilot, tCell, 1, -1, null, false))
            {
                cantReason = Translator.Translate("JetPack.JumpReasonReserved");
                return(false);
            }
            if (GridsUtility.Roofed(tCell, pilot.Map))
            {
                if (!Settings.RoofPunch)
                {
                    cantReason = Translator.Translate("JetPack.JumpReasonRoofed");
                    return(false);
                }
                ThingDef chkSKF = DefDatabase <ThingDef> .GetNamed(this.JPSkyFallType, false);

                if (chkSKF == null || !chkSKF.skyfaller.hitRoof)
                {
                    cantReason = TranslatorFormattedStringExtensions.Translate("JetPack.JumpReasonSFNotRPunch", (chkSKF != null) ? GenText.CapitalizeFirst(chkSKF.label) : null);
                    return(false);
                }
            }
            if (!GenGrid.Walkable(tCell, pilot.Map))
            {
                cantReason = Translator.Translate("JetPack.JumpReasonNotWalk");
                return(false);
            }
            if (DangerUtility.GetDangerFor(tCell, pilot, pilot.Map) == Danger.Deadly)
            {
                cantReason = Translator.Translate("JetPack.JumpReasonDeadly");
                return(false);
            }
            float distance = IntVec3Utility.DistanceTo(pilot.Position, tCell);

            if (distance < minJump)
            {
                cantReason = TranslatorFormattedStringExtensions.Translate("JetPack.JumpReasonMinRange", ((int)minJump).ToString());
                return(false);
            }
            if (distance > maxJump)
            {
                cantReason = TranslatorFormattedStringExtensions.Translate("JetPack.JumpReasonMaxRange", ((int)maxJump).ToString());
                return(false);
            }
            if (fRate <= 0f)
            {
                cantReason = TranslatorFormattedStringExtensions.Translate("JetPack.JumpFuelRateInvalid", fRate.ToString());
                return(false);
            }
            float distCanJump;

            if (Settings.UseCarry)
            {
                distCanJump = (float)fuel / fRate * JPWeightUtility.JPCarryFactor(pilot, this.def, this.JPFuelItem);
            }
            else
            {
                distCanJump = (float)fuel / fRate;
            }
            if (distCanJump > maxJump)
            {
                distCanJump = maxJump;
            }
            if (distCanJump < distance)
            {
                cantReason = Translator.Translate("JetPack.JumpNotEnoughfuel");
                return(false);
            }
            return(true);
        }