Example #1
0
 public static void Postfix(Vector3 clickPos, Pawn pawn, List <FloatMenuOption> opts)
 {
     if (pawn.RaceProps.Humanlike && pawn.TryGetComp <CompKnowledge>() != null)
     {
         IntVec3        c         = IntVec3.FromVector3(clickPos);
         ThingWithComps equipment = null;
         List <Thing>   thingList = c.GetThingList(pawn.Map);
         for (int i = 0; i < thingList.Count; i++)
         {
             if (thingList[i].TryGetComp <CompEquippable>() != null)
             {
                 equipment = (ThingWithComps)thingList[i];
                 break;
             }
         }
         if (equipment != null && equipment.def.IsWeapon && !HarmonyPatches.CheckKnownWeapons(pawn, equipment))
         {
             string labelShort = equipment.LabelShort;
             int    Index      = opts.FindIndex(x => x.Label.Contains(labelShort));
             if (Index != -1)
             {
                 string          flavoredExplanation = ModBaseHumanResources.unlocked.weapons.Contains(equipment.def) ? "UnknownWeapon".Translate(pawn) : "EvilWeapon".Translate(pawn);
                 FloatMenuOption item = new FloatMenuOption("CannotEquip".Translate(labelShort) + " (" + flavoredExplanation + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null);
                 opts.RemoveAt(Index);
                 opts.Add(item);
             }
         }
     }
 }
 public static bool Prefix(Thing item, IThingHolder ___owner)
 {
     if (item.def.IsWeapon && ___owner is Pawn_EquipmentTracker gear)
     {
         Pawn pawn = (Pawn)pawnInfo.GetValue(gear);
         return(HarmonyPatches.CheckKnownWeapons(pawn, item));
     }
     return(true);
 }
Example #3
0
 public static bool GetEquipOffHandOption_Prefix(Pawn pawn, ThingWithComps equipment)
 {
     if (pawn.RaceProps.Humanlike && pawn.Faction != null && pawn.Faction.IsPlayer && pawn.TryGetComp <CompKnowledge>() != null)
     {
         return(HarmonyPatches.CheckKnownWeapons(pawn, equipment));
     }
     else
     {
         return(true);
     }
 }
 public static bool Prefix(Thing newWep, Pawn pawn)
 {
     if (pawn.Faction != null && pawn.Faction.IsPlayer && pawn.RaceProps.Humanlike && pawn.TryGetComp <CompKnowledge>() != null)
     {
         return(HarmonyPatches.CheckKnownWeapons(pawn, newWep));
     }
     else
     {
         return(true);
     }
 }
Example #5
0
 public static bool Prefix(Job job, Pawn ___pawn)
 {
     if (___pawn.RaceProps.Humanlike && ___pawn.Faction != null && ___pawn.Faction.IsPlayer && ___pawn.TryGetComp <CompKnowledge>() != null && job.def == JobDefOf.Equip)
     {
         return(HarmonyPatches.CheckKnownWeapons(___pawn, job.targetA.Thing));
     }
     else
     {
         return(true);
     }
 }
 public static bool equipSpecificWeapon_Prefix(Pawn pawn, ThingWithComps weapon)
 {
     if (pawn.RaceProps.Humanlike && pawn.Faction != null && pawn.Faction.IsPlayer && pawn.TryGetComp <CompKnowledge>() != null)
     {
         return(HarmonyPatches.CheckKnownWeapons(pawn, weapon));
     }
     else
     {
         return(true);
     }
 }
Example #7
0
 public static bool equipSpecificWeapon_Prefix(Pawn pawn, ThingWithComps weapon)
 {
     //Thanks to Andy Brenneke for figuring out sometimes SS equips null weapons!
     if (weapon != null && pawn.RaceProps.Humanlike && pawn.Faction != null && pawn.Faction.IsPlayer && pawn.TryGetComp <CompKnowledge>() != null)
     {
         return(HarmonyPatches.CheckKnownWeapons(pawn, weapon));
     }
     else
     {
         return(true);
     }
 }
Example #8
0
 public static bool canCarrySidearmÌnstance_Prefix(ThingWithComps sidearmThing, Pawn pawn, out string errString)
 {
     errString = ModBaseHumanResources.unlocked.weapons.Contains(sidearmThing.def) ? "UnknownWeapon".Translate() : "EvilWeapon".Translate();
     if (pawn.RaceProps.Humanlike && pawn.Faction != null && pawn.Faction.IsPlayer && pawn.TryGetComp <CompKnowledge>() != null)
     {
         return(HarmonyPatches.CheckKnownWeapons(pawn, sidearmThing));
     }
     else
     {
         return(true);
     }
 }
 public static bool Prefix(Thing thing, Pawn pawn, out string cantReason)
 {
     cantReason = "UnknownWeapon".Translate(pawn);
     if (pawn.RaceProps.Humanlike && pawn.TryGetComp <CompKnowledge>() != null)
     {
         return(HarmonyPatches.CheckKnownWeapons(pawn, thing));
     }
     else
     {
         return(true);
     }
 }
Example #10
0
        public static bool Prefix(Thing thing, Pawn pawn, out string cantReason)
        {
            ThingWithComps equipment = null;

            if (thing.TryGetComp <CompEquippable>() != null)
            {
                equipment = thing as ThingWithComps;
            }
            if (pawn.Faction != null && pawn.Faction.IsPlayer && pawn.RaceProps.Humanlike && equipment != null && equipment.def.IsWeapon && !HarmonyPatches.CheckKnownWeapons(pawn, equipment))
            {
                cantReason = ModBaseHumanResources.unlocked.weapons.Contains(equipment.def) ? "UnknownWeapon".Translate() : "EvilWeapon".Translate();
                return(false);
            }
            cantReason = null;
            return(true);
        }