diff --git a/1.3/Assemblies/Locks.dll b/1.3/Assemblies/Locks.dll index 6acc4ef..6b702e3 100644 Binary files a/1.3/Assemblies/Locks.dll and b/1.3/Assemblies/Locks.dll differ diff --git a/About/About.xml b/About/About.xml index dba82a1..b07752c 100644 --- a/About/About.xml +++ b/About/About.xml @@ -20,5 +20,5 @@ https://github.com/pardeike/HarmonyRimWorld/releases/latest - Version 2.6.0\nThis addon adds Lock command on every door.\n - Left-click to lock toggle.\n - Right click for more options\n - Alternatively you can use "Lock" inspector tab\n\nNote: Door lock must be flicked by colonist. + Version 2.6.1\nThis addon adds Lock command on every door.\n - Left-click to lock toggle.\n - Right click for more options\n - Alternatively you can use "Lock" inspector tab\n\nNote: Door lock must be flicked by colonist. diff --git a/Languages/English/Keyed/Keys.xml b/Languages/English/Keyed/Keys.xml index 83db01e..fe1b655 100644 --- a/Languages/English/Keyed/Keys.xml +++ b/Languages/English/Keyed/Keys.xml @@ -14,6 +14,8 @@ When disabled, allies and traders will not be allowed to pass through this door. This setting do not apply when owners are set. Pet door When enabled small animals, like dogs can pass through door. This setting is not required for doors without owners. + Pens door + When enabled door will work as pens door. This setting is not required for doors without owners. Owners Change lock in order to apply settings! @@ -23,6 +25,8 @@ Forbid visitors from using Add pet door Remove pet door + Set as pens door + Remove pens door Set owners Clear owners diff --git a/README.md b/README.md index 6f5d07c..84e4866 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@

- v2.6.0 + v2.6.1

diff --git a/Source/ITab_Lock.cs b/Source/ITab_Lock.cs index adfa0ce..0c194c2 100644 --- a/Source/ITab_Lock.cs +++ b/Source/ITab_Lock.cs @@ -17,7 +17,7 @@ public class ITab_Lock : ITab private static readonly Vector2 WinSize = new Vector2(310f + WindowGap, ButtonsHeight + OwnersWindowHeight + OwnersTitleHeight + MainSettingsHeight + WindowGap + 2 * Spacing + WarningHeight); private const float ButtonsHeight = 25f; private const float WindowGap = 15f; - private const float MainSettingsHeight = 3 * 32f; + private const float MainSettingsHeight = 4 * 32f; private const float OwnersTitleHeight = 24f; private const float OwnersWindowHeight = 200f; private const float WarningHeight = 24f; @@ -27,6 +27,7 @@ public class ITab_Lock : ITab private bool locked; private bool vistitorsAllowed; private bool petDoor; + private bool pensDoor; private Thing lastSelectedThing; @@ -56,12 +57,12 @@ public LockData Data protected override void FillTab() { Rect mainRect = new Rect(0f, 0f, ITab_Lock.WinSize.x, ITab_Lock.WinSize.y).ContractedBy(WindowGap); - Rect upperSettingsRect = new Rect(0f, 0f, mainRect.width, MainSettingsHeight); - Rect ownersTitleRect = new Rect(0f, mainRect.height - OwnersWindowHeight - OwnersTitleHeight - WarningHeight - 2* Spacing - ButtonsHeight, mainRect.width, OwnersTitleHeight); - Rect ownersListRect = new Rect(0f, mainRect.height - OwnersWindowHeight - WarningHeight - 2*Spacing- ButtonsHeight, mainRect.width, OwnersWindowHeight); + Rect upperSettingsRect = new Rect(0f, 0f + WindowGap, mainRect.width, MainSettingsHeight); + Rect ownersTitleRect = new Rect(0f, mainRect.height - OwnersWindowHeight - OwnersTitleHeight - WarningHeight - 2 * Spacing - ButtonsHeight, mainRect.width, OwnersTitleHeight); + Rect ownersListRect = new Rect(0f, mainRect.height - OwnersWindowHeight - WarningHeight - 2 * Spacing - ButtonsHeight, mainRect.width, OwnersWindowHeight); Rect warningRect = new Rect(0f, mainRect.height - WarningHeight - Spacing - ButtonsHeight, mainRect.width, WarningHeight); Rect cancelButtonRect = new Rect(mainRect.width - ButtonWidth, mainRect.height - WarningHeight, ButtonWidth, WarningHeight); - Rect copyButtonsRect = new Rect(mainRect.width/2 - Spacing - ButtonWidth, mainRect.height - ButtonsHeight, ButtonWidth, ButtonsHeight); + Rect copyButtonsRect = new Rect(mainRect.width / 2 - Spacing - ButtonWidth, mainRect.height - ButtonsHeight, ButtonWidth, ButtonsHeight); Rect pasteButtonsRect = new Rect(mainRect.width / 2 + Spacing, mainRect.height - ButtonsHeight, ButtonWidth, ButtonsHeight); Text.Font = GameFont.Small; float viewRectCalcHeight = (Text.LineHeight + Spacing) * SelDoor.Map.mapPawns.FreeColonists.Count(); @@ -78,6 +79,8 @@ protected override void FillTab() listing.CheckboxLabeled("Locks_ITabVisitorsAllowed".Translate(), ref vistitorsAllowed, "Locks_ITabVisitorsAllowedDesc".Translate()); if (Data.WantedState.IsVisible(nameof(LockState.petDoor))) listing.CheckboxLabeled("Locks_ITabPetDoor".Translate(), ref petDoor, "Locks_ITabPetDoorDesc".Translate()); + if (Data.WantedState.IsVisible(nameof(LockState.pensDoor))) + listing.CheckboxLabeled("Locks_ITabPensDoor".Translate(), ref pensDoor, "Locks_ITabPensDoorDesc".Translate()); listing.End(); if (Data.WantedState.IsVisible(nameof(LockState.owners))) @@ -141,6 +144,7 @@ private void UpdateSettings() Data.WantedState.locked = locked; Data.WantedState.mode = vistitorsAllowed ? LockMode.Allies : LockMode.Colony; Data.WantedState.petDoor = petDoor; + Data.WantedState.pensDoor = pensDoor; if (Data.NeedChange) LockUtility.UpdateLockDesignation(SelDoor); } @@ -156,6 +160,7 @@ public override void OnOpen() locked = Data.WantedState.locked; vistitorsAllowed = Data.WantedState.mode == LockMode.Allies ? true : false; petDoor = Data.WantedState.petDoor; + pensDoor = Data.WantedState.pensDoor; } private void OwnerCheckbox(Rect rect, Pawn pawn) diff --git a/Source/LockData.cs b/Source/LockData.cs index a6dda6e..a39e138 100644 --- a/Source/LockData.cs +++ b/Source/LockData.cs @@ -17,8 +17,8 @@ public class LockData : IExposable public LockData() { - CurrentState = new LockState(LockMode.Allies, true, false, new List()); - WantedState = new LockState(LockMode.Allies, true, false, new List()); + CurrentState = new LockState(LockMode.Allies, true, false, false, new List()); + WantedState = new LockState(LockMode.Allies, true, false, false, new List()); } // Utilities diff --git a/Source/LockGizmo.cs b/Source/LockGizmo.cs index 538ae99..3459325 100644 --- a/Source/LockGizmo.cs +++ b/Source/LockGizmo.cs @@ -72,6 +72,12 @@ private void InvertPetDoorFloatMenu(Building_Door door, bool value) LockUtility.UpdateLockDesignation(door); } + [SyncMethod] + private void InvertPensDoorFloatMenu(Building_Door door, bool value) + { + LockUtility.GetData(door).WantedState.pensDoor = value; + LockUtility.UpdateLockDesignation(door); + } [SyncMethod] private void SetOwnersFloatMenu(Building_Door door) { @@ -142,6 +148,23 @@ public List GetMenuOptions() }) )); } + + if (LockUtility.GetData(parent).WantedState.IsVisible(nameof(LockState.pensDoor))) + { + list.Add(new FloatMenuOption( + LockUtility.GetData(parent).WantedState.pensDoor ? + "Locks_RemovePensDoor".Translate() : + "Locks_AddPensDoor".Translate(), + new Action(() => + { + bool value = !LockUtility.GetData(parent).WantedState.pensDoor; + foreach (Building_Door door in Find.Selector.SelectedObjects.Where(o => o is Building_Door)) + { + InvertPensDoorFloatMenu(door, value); + } + }) + )); + } if (LockUtility.GetData(parent).WantedState.IsVisible(nameof(LockState.owners))) { list.Add(new FloatMenuOption( diff --git a/Source/LockState.cs b/Source/LockState.cs index 1e5bb8a..baaee2c 100644 --- a/Source/LockState.cs +++ b/Source/LockState.cs @@ -17,13 +17,15 @@ public struct LockState public LockMode mode; public bool locked; public bool petDoor; + public bool pensDoor; public List owners; - public LockState(LockMode mode, bool locked, bool petDoor, List owners) + public LockState(LockMode mode, bool locked, bool petDoor, bool pensDoor, List owners) { this.mode = mode; this.locked = locked; this.petDoor = petDoor; + this.pensDoor = pensDoor; this.owners = owners; } @@ -32,6 +34,7 @@ public void CopyFrom(LockState copy) mode = copy.mode; locked = copy.locked; petDoor = copy.petDoor; + pensDoor = copy.pensDoor; owners.Clear(); owners.AddRange(copy.owners); } @@ -44,6 +47,8 @@ public void CopyFrom(LockState copy) return false; if (a.petDoor != b.petDoor) return false; + if (a.pensDoor != b.pensDoor) + return false; foreach (var p in a.owners) if (!b.owners.Contains(p)) return false; @@ -61,6 +66,8 @@ public void CopyFrom(LockState copy) return true; if (a.petDoor != b.petDoor) return true; + if (a.pensDoor != b.pensDoor) + return true; foreach (var p in a.owners) if (!b.owners.Contains(p)) return true; @@ -83,6 +90,7 @@ public void ExposeData(String postfix) Scribe_Values.Look(ref mode, $"Locks_LockData_Mode_{postfix}", LockMode.Allies, false); Scribe_Values.Look(ref locked, $"Locks_LockData_Locked_{postfix}", true, false); Scribe_Values.Look(ref petDoor, $"Locks_LockData_PetDoor_{postfix}", false, false); + Scribe_Values.Look(ref pensDoor, $"Locks_LockData_PensDoor_{postfix}", false, false); Scribe_Collections.Look(ref owners, $"Locks_LockData_Owners_{postfix}", LookMode.Reference); } } diff --git a/Source/LockUtility.cs b/Source/LockUtility.cs index dabb95d..670ab57 100644 --- a/Source/LockUtility.cs +++ b/Source/LockUtility.cs @@ -65,6 +65,15 @@ public static bool PawnCanOpen(Building_Door door, Pawn p) if (p.Faction == null || p.Faction.HostileTo(door.Faction)) return false; + Log.Message($"State check: {respectedState.pensDoor}, { p.RaceProps.FenceBlocked} {!door.def.building.roamerCanOpen} {!p.roping.IsRopedByPawn}"); + if( p.roping.RopedByPawn != null) + { + Log.Message($"{!PawnCanOpen(door, p.roping.RopedByPawn)}"); + } + if (respectedState.pensDoor && p.RaceProps.FenceBlocked && !door.def.building.roamerCanOpen && (!p.roping.IsRopedByPawn || !PawnCanOpen(door, p.roping.RopedByPawn))) + { + return false; + } if (respectedState.Private && respectedState.petDoor && p.RaceProps != null && p.RaceProps.Animal && p.RaceProps.baseBodySize <= MaxPetSize && p.Faction == door.Faction) return true; @@ -125,6 +134,8 @@ public static bool IsVisible(this LockState state, string propertyName) return state.locked && !state.Private; case nameof(LockState.petDoor): return state.locked; + case nameof(LockState.pensDoor): + return state.locked; case nameof(LockState.owners): return state.locked; default: diff --git a/changelog.txt b/changelog.txt index bfc6b56..c52d54a 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,4 +1,6 @@ Changelog: +2.6.1 +- Add option to set door as pens door. Animals should not leave pens now. 2.6.0 - update to Rimworld 1.3 2.5.1