示例#1
0
        public static bool IsTakingTempTool(this JobDef jobDef)
        {
            var ext = jobDef?.GetModExtension <Job_Extension>();

            if (ext == null)
            {
                return(false);
            }
            return(ext.isOpportunistic && ext.isTakeToolJob);
        }
示例#2
0
        private static Gizmo CreateGizmo_SelfRepair(Pawn __instance, ExtendedPawnData pawnData)
        {
            CompRefuelable          compRefuelable = __instance.GetComp <CompRefuelable>();
            Need_Power              powerNeed      = __instance.needs.TryGetNeed <Need_Power>();
            JobDef                  jobDef         = WTH_DefOf.WTH_Ability_Repair;
            DefModExtension_Ability modExt         = jobDef.GetModExtension <DefModExtension_Ability>();

            bool   alreadyRepairing = __instance.health.hediffSet.HasHediff(WTH_DefOf.WTH_Repairing);
            bool   needsMorePower   = powerNeed.CurLevel < modExt.powerDrain;
            bool   needsMoreFuel    = compRefuelable.Fuel < modExt.fuelDrain;
            bool   notActicated     = !__instance.IsActivated();
            bool   noDamage         = !__instance.health.hediffSet.HasNaturallyHealingInjury();
            bool   isDisabled       = alreadyRepairing || needsMorePower || needsMoreFuel || notActicated || noDamage;
            string disabledReason   = "";

            if (isDisabled)
            {
                if (alreadyRepairing)
                {
                    disabledReason = "WTH_Reason_AlreadyRepairing".Translate();
                }
                else if (notActicated)
                {
                    disabledReason = "WTH_Reason_NotActivated".Translate();
                }
                else if (noDamage)
                {
                    disabledReason = "WTH_Reason_NoDamage".Translate();
                }
                else if (needsMorePower)
                {
                    disabledReason = "WTH_Reason_NeedsMorePower".Translate(new object[] { modExt.powerDrain });
                }
                else if (needsMoreFuel)
                {
                    disabledReason = "WTH_Reason_NeedsMoreFuel".Translate(new object[] { modExt.fuelDrain });
                }
            }

            Gizmo gizmo = new Command_Action
            {
                defaultLabel   = "WTH_Gizmo_SelfRepair_Label".Translate(),
                defaultDesc    = "WTH_Gizmo_SelfRepair_Description".Translate(),
                icon           = ContentFinder <Texture2D> .Get(("Things/" + "Mote_HealingCrossGreen"), true),
                disabled       = isDisabled,
                disabledReason = disabledReason,
                action         = delegate
                {
                    Job job = new Job(WTH_DefOf.WTH_Ability_Repair, __instance);
                    __instance.jobs.StartJob(job, JobCondition.InterruptForced);
                }
            };

            return(gizmo);
        }
示例#3
0
        private static Gizmo CreateGizmo_Repair(Pawn __instance, ExtendedPawnData pawnData)
        {
            CompRefuelable compRefuelable = __instance.GetComp <CompRefuelable>();
            Need_Power     powerNeed      = __instance.needs.TryGetNeed <Need_Power>();

            JobDef jobDef = WTH_DefOf.WTH_Ability_Repair;
            DefModExtension_Ability modExt = jobDef.GetModExtension <DefModExtension_Ability>();
            bool alreadyRepairing          = __instance.health.hediffSet.HasHediff(WTH_DefOf.WTH_Repairing);
            bool needsMorePower            = powerNeed.CurLevel < modExt.powerDrain;
            bool needsMoreFuel             = compRefuelable.Fuel < modExt.fuelDrain;
            bool notActicated = !__instance.IsActivated();

            bool   isDisabled     = needsMorePower || needsMoreFuel || notActicated;
            string disabledReason = "";

            if (isDisabled)
            {
                if (needsMorePower)
                {
                    disabledReason = "WTH_Reason_NeedsMorePower".Translate(new object[] { modExt.powerDrain });
                }
                else if (needsMoreFuel)
                {
                    disabledReason = "WTH_Reason_NeedsMoreFuel".Translate(new object[] { modExt.fuelDrain });
                }
                else if (notActicated)
                {
                    disabledReason = "WTH_Reason_NotActivated".Translate();
                }
            }

            Gizmo gizmo = new Command_Target
            {
                defaultLabel    = "WTH_Gizmo_Mech_Repair_Label".Translate(),
                defaultDesc     = "WTH_Gizmo_Mech_Repair_Description".Translate(),
                icon            = ContentFinder <Texture2D> .Get(("Things/" + "Mote_HealingCrossBlue"), true), //TODO: other icon
                disabled        = isDisabled,
                targetingParams = GetTargetingParametersForRepairing(),
                disabledReason  = disabledReason,
                action          = delegate(LocalTargetInfo target)
                {
                    if (target.HasThing && target.Thing is Pawn mech)
                    {
                        Job job = new Job(WTH_DefOf.WTH_Ability_Repair, target);
                        __instance.jobs.StartJob(job, JobCondition.InterruptForced);
                    }
                }
            };

            return(gizmo);
        }
示例#4
0
        private static Gizmo CreateGizmo_Overdrive(Pawn __instance, ExtendedPawnData pawnData)
        {
            Need_Power powerNeed = __instance.needs.TryGetNeed <Need_Power>();

            JobDef jobDef = WTH_DefOf.WTH_Ability_Overdrive;
            DefModExtension_Ability modExt = jobDef.GetModExtension <DefModExtension_Ability>();
            bool alreadyOverdriving        = __instance.health.hediffSet.HasHediff(WTH_DefOf.WTH_Overdrive);
            bool needsMorePower            = powerNeed.CurLevel < modExt.powerDrain;
            bool notActicated = !__instance.IsActivated();

            bool   isDisabled     = needsMorePower || notActicated || alreadyOverdriving;
            string disabledReason = "";

            if (isDisabled)
            {
                if (alreadyOverdriving)
                {
                    disabledReason = "WTH_Reason_AlreadyOverdriving".Translate();
                }
                else if (needsMorePower)
                {
                    disabledReason = "WTH_Reason_NeedsMorePower".Translate(new object[] { modExt.powerDrain });
                }
                else if (notActicated)
                {
                    disabledReason = "WTH_Reason_NotActivated".Translate();
                }
            }

            Gizmo gizmo = new Command_Action
            {
                defaultLabel   = "WTH_Gizmo_Overdrive_Label".Translate(),
                defaultDesc    = "WTH_Gizmo_Overdrive_Description".Translate(),
                icon           = ContentFinder <Texture2D> .Get(("Things/" + "OverdriveModule"), true),
                disabled       = isDisabled,
                disabledReason = disabledReason,
                action         = delegate
                {
                    Job job = new Job(WTH_DefOf.WTH_Ability_Overdrive, __instance);
                    __instance.jobs.StartJob(job, JobCondition.InterruptForced);
                }
            };

            return(gizmo);
        }
示例#5
0
        private static Gizmo CreateGizmo_SelfDestruct(Pawn pawn, ExtendedPawnData pawnData)
        {
            Need_Power powerNeed = pawn.needs.TryGetNeed <Need_Power>();

            JobDef jobDef = WTH_DefOf.WTH_Ability_SelfDestruct;
            DefModExtension_Ability modExt = jobDef.GetModExtension <DefModExtension_Ability>();

            bool   needsMorePower = powerNeed.CurLevel < modExt.powerDrain;
            bool   notActicated   = !pawn.IsActivated();
            bool   isDisabled     = needsMorePower || notActicated;
            string disabledReason = "";

            if (isDisabled)
            {
                if (notActicated)
                {
                    disabledReason = "WTH_Reason_NotActivated".Translate();
                }
                else if (needsMorePower)
                {
                    disabledReason = "WTH_Reason_NeedsMorePower".Translate(new object[] { modExt.powerDrain });
                }
            }

            Gizmo gizmo = new Command_Action
            {
                defaultLabel   = "WTH_Gizmo_SelfDestruct_Label".Translate(),
                defaultDesc    = "WTH_Gizmo_SelfDestruct_Description".Translate(),
                icon           = ContentFinder <Texture2D> .Get(("UI/" + "Detonate"), true),
                disabled       = isDisabled,
                disabledReason = disabledReason,
                action         = delegate
                {
                    Job job = new Job(WTH_DefOf.WTH_Ability_SelfDestruct, pawn);
                    pawn.jobs.StartJob(job, JobCondition.InterruptForced);
                }
            };

            return(gizmo);
        }