public static bool DrawThingRow(object tab, ref float y, ref float width, Thing thing, bool inventory) { if (!Settings.gui_manual_unload) { return(true); } Pawn SelPawn = (Pawn)ITab_Pawn_Gear_Utility.LSelPawnForGear.GetValue(tab); bool CanControl = (bool)ITab_Pawn_Gear_Utility.LCanControl.GetValue(tab); Color hColor = new Color(1f, 0.8f, 0.8f, 1f); //Log.Message($"CanControl={CanControl}, pc={SelPawn.IsColonistPlayerControlled}, spawned={SelPawn.Spawned}, pcHome={SelPawn.Map.IsPlayerHome}, bcoded={IsBiocodedOrLinked(SelPawn, thing, inventory)}, locked={IsLocked(SelPawn, thing)}"); Rect rect = new Rect(0f, y, width, 28f); if ((thing is ThingWithComps) && CanControl && (inventory || SelPawn.IsColonistPlayerControlled || SelPawn.Spawned && !SelPawn.Map.IsPlayerHome) && !IsBiocodedOrLinked(SelPawn, thing, inventory) && !IsLocked(SelPawn, 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()); 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(SelPawn, null) < MassUtility.GearAndInventoryMass(SelPawn) && thing.stackCount * thing.GetStatValue(StatDefOf.Mass, true) > 0 && !thing.def.destroyOnDrop) { ITab_Pawn_Gear_Utility.LInterfaceDrop.Invoke(tab, new object[] { thing }); } } GUI.color = cl; } else { TooltipHandler.TipRegion(rect2, "UnloadThing".Translate()); var cl = GUI.color; if (Widgets.ButtonImage(rect2, ContentFinder <Texture2D> .Get("UI/Icons/Unload_Thing"), Color.white)) { SoundDefOf.Tick_High.PlayOneShotOnCamera(null); c.ShouldUnload = true; } } width -= 24f; } return(true); }
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); }
static void Postfix(ThingOwner <Thing> __instance, bool __result, Thing item) { if (!__result || item.Destroyed || item.stackCount == 0) { return; } if (__instance.Owner is Pawn_InventoryTracker) { CompUnloadChecker.GetChecker(__instance[__instance.Count - 1], false, true); } }
static void Postfix(ThingOwner __instance) { if (__instance.Owner is Pawn_InventoryTracker && Scribe.mode == LoadSaveMode.PostLoadInit) { for (int i = 0; i < __instance.Count; i++) { if (__instance[i] != null) { CompUnloadChecker.GetChecker(__instance[i], false, true); } } } }
static void Postfix(ThingWithComps __instance) { if (Scribe.mode == LoadSaveMode.LoadingVars) { bool a = false; bool b = false; Scribe_Values.Look(ref a, "CommonSenseShouldUnload", defaultValue: false); Scribe_Values.Look(ref b, "CommonSenseWasInInventory", defaultValue: false); if (a || b) { CompUnloadChecker.GetChecker(__instance, a, b); } } }
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); }
public static bool DrawThingRow(Pawn SelPawn, bool CanControl, ref float y, ref float width, Thing thing, bool inventory) { Color hColor = new Color(1f, 0.8f, 0.8f, 1f); bool IsBiocodedOrLinked(Pawn pawn, Thing athing, bool ainventory) { if (pawn.IsQuestLodger()) { if (ainventory) { return(true); } else { CompBiocodable compBiocodable = athing.TryGetComp <CompBiocodable>(); if (compBiocodable != null && compBiocodable.Biocoded) { return(true); } else { CompBladelinkWeapon compBladelinkWeapon = athing.TryGetComp <CompBladelinkWeapon>(); return(compBladelinkWeapon != null && compBladelinkWeapon.bondedPawn == pawn); } } } else { return(false); } } bool IsLocked(Pawn pawn, Thing athing) { Apparel apparel; return((apparel = (athing as Apparel)) != null && pawn.apparel != null && pawn.apparel.IsLocked(apparel)); } if (!Settings.gui_manual_unload) { return(true); } Rect rect = new Rect(0f, y, width, 28f); if (CanControl && (SelPawn.IsColonistPlayerControlled || SelPawn.Spawned && !SelPawn.Map.IsPlayerHome) && (thing is ThingWithComps) && !IsBiocodedOrLinked(SelPawn, thing, inventory) && !IsLocked(SelPawn, 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(SelPawn, null) < MassUtility.GearAndInventoryMass(SelPawn) && thing.stackCount * thing.GetStatValue(StatDefOf.Mass, true) > 0 && !thing.def.destroyOnDrop) { Thing t; SelPawn.inventory.innerContainer.TryDrop(thing, SelPawn.Position, SelPawn.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); }