コード例 #1
0
        // RimWorld.Pawn_ApparelTracker
        public static bool InterfaceDrop_PreFix(ITab_Pawn_Gear __instance, Thing t)
        {
            ThingWithComps thingWithComps = t as ThingWithComps;
            Apparel        apparel        = t as Apparel;
            Pawn           __pawn         = (Pawn)AccessTools.Method(typeof(ITab_Pawn_Gear), "get_SelPawnForGear").Invoke(__instance, new object[0]);

            if (__pawn != null)
            {
                if (apparel != null)
                {
                    if (__pawn.apparel != null)
                    {
                        if (__pawn.apparel.WornApparel.Contains(apparel))
                        {
                            if (__pawn.apparel.WornApparel != null)
                            {
                                CompInstalledPart installedPart = apparel.GetComp <CompInstalledPart>();
                                if (installedPart != null)
                                {
                                    if (!installedPart.uninstalled)
                                    {
                                        return(false);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(true);
        }
コード例 #2
0
 public static void InterfaceDrop(ITab_Pawn_Gear __instance, Thing t)
 {
     if (t.def.IsMeleeWeapon || t.def.IsRangedWeapon)
     {
         ThingWithComps thingWithComps = t as ThingWithComps;
         ThingOwner     thingOwner     = thingWithComps.holdingOwner;
         IThingHolder   actualOwner    = thingOwner.Owner;
         if (actualOwner is Pawn_InventoryTracker)
         {
             CompSidearmMemory pawnMemory = CompSidearmMemory.GetMemoryCompForPawn((actualOwner as Pawn_InventoryTracker).pawn);
             if (pawnMemory == null)
             {
                 return;
             }
             pawnMemory.InformOfDroppedSidearm(thingWithComps, true);
         }
         else if (actualOwner is Pawn_EquipmentTracker)
         {
             CompSidearmMemory pawnMemory = CompSidearmMemory.GetMemoryCompForPawn((actualOwner as Pawn_EquipmentTracker).ParentHolder as Pawn);
             if (pawnMemory == null)
             {
                 return;
             }
             pawnMemory.InformOfDroppedSidearm(thingWithComps, true);
         }
     }
 }
コード例 #3
0
        public static bool Prefix(ITab_Pawn_Gear __instance, ref float y, ref float width, Thing thing, bool inventory)
        {
            bool CanControl     = Traverse.Create(__instance).Property("CanControl").GetValue <bool>();
            Pawn SelPawnForGear = Traverse.Create(__instance).Property("SelPawnForGear").GetValue <Pawn>();

            return(Utility.DrawThingRow(SelPawnForGear, CanControl, ref y, ref width, thing, inventory));
        }
コード例 #4
0
ファイル: Intercepts_UI.cs プロジェクト: Nylux/SimpleSidearms
 private static void InterfaceDrop(ITab_Pawn_Gear __instance, Thing t)
 {
     if (t.def.IsMeleeWeapon || t.def.IsRangedWeapon)
     {
         ThingWithComps thingWithComps = t as ThingWithComps;
         ThingOwner     thingOwner     = thingWithComps.holdingOwner;
         IThingHolder   actualOwner    = thingOwner.Owner;
         if (actualOwner is Pawn_InventoryTracker)
         {
             GoldfishModule pawnMemory = GoldfishModule.GetGoldfishForPawn((actualOwner as Pawn_InventoryTracker).pawn);
             if (pawnMemory == null)
             {
                 return;
             }
             pawnMemory.DropSidearm(thingWithComps.def, true);
         }
         else if (actualOwner is Pawn_EquipmentTracker)
         {
             GoldfishModule pawnMemory = GoldfishModule.GetGoldfishForPawn((actualOwner as Pawn_EquipmentTracker).ParentHolder as Pawn);
             if (pawnMemory == null)
             {
                 return;
             }
             pawnMemory.DropPrimary(true);
         }
     }
 }
コード例 #5
0
        public static bool Prefix(ITab_Pawn_Gear __instance, Thing t)
        {
            if (GameAttackTrigger_Patch.ActiveAttacker.Count == 0)
            {
                return(true);
            }
            var pawn = (t.ParentHolder as Pawn_InventoryTracker)?.pawn;

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

            //Если дропается вещь не из инвентаря (например оружие или одежда), то это делается джобом а не здесь
            if (!pawn.inventory.innerContainer.Any(tt => tt == t))
            {
                return(true);
            }

            GameAttacker client;

            if (GameAttackTrigger_Patch.ActiveAttacker.TryGetValue(pawn.Map, out client))
            {
                return(client.UIEventInventoryDrop(t));
            }
            return(true);
        }
コード例 #6
0
            public static bool Prefix(ITab_Pawn_Gear __instance, Thing t)
            {
                var SelPawnForGear = Traverse.Create(__instance).Property("SelPawnForGear").GetValue <Pawn>();

                var preventDrop = SelPawnForGear.HostFaction == Faction.OfPlayer && !SelPawnForGear.IsPrisoner;

                return(!preventDrop);
            }
コード例 #7
0
 private static void SyncITab(SyncWorker sync, ref ITab_Pawn_Gear gearITab)
 {
     if (sync.isWriting)
     {
         sync.Write(gearITab.GetType());
     }
     else
     {
         gearITab = (ITab_Pawn_Gear)InspectTabManager.GetSharedInstance(sync.Read <Type>());
     }
 }
コード例 #8
0
        public static void Postfix(Thing t, ITab_Pawn_Gear __instance)
        {
            if (!Settings.Get().stockUp)
            {
                return;
            }

            Pawn pawn = (Pawn)SelPawnForGearInfo.GetValue(__instance, new object[] { });

            pawn.StockUpStop(t);
        }
コード例 #9
0
            public static bool Prefix(ITab_Pawn_Gear __instance, ref float y, ref float width, Thing thing, ref bool inventory)
            {
                Pawn SelPawnForGear = Traverse.Create(__instance).Property("SelPawnForGear").GetValue<Pawn>();
                Corpse corpse = SelPawnForGear.Corpse;

                inventory = inventory && corpse == null;

                if (SelPawnForGear.Downed || corpse != null || SelPawnForGear.IsPrisoner && SelPawnForGear.guest.PrisonerIsSecure)
                {
                    CompStripChecker c = CompStripChecker.GetChecker(thing, false);
                    if (c == null)
                    {
                        width -= 24f;
                        return true;
                    }

                    ThingWithComps holder = corpse == null ? SelPawnForGear : (ThingWithComps)corpse;
                    Rect rect = new Rect(0f, y, width, 28f);

                    Rect rect2 = new Rect(rect.width - 24f, y, 24f, 24f);

                    if (c.ShouldStrip)
                    {
                        TooltipHandler.TipRegion(rect2, "StripThingCancel".Translate());

                        //weird shenanigans with colors
                        var cl = GUI.color;
                        if (Widgets.ButtonImage(rect2, ContentFinder<Texture2D>.Get("UI/Icons/Strip_Thing_Cancel"), hColor))
                        {
                            SoundDefOf.Tick_High.PlayOneShotOnCamera(null);
                            c.ShouldStrip = false;
                            if (CompStripChecker.getFirstMarked(SelPawnForGear) == null && holder.Map != null)
                            {
                                Designation d = holder.Map.designationManager.DesignationOn(holder, DesignationDefOf.Strip);
                                if (d != null) holder.Map.designationManager.RemoveDesignation(d);
                            }
                        }
                        GUI.color = cl;
                    }
                    else
                    {
                        TooltipHandler.TipRegion(rect2, "StripThing".Translate());
                        if (Widgets.ButtonImage(rect2, ContentFinder<Texture2D>.Get("UI/Icons/Strip_Thing")))
                        {
                            SoundDefOf.Tick_High.PlayOneShotOnCamera(null);
                            bool b = CompStripChecker.getFirstMarked(SelPawnForGear) == null && holder.Map.designationManager.DesignationOn(holder, DesignationDefOf.Strip) == null;
                            c.ShouldStrip = true;
                            if (b) holder.Map.designationManager.AddDesignation(new Designation(holder, DesignationDefOf.Strip));
                        }
                    }
                    width -= 24f;
                }
                return true;
            }
コード例 #10
0
        static bool Prefix(ITab_Pawn_Gear __instance, Thing t)
        {
            Pawn pawn = Traverse.Create(__instance).Property("SelPawnForGear").GetValue <Pawn>();

            if (pawn != null && pawn.IsHacked() && pawn.equipment != null && pawn.equipment.Primary == t)
            {
                Messages.Message("WTH_Message_CannotDrop".Translate(), MessageTypeDefOf.RejectInput);
                return(false);
            }
            return(true);
        }
コード例 #11
0
        public static bool Prefix(ITab_Pawn_Gear __instance, ref float y, ref float width, Thing thing, bool inventory)
        {
            if (!Settings.gui_manual_unload)
            {
                return(true);
            }

            bool CanControl     = Traverse.Create(__instance).Property("CanControl").GetValue <bool>();
            Pawn SelPawnForGear = Traverse.Create(__instance).Property("SelPawnForGear").GetValue <Pawn>();
            Rect rect           = new Rect(0f, y, width, 28f);

            if (CanControl &&
                (SelPawnForGear.IsColonistPlayerControlled || SelPawnForGear.Spawned && !SelPawnForGear.Map.IsPlayerHome) &&
                (thing is ThingWithComps) &&
                !IsBiocodedOrLinked(SelPawnForGear, thing, inventory) &&
                !IsLocked(SelPawnForGear, thing))
            {
                Rect rect2          = new Rect(rect.width - 24f, y, 24f, 24f);
                CompUnloadChecker c = CompUnloadChecker.GetChecker(thing, false, true);
                if (c.ShouldUnload)
                {
                    TooltipHandler.TipRegion(rect2, "UnloadThingCancel".Translate());

                    //weird shenanigans with colors
                    var cl = GUI.color;
                    if (Widgets.ButtonImage(rect2, ContentFinder <Texture2D> .Get("UI/Icons/Unload_Thing_Cancel"), hColor))
                    {
                        SoundDefOf.Tick_High.PlayOneShotOnCamera(null);
                        c.ShouldUnload = false;

                        if (MassUtility.Capacity(SelPawnForGear, null) < MassUtility.GearAndInventoryMass(SelPawnForGear) &&
                            thing.stackCount * thing.GetStatValue(StatDefOf.Mass, true) > 0 &&
                            !thing.def.destroyOnDrop)
                        {
                            Thing t;
                            SelPawnForGear.inventory.innerContainer.TryDrop(thing, SelPawnForGear.Position, SelPawnForGear.Map, ThingPlaceMode.Near, out t, null, null);
                        }
                    }
                    GUI.color = cl;
                }
                else
                {
                    TooltipHandler.TipRegion(rect2, "UnloadThing".Translate());
                    if (Widgets.ButtonImage(rect2, ContentFinder <Texture2D> .Get("UI/Icons/Unload_Thing")))
                    {
                        SoundDefOf.Tick_High.PlayOneShotOnCamera(null);
                        c.ShouldUnload = true;
                    }
                }
                width -= 24f;
            }
            return(true);
        }
コード例 #12
0
 public static bool InterfaceDrop(Thing t, ITab_Pawn_Gear __instance)
 {
     if (use_native)
     {
         return(true);
     }
     else
     {
         Pawn p = (Pawn)__instance.GetType().GetMethod("get_SelPawnForGear", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(__instance, new object[] { });
         DropGear(t, p);
         return(false);
     }
 }
コード例 #13
0
        public static bool InterfaceDrop(ITab_Pawn_Gear __instance, Thing t)
        {
            if (!Event.current.control || t.stackCount < 2)
            {
                return(true);
            }

            Pawn selPawnForGear = __instance.SelPawnForGear; // Traverse.Create(__instance).Property("SelPawnForGear", null).GetValue<Pawn>();

            ThingWithComps thingWithComps = t as ThingWithComps;

            if (t is Apparel apparel && selPawnForGear.apparel != null && selPawnForGear.apparel.WornApparel.Contains(apparel))
            {
                // RemoveApparel
            }
コード例 #14
0
 // RimWorld.Pawn_ApparelTracker
 public static bool InterfaceDrop_PreFix(ITab_Pawn_Gear __instance, Thing t)
 {
     if (t is Apparel apparel)
     {
         var pawn = itabPawnGearSelPawnForGearGetter(__instance);
         if (pawn?.apparel?.WornApparel.Contains(apparel) ?? false)
         {
             var installedPart = apparel.GetCompInstalledPart();
             if (installedPart != null)
             {
                 if (!installedPart.uninstalled)
                 {
                     return(false);
                 }
             }
         }
     }
     return(true);
 }
コード例 #15
0
        //=================================== COMPSLOTLOADABLE

        public static void DrawThingRow_PostFix(ITab_Pawn_Gear __instance, ref float y, float width, Thing thing,
                                                bool inventory = false)
        {
            //Log.Message("1");
            if (thing is ThingWithComps thingWithComps)
            {
                var comp = thingWithComps.AllComps.FirstOrDefault(x => x is CompSlotLoadable);
                if (comp != null)
                {
                    var compSlotLoadable = comp as CompSlotLoadable;
                    if (compSlotLoadable.Slots != null && compSlotLoadable.Slots.Count > 0)
                    {
                        foreach (var slot in compSlotLoadable.Slots)
                        {
                            if (!slot.IsEmpty())
                            {
                                var rect = new Rect(0f, y, width, 28f);
                                Widgets.InfoCardButton(rect.width - 24f, y, slot.SlotOccupant);
                                rect.width -= 24f;
                                //bool CanControl = (bool)AccessTools.Method(typeof(ITab_Pawn_Gear), "get_CanControl").Invoke(__instance, null);
                                if (Mouse.IsOver(rect))
                                {
                                    GUI.color = HighlightColor;
                                    GUI.DrawTexture(rect, TexUI.HighlightTex);
                                }
                                if (slot.SlotOccupant.def.DrawMatSingle != null &&
                                    slot.SlotOccupant.def.DrawMatSingle.mainTexture != null)
                                {
                                    Widgets.ThingIcon(new Rect(4f, y, 28f, 28f), slot.SlotOccupant, 1f);
                                }
                                Text.Anchor = TextAnchor.MiddleLeft;
                                GUI.color   = ThingLabelColor;
                                var rect4 = new Rect(36f, y, width - 36f, 28f);
                                var text  = slot.SlotOccupant.LabelCap;
                                Widgets.Label(rect4, text);
                                y += 28f;
                            }
                        }
                    }
                }
            }
        }
コード例 #16
0
        public static bool Prefix(ITab_Pawn_Gear __instance, ref float y, ref float width, Thing thing, bool inventory = false)
        {
            if (!Settings.gui_manual_unload)
            {
                return(true);
            }

            bool CanControlColonist = Traverse.Create(__instance).Property("CanControlColonist").GetValue <bool>();
            Rect rect = new Rect(0f, y, width, 28f);

            if (CanControlColonist && (thing is ThingWithComps))
            {
                Rect rect2          = new Rect(rect.width - 24f, y, 24f, 24f);
                CompUnloadChecker c = CompUnloadChecker.GetChecker(thing, false, true);
                if (c.ShouldUnload)
                {
                    TooltipHandler.TipRegion(rect2, "UnloadThingCancel".Translate());

                    //weird shenanigans with colors
                    var cl = GUI.color;
                    if (Widgets.ButtonImage(rect2, ContentFinder <Texture2D> .Get("UI/Icons/Unload_Thing_Cancel"), hColor))
                    {
                        SoundDefOf.Tick_High.PlayOneShotOnCamera(null);
                        c.ShouldUnload = false;
                    }
                    GUI.color = cl;
                }
                else
                {
                    TooltipHandler.TipRegion(rect2, "UnloadThing".Translate());
                    if (Widgets.ButtonImage(rect2, ContentFinder <Texture2D> .Get("UI/Icons/Unload_Thing")))
                    {
                        SoundDefOf.Tick_High.PlayOneShotOnCamera(null);
                        c.ShouldUnload = true;
                    }
                }
            }
            width -= 24f;
            return(true);
        }
コード例 #17
0
        // RimWorld.ITab_Pawn_Gear

        /*
         *  PreFix
         *
         *  Disables the drop button's effect if the user is wearing a straitjacket.
         *  A straitjacket user should not be able to take it off by themselves, right?
         *
         */
        public static bool InterfaceDropPreFix(ITab_Pawn_Gear __instance, Thing t)
        {
            ThingWithComps thingWithComps = t as ThingWithComps;
            Apparel        apparel        = t as Apparel;
            Pawn           __pawn         = (Pawn)AccessTools.Method(typeof(ITab_Pawn_Gear), "get_SelPawnForGear").Invoke(__instance, new object[0]);

            if (__pawn != null)
            {
                if (apparel != null && __pawn.apparel != null && __pawn.apparel.WornApparel.Contains(apparel))
                {
                    if (apparel.def == StraitjacketDefOf.ROM_Straitjacket)
                    {
                        Messages.Message("CannotRemoveByOneself".Translate(new object[]
                        {
                            __pawn.Label
                        }), MessageTypeDefOf.RejectInput);//MessageSound.RejectInput);
                        return(false);
                    }
                }
            }
            return(true);
        }
コード例 #18
0
ファイル: patches_bondage_gear.cs プロジェクト: deanec64/RJW
        private static bool drop_locked_apparel(ITab_Pawn_Gear __instance, Thing t)
        {
            var tab = __instance;
            var app = t as Apparel;

            if ((app == null) || (!app.has_lock()))
            {
                return(true);
            }
            else
            {
                var p = SelPawnForGear(tab);
                if ((p.apparel != null) && (p.apparel.WornApparel.Contains(app)))
                {
                    p.jobs.TryTakeOrderedJob(new Job(DefDatabase <JobDef> .GetNamed("StruggleInBondageGear"), app));
                    return(false);
                }
                else
                {
                    return(true);
                }
            }
        }
コード例 #19
0
        private static bool drop_locked_apparel(ITab_Pawn_Gear __instance, Thing t)
        {
            var tab     = __instance;
            var apparel = t as Apparel;

            if ((apparel == null) || (!apparel.has_lock()))
            {
                return(true);
            }
            else
            {
                var p = SelPawnForGear(tab);
                if ((p.apparel != null) && (p.apparel.WornApparel.Contains(apparel)))
                {
                    p.jobs.TryTakeOrderedJob(JobMaker.MakeJob(xxx.struggle_in_BondageGear, apparel));
                    return(false);
                }
                else
                {
                    return(true);
                }
            }
        }
コード例 #20
0
 public static bool Prefix(ITab_Pawn_Gear __instance, ref float y, ref float width, Thing thing, bool inventory)
 {
     return(Utility.DrawThingRow(__instance, ref y, ref width, thing, inventory));
 }
コード例 #21
0
        public static void Prefix(ITab_Pawn_Gear __instance, ref float y, ref float width, Thing thing, ref bool inventory)
        {
            Pawn SelPawnForGear = Traverse.Create(__instance).Property("SelPawnForGear").GetValue <Pawn>();

            NUPUtility.DrawThingRow(SelPawnForGear, ref y, ref width, thing, ref inventory);
        }
コード例 #22
0
        // Token: 0x0600005E RID: 94 RVA: 0x00004878 File Offset: 0x00002A78
        public static void IsVisible_Prefix(ref bool __result, ITab_Pawn_Gear __instance)
        {
            Pawn value = Traverse.Create(__instance).Property("SelPawnForGear", null).GetValue <Pawn>();

            __result = (value.RaceProps.ToolUser || value.inventory.innerContainer.Count > 0 || value.equipment != null);
        }
コード例 #23
0
ファイル: patches_bondage_gear.cs プロジェクト: deanec64/RJW
        private static Pawn SelPawnForGear(ITab_Pawn_Gear tab)
        {
            var pro = typeof(ITab_Pawn_Gear).GetProperty("SelPawnForGear", xxx.ins_public_or_no);

            return((Pawn)pro.GetValue(tab, null));
        }