From e5029166e2ba5f80a038977d91011dc9b29ca29d Mon Sep 17 00:00:00 2001 From: WarrentyExpired Date: Thu, 8 Oct 2026 09:07:58 -0400 Subject: [PATCH] #W# Spawn: Tweaked RegionSpawner so it detects the region when you spawn it. --- Distribution/Data/regions.json | 21 +++++++--------- .../Engines/Spawners/RegionSpawner.cs | 24 +++++++++++++++++++ 2 files changed, 33 insertions(+), 12 deletions(-) diff --git a/Distribution/Data/regions.json b/Distribution/Data/regions.json index 7f797cb0e..6446e75ef 100644 --- a/Distribution/Data/regions.json +++ b/Distribution/Data/regions.json @@ -2406,12 +2406,7 @@ "Name": "the Dungeon Destard", "Priority": 50, "Area": [ - { "x1": 2712, "y1": 30, "x2": 2977, "y2": 306 }, - { "x1": 2714, "y1": 69, "x2": 2791, "y2": 168 }, - { "x1": 2717, "y1": 272, "x2": 2801, "y2": 304 }, - { "x1": 2718, "y1": 230, "x2": 2750, "y2": 271 }, - { "x1": 2750, "y1": 238, "x2": 2755, "y2": 272 }, - { "x1": 2755, "y1": 261, "x2": 2773, "y2": 272 } + { "x1": 2712, "y1": 30, "x2": 2977, "y2": 306 } ] }, { @@ -2421,7 +2416,10 @@ "Name": "the Dungeon Destard - Level 1", "Priority": 55, "Area": [ - { "x1": 2712, "y1": 30, "x2": 2977, "y2": 306 } + { "x1": 2787, "y1": 49, "x2": 2976, "y2": 271 }, + { "x1": 2718, "y1": 169, "x2": 2787, "y2": 215 }, + { "x1": 2755, "y1": 215, "x2": 2787, "y2": 256 }, + { "x1": 2800, "y1": 271, "x2": 2897, "y2": 294 } ] }, { @@ -2431,7 +2429,7 @@ "Name": "Destard - Level 2", "Priority": 60, "Area": [ - { "x1": 2714, "y1": 69, "x2": 2791, "y2": 168 } + { "x1": 2719, "y1": 67, "x2": 2786, "y2": 166 } ] }, { @@ -2441,10 +2439,9 @@ "Name": "Destard - Level 3", "Priority": 60, "Area": [ - { "x1": 2717, "y1": 272, "x2": 2801, "y2": 304 }, - { "x1": 2718, "y1": 230, "x2": 2750, "y2": 271 }, - { "x1": 2750, "y1": 238, "x2": 2755, "y2": 272 }, - { "x1": 2755, "y1": 261, "x2": 2773, "y2": 272 } + { "x1": 2722, "y1": 234, "x2": 2754, "y2": 304 }, + { "x1": 2754, "y1": 260, "x2": 2783, "y2": 304 }, + { "x1": 2783, "y1": 274, "x2": 2799, "y2": 304 } ] }, { diff --git a/Projects/UOContent/Engines/Spawners/RegionSpawner.cs b/Projects/UOContent/Engines/Spawners/RegionSpawner.cs index 37b3d098e..4df8da352 100644 --- a/Projects/UOContent/Engines/Spawners/RegionSpawner.cs +++ b/Projects/UOContent/Engines/Spawners/RegionSpawner.cs @@ -115,6 +115,30 @@ public partial class RegionSpawner : Spawner } } + public override void OnMapChange() + { + base.OnMapChange(); + UpdateRegionFromLocation(); + } + + public override void OnLocationChange(Point3D oldLocation) + { + base.OnLocationChange(oldLocation); + UpdateRegionFromLocation(); + } + + private void UpdateRegionFromLocation() + { + if (Map != null && Map != Map.Internal) + { + var currentRegion = Region.Find(Location, Map) as BaseRegion; + if (currentRegion != null && currentRegion != _spawnRegion) + { + SpawnRegion = currentRegion; + } + } + } + [AfterDeserialization(false)] private void AfterDeserialization() {