diff --git a/Mods/0-SCore/0-SCore.csproj b/Mods/0-SCore/0-SCore.csproj index a3a7e357..56dbe1d2 100644 --- a/Mods/0-SCore/0-SCore.csproj +++ b/Mods/0-SCore/0-SCore.csproj @@ -151,6 +151,7 @@ + diff --git a/Mods/0-SCore/Config/Localization.txt b/Mods/0-SCore/Config/Localization.txt index 37986bd9..78b8570b 100644 --- a/Mods/0-SCore/Config/Localization.txt +++ b/Mods/0-SCore/Config/Localization.txt @@ -188,7 +188,6 @@ BreakBlock04Short,"Destroy any metal block in the pine forest" SCore02challenges_key,"Fire Bug" onStartFire,"Start a Fire" - BurnWithFire02,"Start a fire" BurnWithFire02Desc,"Start a fire with the Fire Mod active." onBigFire,"Start an out of control fire" diff --git a/Mods/0-SCore/Config/blocks.xml b/Mods/0-SCore/Config/blocks.xml index 1e1fbb02..985c426c 100644 --- a/Mods/0-SCore/Config/blocks.xml +++ b/Mods/0-SCore/Config/blocks.xml @@ -172,8 +172,14 @@ - + + + + + + + diff --git a/Mods/0-SCore/Features/Challenges/Scripts/ChallengeObjectiveExtinguishFire.cs b/Mods/0-SCore/Features/Challenges/Scripts/ChallengeObjectiveExtinguishFire.cs index 2130d251..ac23eb0a 100644 --- a/Mods/0-SCore/Features/Challenges/Scripts/ChallengeObjectiveExtinguishFire.cs +++ b/Mods/0-SCore/Features/Challenges/Scripts/ChallengeObjectiveExtinguishFire.cs @@ -28,7 +28,10 @@ public override void HandleRemoveHooks() { FireManager.Instance.OnExtinguish -= Check_Block; } - private void Check_Block(int count) { + private void Check_Block(int count, int entityId) { + if (entityId == -1) return; + var localPlayer = GameManager.Instance.World.GetPrimaryPlayer(); + if (localPlayer.entityId != entityId) return; Current = count; CheckObjectiveComplete(); } diff --git a/Mods/0-SCore/Features/Challenges/Scripts/ChallengeObjectiveStartFire.cs b/Mods/0-SCore/Features/Challenges/Scripts/ChallengeObjectiveStartFire.cs index affc9770..0fdd477c 100644 --- a/Mods/0-SCore/Features/Challenges/Scripts/ChallengeObjectiveStartFire.cs +++ b/Mods/0-SCore/Features/Challenges/Scripts/ChallengeObjectiveStartFire.cs @@ -28,7 +28,10 @@ public override void HandleRemoveHooks() { FireManager.Instance.OnStartFire -= Check_Block; } - private void Check_Block() { + private void Check_Block(int entityId) { + if (entityId == -1) return; + var localPlayer = GameManager.Instance.World.GetPrimaryPlayer(); + if (localPlayer.entityId != entityId) return; Current++; CheckObjectiveComplete(); } diff --git a/Mods/0-SCore/Features/Fire/Scripts/FireManager.cs b/Mods/0-SCore/Features/Fire/Scripts/FireManager.cs index dfaa4ba9..0fa80a6a 100644 --- a/Mods/0-SCore/Features/Fire/Scripts/FireManager.cs +++ b/Mods/0-SCore/Features/Fire/Scripts/FireManager.cs @@ -30,13 +30,13 @@ private static readonly ConcurrentDictionary public delegate void OnBlockDestroyedByFire(); public event OnBlockDestroyedByFire OnDestroyed; - public delegate void OnFireStart(); + public delegate void OnFireStart(int entityId); public event OnFireStart OnStartFire; public delegate void OnFireRefresh(int count); public event OnFireRefresh OnFireUpdate; - public delegate void OnExtinguishFire(int count); + public delegate void OnExtinguishFire(int count, int entityId); public event OnExtinguishFire OnExtinguish; @@ -608,7 +608,7 @@ private void Read(BinaryReader br) { if (string.IsNullOrEmpty(position)) continue; var vector = StringParsers.ParseVector3i(position); - ExtinguishBlock(vector); + ExtinguishBlock(vector, -1); } } @@ -636,6 +636,8 @@ public void Add(Vector3i blockPos, int entityID = -1) { if (!IsFlammable(blockPos)) return; + + OnStartFire?.Invoke(entityID); AddBlock(blockPos); @@ -655,7 +657,7 @@ public void Add(Vector3i blockPos, int entityID = -1) // General call to remove the fire from a block, and add an extinguished counter, so blocks can be temporarily immune to restarting. public void Extinguish(Vector3i blockPos, int entityID = -1) { - ExtinguishBlock(blockPos); + ExtinguishBlock(blockPos, entityID); if (!SingletonMonoBehaviour.Instance.IsServer) { SingletonMonoBehaviour.Instance.SendToServer( @@ -709,7 +711,7 @@ public void RemoveFire(Vector3i blockPos) FireMap.TryRemove(blockPos, out _); } - public void ExtinguishBlock(Vector3i blockPos) + public void ExtinguishBlock(Vector3i blockPos, int entityId) { var worldTime = GameManager.Instance.World.GetWorldTime(); var expiry = worldTime + _smokeTime; @@ -718,7 +720,7 @@ public void ExtinguishBlock(Vector3i blockPos) // keep resetting the expired time. ExtinguishPositions[blockPos] = expiry; RemoveFire(blockPos); - OnExtinguish?.Invoke(ExtinguishPositions.Count); + OnExtinguish?.Invoke(ExtinguishPositions.Count, entityId); //FireMap.TryRemove(blockPos, out _); var block = GameManager.Instance.World.GetBlock(blockPos); @@ -739,7 +741,6 @@ public void AddBlock(Vector3i blockPos) var block = GameManager.Instance.World.GetBlock(blockPos); if (!FireMap.TryAdd(blockPos, block)) return; - OnStartFire?.Invoke(); ToggleSound(blockPos, true); ToggleParticle(blockPos, true); diff --git a/Mods/0-SCore/Features/Fire/Scripts/MinEvent/MinEventActionAddFireDamage.cs b/Mods/0-SCore/Features/Fire/Scripts/MinEvent/MinEventActionAddFireDamage.cs index c6693888..19217b14 100644 --- a/Mods/0-SCore/Features/Fire/Scripts/MinEvent/MinEventActionAddFireDamage.cs +++ b/Mods/0-SCore/Features/Fire/Scripts/MinEvent/MinEventActionAddFireDamage.cs @@ -21,6 +21,7 @@ public override void Execute(MinEventParams @params) if (FireManager.Instance == null) return; if (FireManager.Instance.Enabled == false) return; + var entityId = @params.Self.entityId; var position = @params.Position; if (targetType != TargetTypes.positionAOE) { @@ -51,10 +52,10 @@ public override void Execute(MinEventParams @params) AdvLogging.DisplayLog(AdvFeatureClass, $"Executing AddFireDamage() at {position} Self: {@params.Self.position} Range: {maxRange} Delay: {_delayTime}"); Task.Delay((int) _delayTime) - .ContinueWith(_ => AddFire(position)); + .ContinueWith(_ => AddFire(position, entityId)); } - private void AddFire(Vector3 position) + private void AddFire(Vector3 position, int entityId) { var range = (int) maxRange; for (var x = -range; x <= range; x++) @@ -64,7 +65,7 @@ private void AddFire(Vector3 position) for (var y = -range; y <= range; y++) { var vector = new Vector3i(position.x + x, position.y + y, position.z + z); - FireManager.Instance.Add(vector); + FireManager.Instance.Add(vector, entityId); } } } diff --git a/Mods/0-SCore/Features/Fire/Scripts/MinEvent/MinEventActionAddFireDamageCascade.cs b/Mods/0-SCore/Features/Fire/Scripts/MinEvent/MinEventActionAddFireDamageCascade.cs index 6b25299f..6c9e210f 100644 --- a/Mods/0-SCore/Features/Fire/Scripts/MinEvent/MinEventActionAddFireDamageCascade.cs +++ b/Mods/0-SCore/Features/Fire/Scripts/MinEvent/MinEventActionAddFireDamageCascade.cs @@ -36,6 +36,7 @@ private enum FilterTypeCascade public override void Execute(MinEventParams @params) { var position = @params.Position; + var entityId = @params.Self.entityId; if (targetType != TargetTypes.positionAOE) { if (Voxel.voxelRayHitInfo.bHitValid) @@ -45,10 +46,10 @@ public override void Execute(MinEventParams @params) position = hitInfo.hit.blockPos; } } - SpreadFire(position); + SpreadFire(position, entityId); } - private void SpreadFire(Vector3 position) + private void SpreadFire(Vector3 position, int entityId) { var targetBlock = GameManager.Instance.World.GetBlock(new Vector3i(position)); @@ -65,21 +66,21 @@ private void SpreadFire(Vector3 position) { case FilterTypeCascade.Type: if (neighborBlock.type == targetBlock.type) - FireManager.Instance.Add(vector); + FireManager.Instance.Add(vector,entityId); break; case FilterTypeCascade.Material: if (neighborBlock.Block.blockMaterial.id == targetBlock.Block.blockMaterial.id) - FireManager.Instance.Add(vector); + FireManager.Instance.Add(vector,entityId); break; case FilterTypeCascade.MaterialDamage: if (neighborBlock.Block.blockMaterial.DamageCategory == targetBlock.Block.blockMaterial.DamageCategory) - FireManager.Instance.Add(vector); + FireManager.Instance.Add(vector,entityId); break; case FilterTypeCascade.MaterialSurface: if (neighborBlock.Block.blockMaterial.SurfaceCategory == targetBlock.Block.blockMaterial.SurfaceCategory) - FireManager.Instance.Add(vector); + FireManager.Instance.Add(vector,entityId); break; } } diff --git a/Mods/0-SCore/Features/Fire/Scripts/MinEvent/MinEventActionRemoveFire.cs b/Mods/0-SCore/Features/Fire/Scripts/MinEvent/MinEventActionRemoveFire.cs index 3594024c..888e63cd 100644 --- a/Mods/0-SCore/Features/Fire/Scripts/MinEvent/MinEventActionRemoveFire.cs +++ b/Mods/0-SCore/Features/Fire/Scripts/MinEvent/MinEventActionRemoveFire.cs @@ -19,6 +19,7 @@ public override void Execute(MinEventParams @params) if (FireManager.Instance.Enabled == false) return; var position = @params.Position; + var entityId = @params.Self.entityId; if (targetType != TargetTypes.positionAOE) { if (Voxel.voxelRayHitInfo.bHitValid) @@ -40,7 +41,7 @@ public override void Execute(MinEventParams @params) var vector = new Vector3i(position.x + x, position.y + y, position.z + z); if (!FireManager.IsBurning(vector)) continue; // FireManager.Instance.Remove(vector); - FireManager.Instance.Extinguish(vector); + FireManager.Instance.Extinguish(vector,entityId); } } diff --git a/Mods/0-SCore/Features/Fire/Scripts/NetPackage/NetPackageAddExtinguishPosition.cs b/Mods/0-SCore/Features/Fire/Scripts/NetPackage/NetPackageAddExtinguishPosition.cs index 6e6412ed..2ac971da 100644 --- a/Mods/0-SCore/Features/Fire/Scripts/NetPackage/NetPackageAddExtinguishPosition.cs +++ b/Mods/0-SCore/Features/Fire/Scripts/NetPackage/NetPackageAddExtinguishPosition.cs @@ -49,7 +49,7 @@ public override void ProcessPackage(World world, GameManager callbacks) return; } - FireManager.Instance.ExtinguishBlock(_position); + FireManager.Instance.ExtinguishBlock(_position, _entityThatCausedIt); } } diff --git a/Mods/0-SCore/Harmony/Blocks/ChunkPoolBlockEntityTransform.cs b/Mods/0-SCore/Harmony/Blocks/ChunkPoolBlockEntityTransform.cs new file mode 100644 index 00000000..a2fa270a --- /dev/null +++ b/Mods/0-SCore/Harmony/Blocks/ChunkPoolBlockEntityTransform.cs @@ -0,0 +1,46 @@ +using HarmonyLib; +using UnityEngine; + +namespace SCore.Harmony.Blocks { + public class ChunkPoolBlockEntityTransform { + private static readonly string AdvFeatureClass = "ErrorHandling"; + private static readonly string Feature = "EnablePoolBlockEntityTransformCheck"; + private static readonly string Logging = "LogPoolBlockEntityTransformCheck"; + + [HarmonyPatch(typeof(Chunk))] + [HarmonyPatch("poolBlockEntityTransform")] + public class ChunkpoolBlockEntityTransform { + public static bool Prefix(BlockEntityData _bed) { + // Check if this feature is enabled. + if (!Configuration.CheckFeatureStatus(AdvFeatureClass, Feature)) return true; + if (_bed.transform != null && _bed.transform.gameObject != null) return true; + if (Configuration.CheckFeatureStatus(AdvFeatureClass, Logging)) + { + Debug.Log("Error: There's a Block Entity without a Transform!"); + Debug.Log($"Block Position: {_bed.pos} : BlockValue: {_bed.blockValue.Block.ToString()}"); + } + + return false; + + } + } + + [HarmonyPatch(typeof(Chunk))] + [HarmonyPatch("setBlockEntityRendering")] + public class ChunksetBlockEntityRendering { + public static bool Prefix(BlockEntityData _bed) { + // Check if this feature is enabled. + if (!Configuration.CheckFeatureStatus(AdvFeatureClass, Feature)) return true; + if (_bed.transform != null && _bed.transform.gameObject != null) return true; + if (Configuration.CheckFeatureStatus(AdvFeatureClass, Logging)) + { + Debug.Log("Error: There's a Block Entity without a Transform!"); + Debug.Log($"Block Position: {_bed.pos} : BlockValue: {_bed.blockValue.Block.ToString()}"); + } + + return false; + + } + } + } +} \ No newline at end of file diff --git a/Mods/0-SCore/Harmony/Faction/FactionTweaks.cs b/Mods/0-SCore/Harmony/Faction/FactionTweaks.cs index 05c04ef3..a9d70a54 100644 --- a/Mods/0-SCore/Harmony/Faction/FactionTweaks.cs +++ b/Mods/0-SCore/Harmony/Faction/FactionTweaks.cs @@ -47,6 +47,30 @@ public static bool Prefix(global::Faction __instance, byte _factionId, float _va return false; } } + + // Working around missing faction bug + [HarmonyPatch(typeof(FactionManager))] + [HarmonyPatch("GetFactionByName")] + public class FactionGetFactionByName + { + public static bool Prefix(ref global::Faction __result, FactionManager __instance, string _name) { + global::Faction defaultFaction = null; + for (var i = 0; i < __instance.Factions.Length; i++) + { + // If no faction is found, use this one. + if (__instance.Factions[i]?.Name == "undead") + defaultFaction = __instance.Factions[i]; + + if (__instance.Factions[i]?.Name != _name) continue; + __result = __instance.Factions[i]; + return false; + } + + Debug.Log($"FactionManager: Requested this Faction: {_name} but it was not defined in the npc.xml. Defaulting to Undead faction."); + __result = defaultFaction; + return false; + } + } } } \ No newline at end of file diff --git a/Mods/0-SCore/Harmony/TileEntities/TileEntitySignGif.cs b/Mods/0-SCore/Harmony/TileEntities/TileEntitySignGif.cs index e82aaa42..5856139e 100644 --- a/Mods/0-SCore/Harmony/TileEntities/TileEntitySignGif.cs +++ b/Mods/0-SCore/Harmony/TileEntities/TileEntitySignGif.cs @@ -30,6 +30,8 @@ public static bool Prefix(TileEntitySign __instance) { var smartTextMesh = __instance.smartTextMesh; if (smartTextMesh == null) return true; var parentTransform = smartTextMesh.transform.parent; + if (parentTransform.transform.childCount < 2) + return true; var signMesh = parentTransform.transform.GetChild(0); var prefab = parentTransform.transform.GetChild(1); diff --git a/Mods/0-SCore/ModInfo.xml b/Mods/0-SCore/ModInfo.xml index dd698a74..723f23aa 100644 --- a/Mods/0-SCore/ModInfo.xml +++ b/Mods/0-SCore/ModInfo.xml @@ -5,5 +5,5 @@ - + \ No newline at end of file diff --git a/Mods/0-SCore/Properties/AssemblyInfo.cs b/Mods/0-SCore/Properties/AssemblyInfo.cs index 93f393e6..49f6c0b0 100644 --- a/Mods/0-SCore/Properties/AssemblyInfo.cs +++ b/Mods/0-SCore/Properties/AssemblyInfo.cs @@ -38,5 +38,5 @@ // [assembly: AssemblyVersion("1.0.*")] //[assembly: AssemblyVersion("20.0.*")] -[assembly: AssemblyVersion("1.1.4.1542")] -[assembly: AssemblyFileVersion("1.1.4.1542")] +[assembly: AssemblyVersion("1.1.9.2008")] +[assembly: AssemblyFileVersion("1.1.9.2008")] diff --git a/Mods/0-SCore/ReadMe.md b/Mods/0-SCore/ReadMe.md index 77fb57ad..1ce7cbcb 100644 --- a/Mods/0-SCore/ReadMe.md +++ b/Mods/0-SCore/ReadMe.md @@ -20,7 +20,37 @@ Direct Download to the 0-SCore.zip available on gitlab mirror: https://github.co ### Change Logs [ Change Log ] -Version: 1.1.4.1542 +Version: 1.1.9.2008 + [ Faction Manager ] + - Added a Harmony Patch to GetFactionByName() to catch for invalid factions. + - If a faction is requested from an entityclass, but it's not defined in npc.xml, + the undead faction is used. + - A message in the console is printed when a faction was not found. + + [ POI Error Check ] + - Added in two Harmony patches, gated by two new blocks.xml entry. + - Under the ErrorHandling section: + EnablePoolBlockEntityTransformCheck + LogPoolBlockEntityTransformCheck + - Some POis were throwing errors about block entity's without a proper transform: + BlockEntity {0} at pos {1} null transform! + 2: {0} on pos {1} with empty transform/gameobject! + - These were being thrown in the Chunk class. + - These two patches block that error from being thrown, and silently returns. + - The LogPoolBlockEntityTransformCheck will throw an error, but it'll tell you which block it's failing at. + - Both these should be false, unless you are specifically having a problem + + [ TileEntitySign Gif ] + - Fixed an issue where some older signs did not have the correct amount of transforms + - ie, pathing cubes + + [ Challenges ] + - Fixed an issue with the StartAFire / Extinguish Fire where any entity would contribute + + [ Fire Manager ] + - Updated the Fire Manager's StartFire / ExtinguishFire event takes an entity ID. + +Version: 1.1.4.1542 [ Entity Targetting ] - Updated the code for the ItemItemAction to first check if it's hitting an EntityAlive - Then checks if the entity alive is dead. If so, let the damage through. diff --git a/Mods/0-SCore/SCore.dll b/Mods/0-SCore/SCore.dll index a64f1c90..fcdca402 100644 Binary files a/Mods/0-SCore/SCore.dll and b/Mods/0-SCore/SCore.dll differ diff --git a/Mods/0-SCore/SCore.pdb b/Mods/0-SCore/SCore.pdb index b4ab7d7d..6dd511c4 100644 Binary files a/Mods/0-SCore/SCore.pdb and b/Mods/0-SCore/SCore.pdb differ diff --git a/Mods/SphereII Winter Project/SphereII_Winter_Project.dll b/Mods/SphereII Winter Project/SphereII_Winter_Project.dll index aa44006c..2829d9ea 100644 Binary files a/Mods/SphereII Winter Project/SphereII_Winter_Project.dll and b/Mods/SphereII Winter Project/SphereII_Winter_Project.dll differ diff --git a/Mods/SphereII Winter Project/SphereII_Winter_Project.pdb b/Mods/SphereII Winter Project/SphereII_Winter_Project.pdb index 9f9fa528..915153bd 100644 Binary files a/Mods/SphereII Winter Project/SphereII_Winter_Project.pdb and b/Mods/SphereII Winter Project/SphereII_Winter_Project.pdb differ