From 862768e3640c419e9b36b369729b375993d8daec Mon Sep 17 00:00:00 2001 From: Thomas Menanteau <91687641+VisualDev-FR@users.noreply.github.com> Date: Mon, 24 Jun 2024 18:25:54 +0200 Subject: [PATCH 1/5] make persistant the upgrade On button + add isPowered to persistant stream --- Harmony/TileEntityEfficientBaseRepair.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Harmony/TileEntityEfficientBaseRepair.cs b/Harmony/TileEntityEfficientBaseRepair.cs index aa20171..f867bd2 100644 --- a/Harmony/TileEntityEfficientBaseRepair.cs +++ b/Harmony/TileEntityEfficientBaseRepair.cs @@ -45,6 +45,8 @@ public class TileEntityEfficientBaseRepair : TileEntitySecureLootContainer //TOD public bool upgradeOn; + public bool isPowered; + private bool forceFullRefresh; private bool forceRefreshMaterials; @@ -590,11 +592,12 @@ public override void read(PooledBinaryReader _br, StreamModeRead _eStreamMode) { base.read(_br, _eStreamMode); isOn = _br.ReadBoolean(); + upgradeOn = _br.ReadBoolean(); + isPowered = _br.ReadBoolean(); if (_eStreamMode == StreamModeRead.Persistency) return; - upgradeOn = _br.ReadBoolean(); forceRefreshMaterials = _br.ReadBoolean(); forceFullRefresh = _br.ReadBoolean(); damagedBlockCount = _br.ReadInt32(); @@ -652,11 +655,12 @@ public override void write(PooledBinaryWriter _bw, StreamModeWrite _eStreamMode) { base.write(_bw, _eStreamMode); _bw.Write(isOn); + _bw.Write(upgradeOn); + _bw.Write(isPowered); if (_eStreamMode == StreamModeWrite.Persistency) return; - _bw.Write(upgradeOn); _bw.Write(forceRefreshMaterials); _bw.Write(forceFullRefresh); _bw.Write(damagedBlockCount); From 84449bc4081721301ac24385a68c8dcf1200abe7 Mon Sep 17 00:00:00 2001 From: Thomas Menanteau <91687641+VisualDev-FR@users.noreply.github.com> Date: Mon, 24 Jun 2024 20:32:51 +0200 Subject: [PATCH 2/5] ocmpiling commit --- CHANGELOG.md | 9 +++++++++ EfficientBaseRepair.csproj | 2 +- Harmony/BlockEfficientBaseRepair.cs | 6 +++--- Harmony/EfficientBaseRepair.cs | 2 +- Scripts/start-local.cmd | 2 +- 5 files changed, 15 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4dac254..689b876 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), ## [Unreleased] +## [1.0.0] - 2024-06-24 + +### Fixed + +- The `upgrade on` button was not persistant, and was set to off at each game restart + +### Changed + ## [0.1.1] - 2024-06-09 ### Fixed @@ -59,6 +67,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), [unreleased]: https://github.com/VisualDev-FR/7D2D-efficient-base-repair/compare/master...unreleased +[1.0.0]: https://github.com/VisualDev-FR/7D2D-efficient-base-repair/compare/0.1.1...1.0.0 [0.1.1]: https://github.com/VisualDev-FR/7D2D-efficient-base-repair/compare/0.1.0...0.1.1 [0.1.0]: https://github.com/VisualDev-FR/7D2D-efficient-base-repair/compare/0.0.3...0.1.0 [0.0.3]: https://github.com/VisualDev-FR/7D2D-efficient-base-repair/compare/0.0.2...0.0.3 diff --git a/EfficientBaseRepair.csproj b/EfficientBaseRepair.csproj index 94e40f7..6815276 100644 --- a/EfficientBaseRepair.csproj +++ b/EfficientBaseRepair.csproj @@ -32,7 +32,7 @@ - $(PATH_7D2D)\7DaysToDie_Data\Managed\0Harmony.dll + $(PATH_7D2D)\Mods\0_TFP_Harmony\0Harmony.dll False diff --git a/Harmony/BlockEfficientBaseRepair.cs b/Harmony/BlockEfficientBaseRepair.cs index 2de76eb..bfbb625 100644 --- a/Harmony/BlockEfficientBaseRepair.cs +++ b/Harmony/BlockEfficientBaseRepair.cs @@ -69,7 +69,7 @@ private void BloodMoonDenied(EntityPlayerLocal _player) } // copied from BlockSecureLoot - public override bool OnBlockActivated(string _commandName, WorldBase _world, int _cIdx, Vector3i _blockPos, BlockValue _blockValue, EntityAlive _player) + public override bool OnBlockActivated(string _commandName, WorldBase _world, int _cIdx, Vector3i _blockPos, BlockValue _blockValue, EntityPlayerLocal _player) { if (_blockValue.ischild) @@ -138,7 +138,7 @@ public override bool OnBlockActivated(string _commandName, WorldBase _world, int } // copied from BlockSecureLoot - public override bool OnBlockActivated(WorldBase _world, int _cIdx, Vector3i _blockPos, BlockValue _blockValue, EntityAlive _player) + public override bool OnBlockActivated(WorldBase _world, int _cIdx, Vector3i _blockPos, BlockValue _blockValue, EntityPlayerLocal _player) { if (_blockValue.ischild) { @@ -195,7 +195,7 @@ private void TakeItemWithTimer(int _cIdx, Vector3i _blockPos, BlockValue _blockV } // copied from BlockWorkStation - private void EventData_Event(TimerEventData timerData) + public new void EventData_Event(TimerEventData timerData) { World world = GameManager.Instance.World; object[] obj = (object[])timerData.Data; diff --git a/Harmony/EfficientBaseRepair.cs b/Harmony/EfficientBaseRepair.cs index a019756..73268d2 100644 --- a/Harmony/EfficientBaseRepair.cs +++ b/Harmony/EfficientBaseRepair.cs @@ -39,7 +39,7 @@ public static bool Prefix(GameManager __instance, TileEntityLootContainer _te, L if (!(_te is TileEntityEfficientBaseRepair)) return true; - FastTags containerTags = FastTags.none; + FastTags containerTags = FastTags.none; if (_playerUI != null) { if (_te.entityId != -1) diff --git a/Scripts/start-local.cmd b/Scripts/start-local.cmd index e7e0981..ec42ca3 100644 --- a/Scripts/start-local.cmd +++ b/Scripts/start-local.cmd @@ -14,6 +14,6 @@ cd %MOD_PATH%\.. taskkill /IM 7DaysToDie.exe /F >nul 2>&1 -start steam://rungameid/251570 +start "" "%PATH_7D2D%\7DaysToDie" -force-d3d11 -disablenativeinput -nogs -noeac exit /b 0 \ No newline at end of file From 6397413c8f908fe3392a670f78293e4d529a41ae Mon Sep 17 00:00:00 2001 From: Thomas Menanteau <91687641+VisualDev-FR@users.noreply.github.com> Date: Mon, 24 Jun 2024 20:41:03 +0200 Subject: [PATCH 3/5] fix obsolete storagecrate name in blocks.xml --- Config/blocks.xml | 2 +- Scripts/start-local.cmd | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Config/blocks.xml b/Config/blocks.xml index 17a1f57..6db11a9 100644 --- a/Config/blocks.xml +++ b/Config/blocks.xml @@ -11,7 +11,7 @@ - + diff --git a/Scripts/start-local.cmd b/Scripts/start-local.cmd index ec42ca3..5ac4143 100644 --- a/Scripts/start-local.cmd +++ b/Scripts/start-local.cmd @@ -14,6 +14,6 @@ cd %MOD_PATH%\.. taskkill /IM 7DaysToDie.exe /F >nul 2>&1 -start "" "%PATH_7D2D%\7DaysToDie" -force-d3d11 -disablenativeinput -nogs -noeac +@REM start "" "%PATH_7D2D%\7DaysToDie" -force-d3d11 -disablenativeinput -nogs -noeac exit /b 0 \ No newline at end of file From 6637558875aa25f7312e9005da6bca92974d96b7 Mon Sep 17 00:00:00 2001 From: Thomas Menanteau <91687641+VisualDev-FR@users.noreply.github.com> Date: Tue, 25 Jun 2024 00:08:02 +0200 Subject: [PATCH 4/5] implement compatibility for A22 --- Harmony/BlockEfficientBaseRepair.cs | 15 ++++++- Harmony/EfficientBaseRepair.cs | 57 ++++++++++++++++++++++++ Harmony/XUiC_EfficientBaseRepairStats.cs | 2 +- 3 files changed, 72 insertions(+), 2 deletions(-) diff --git a/Harmony/BlockEfficientBaseRepair.cs b/Harmony/BlockEfficientBaseRepair.cs index bfbb625..4c60e2c 100644 --- a/Harmony/BlockEfficientBaseRepair.cs +++ b/Harmony/BlockEfficientBaseRepair.cs @@ -69,7 +69,7 @@ private void BloodMoonDenied(EntityPlayerLocal _player) } // copied from BlockSecureLoot - public override bool OnBlockActivated(string _commandName, WorldBase _world, int _cIdx, Vector3i _blockPos, BlockValue _blockValue, EntityPlayerLocal _player) + public override bool OnBlockActivated(string _commandName, WorldBase _world, int _cIdx, Vector3i _blockPos, BlockValue _blockValue, EntityPlayerLocal _player) { if (_blockValue.ischild) @@ -243,4 +243,17 @@ protected virtual void HandleTakeInternalItems(TileEntityEfficientBaseRepair te, } } + + public override void OnBlockRemoved(WorldBase world, Chunk _chunk, Vector3i _blockPos, BlockValue _blockValue) + { + Log.Out($"[EfficientBaseRepair] OnBlockRemoved: {StackTraceUtility.ExtractStackTrace()}"); + base.OnBlockRemoved(world, _chunk, _blockPos, _blockValue); + } + + public override DestroyedResult OnBlockDestroyedBy(WorldBase _world, int _clrIdx, Vector3i _blockPos, BlockValue _blockValue, int _entityId, bool _bUseHarvestTool) + { + Log.Out($"[EfficientBaseRepair] OnBlockDestroyedBy: {StackTraceUtility.ExtractStackTrace()}"); + + return base.OnBlockDestroyedBy(_world, _clrIdx, _blockPos, _blockValue, _entityId, _bUseHarvestTool); + } } \ No newline at end of file diff --git a/Harmony/EfficientBaseRepair.cs b/Harmony/EfficientBaseRepair.cs index 73268d2..cdde73c 100644 --- a/Harmony/EfficientBaseRepair.cs +++ b/Harmony/EfficientBaseRepair.cs @@ -1,6 +1,10 @@ +using System; +using System.Collections.Generic; using System.Reflection; +using Audio; using HarmonyLib; using Twitch; +using UnityEngine; namespace Harmony { @@ -12,6 +16,7 @@ public void InitMod(Mod _modInstance) harmony.PatchAll(Assembly.GetExecutingAssembly()); } + [HarmonyPatch(typeof(TileEntity))] [HarmonyPatch("Instantiate")] public class TileEntity_Instantiate @@ -27,6 +32,7 @@ public static bool Prefix(TileEntityType type, Chunk _chunk, ref TileEntity __re } } + [HarmonyPatch(typeof(GameManager))] [HarmonyPatch("lootContainerOpened")] public class GameManager_lootContainerOpened @@ -69,5 +75,56 @@ public static bool Prefix(GameManager __instance, TileEntityLootContainer _te, L return false; } } + + + [HarmonyPatch(typeof(GameManager))] + [HarmonyPatch("TEUnlockServer")] + public class GameManager_TEUnlockServer + { + public static bool Prefix(GameManager __instance, int _clrIdx, Vector3i _blockPos, int _lootEntityId, bool _allowContainerDestroy = true) + { + if (!SingletonMonoBehaviour.Instance.IsServer) + { + SingletonMonoBehaviour.Instance.SendToServer(NetPackageManager.GetPackage().Setup(NetPackageTELock.TELockType.UnlockServer, _clrIdx, _blockPos, _lootEntityId, -1, null, _allowContainerDestroy)); + return false; + } + + TileEntity tileEntity = null; + if (_lootEntityId == -1) + { + tileEntity = __instance.m_World.GetTileEntity(_blockPos); + } + else + { + tileEntity = __instance.m_World.GetTileEntity(_lootEntityId); + if (tileEntity == null) + { + foreach (KeyValuePair lockedTileEntity in __instance.lockedTileEntities) + { + if (lockedTileEntity.Key.EntityId == _lootEntityId) + { + __instance.lockedTileEntities.Remove(lockedTileEntity.Key); + break; + } + } + } + } + + if (tileEntity != null) + { + __instance.lockedTileEntities.Remove(tileEntity); + + if (tileEntity.GetTileEntityType() == (TileEntityType)191) + return false; + + if (_allowContainerDestroy) + { + __instance.DestroyLootOnClose(tileEntity, _blockPos, _lootEntityId); + } + } + + return false; + } + } } } \ No newline at end of file diff --git a/Harmony/XUiC_EfficientBaseRepairStats.cs b/Harmony/XUiC_EfficientBaseRepairStats.cs index 0c04d8a..c208a0b 100644 --- a/Harmony/XUiC_EfficientBaseRepairStats.cs +++ b/Harmony/XUiC_EfficientBaseRepairStats.cs @@ -305,7 +305,7 @@ public override void OnClose() if (!XUiC_CameraWindow.hackyIsOpeningMaximizedWindow) { tileEntity.SetUserAccessing(_bUserAccessing: false); - instance.TEUnlockServer(tileEntity.GetClrIdx(), blockPos, tileEntity.entityId); + instance.TEUnlockServer(tileEntity.GetClrIdx(), blockPos, tileEntity.entityId, false); tileEntity.SetModified(); } base.OnClose(); From d7fb760b21d3366ef7d423a404ad106d4f6be0b0 Mon Sep 17 00:00:00 2001 From: Thomas Menanteau <91687641+VisualDev-FR@users.noreply.github.com> Date: Tue, 25 Jun 2024 00:10:53 +0200 Subject: [PATCH 5/5] update changelog --- CHANGELOG.md | 3 +++ ModInfo.xml | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 689b876..3125873 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), ### Changed +- The mod is now compatible with version 1.0 of the game +- A21 is not supported anymore + ## [0.1.1] - 2024-06-09 ### Fixed diff --git a/ModInfo.xml b/ModInfo.xml index 0fcdaad..01c87ec 100644 --- a/ModInfo.xml +++ b/ModInfo.xml @@ -4,6 +4,6 @@ - + \ No newline at end of file