fr.jeanf.scenemanagement 0.3.6 → 0.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
using UnityEngine;
|
|
2
|
+
using UnityEngine.Serialization;
|
|
2
3
|
|
|
3
4
|
namespace jeanf.scenemanagement
|
|
4
5
|
{
|
|
5
6
|
[CreateAssetMenu(fileName = "App_", menuName = "LoadingSystem/App")]
|
|
6
7
|
public class AppType: ScriptableObject
|
|
7
8
|
{
|
|
8
|
-
[Header("App Information")]
|
|
9
|
-
public string
|
|
9
|
+
[FormerlySerializedAs("name")] [Header("App Information")]
|
|
10
|
+
public string appName;
|
|
10
11
|
public Texture2D icon;
|
|
11
12
|
}
|
|
12
13
|
}
|
|
@@ -191,7 +191,7 @@ namespace jeanf.scenemanagement
|
|
|
191
191
|
|
|
192
192
|
private void BuildLandingZoneCache()
|
|
193
193
|
{
|
|
194
|
-
var connectivity =
|
|
194
|
+
var connectivity = FindFirstObjectByType<RegionConnectivityAuthoring>();
|
|
195
195
|
if (connectivity?.regionConnectivity?.landingZones == null) return;
|
|
196
196
|
|
|
197
197
|
for (int i = 0; i < connectivity.regionConnectivity.landingZones.Count; i++)
|
|
@@ -208,7 +208,6 @@ namespace jeanf.scenemanagement
|
|
|
208
208
|
{
|
|
209
209
|
if (Instance != null && !_isRegionTransitioning)
|
|
210
210
|
{
|
|
211
|
-
// FIXED: Reliable string conversion
|
|
212
211
|
var zoneIdString = zoneId.ToString();
|
|
213
212
|
Instance.OnZoneChangedFromECS(zoneIdString);
|
|
214
213
|
}
|
|
@@ -218,7 +217,6 @@ namespace jeanf.scenemanagement
|
|
|
218
217
|
{
|
|
219
218
|
if (Instance != null && !_isRegionTransitioning)
|
|
220
219
|
{
|
|
221
|
-
// FIXED: Reliable string conversion
|
|
222
220
|
var regionIdString = regionId.ToString();
|
|
223
221
|
Instance.OnRegionChangedFromECS(regionIdString);
|
|
224
222
|
}
|
|
@@ -226,7 +224,6 @@ namespace jeanf.scenemanagement
|
|
|
226
224
|
|
|
227
225
|
private void OnZoneChangedFromECS(string zoneId)
|
|
228
226
|
{
|
|
229
|
-
// FIXED: Handle empty zones properly
|
|
230
227
|
if (zoneId == _lastNotifiedZone) return;
|
|
231
228
|
|
|
232
229
|
if (string.IsNullOrEmpty(zoneId))
|
|
@@ -249,7 +246,6 @@ namespace jeanf.scenemanagement
|
|
|
249
246
|
|
|
250
247
|
private void OnRegionChangedFromECS(string regionId)
|
|
251
248
|
{
|
|
252
|
-
// FIXED: Handle empty regions properly and fix comparison
|
|
253
249
|
if (regionId == _lastNotifiedRegion) return;
|
|
254
250
|
|
|
255
251
|
if (string.IsNullOrEmpty(regionId))
|
|
@@ -87,10 +87,9 @@ namespace jeanf.scenemanagement
|
|
|
87
87
|
|
|
88
88
|
private void DrawVolumeConnections(RegionConnectivity connectivity)
|
|
89
89
|
{
|
|
90
|
-
var volumeAuthorings =
|
|
90
|
+
var volumeAuthorings = Object.FindObjectsByType<VolumeAuthoring>(FindObjectsSortMode.None);
|
|
91
91
|
var regionVolumeMap = new Dictionary<Region, List<VolumeAuthoring>>();
|
|
92
92
|
|
|
93
|
-
// Group volumes by region and assign colors
|
|
94
93
|
foreach (var region in connectivity.activeRegions)
|
|
95
94
|
{
|
|
96
95
|
if (region == null) continue;
|
|
@@ -107,26 +106,22 @@ namespace jeanf.scenemanagement
|
|
|
107
106
|
{
|
|
108
107
|
if (zone == null) continue;
|
|
109
108
|
|
|
110
|
-
// CHANGED: Collect ALL volumes for this zone, not just the first one
|
|
111
109
|
foreach (var volumeAuth in volumeAuthorings)
|
|
112
110
|
{
|
|
113
111
|
if (volumeAuth.zone != null && volumeAuth.zone.id.Equals(zone.id))
|
|
114
112
|
{
|
|
115
113
|
regionVolumeMap[region].Add(volumeAuth);
|
|
116
|
-
// REMOVED: break statement - now collects all volumes for the zone
|
|
117
114
|
}
|
|
118
115
|
}
|
|
119
116
|
}
|
|
120
117
|
}
|
|
121
118
|
|
|
122
|
-
// Priority 3: Draw regular volumes and their connections first
|
|
123
119
|
foreach (var kvp in regionVolumeMap)
|
|
124
120
|
{
|
|
125
121
|
var region = kvp.Key;
|
|
126
122
|
var volumes = kvp.Value;
|
|
127
123
|
var color = _regionColors[region];
|
|
128
124
|
|
|
129
|
-
// Draw all volumes for this region
|
|
130
125
|
foreach (var volume in volumes)
|
|
131
126
|
{
|
|
132
127
|
if (volume == null) continue;
|
|
@@ -138,7 +133,6 @@ namespace jeanf.scenemanagement
|
|
|
138
133
|
Handles.DrawWireCube(pos, scale);
|
|
139
134
|
}
|
|
140
135
|
|
|
141
|
-
// CHANGED: Draw connections between zone centers, not individual volumes
|
|
142
136
|
var zoneVolumeGroups = new Dictionary<string, List<VolumeAuthoring>>();
|
|
143
137
|
foreach (var volume in volumes)
|
|
144
138
|
{
|
|
@@ -151,7 +145,6 @@ namespace jeanf.scenemanagement
|
|
|
151
145
|
zoneVolumeGroups[zoneId].Add(volume);
|
|
152
146
|
}
|
|
153
147
|
|
|
154
|
-
// Draw connections between zone centers (red dotted lines)
|
|
155
148
|
var zoneIds = zoneVolumeGroups.Keys.ToList();
|
|
156
149
|
for (int i = 0; i < zoneIds.Count; i++)
|
|
157
150
|
{
|
|
@@ -169,12 +162,10 @@ namespace jeanf.scenemanagement
|
|
|
169
162
|
}
|
|
170
163
|
}
|
|
171
164
|
|
|
172
|
-
// Draw landing zone connections (yellow solid lines)
|
|
173
165
|
foreach (var landing in connectivity.landingZones)
|
|
174
166
|
{
|
|
175
167
|
if (landing.landingZone == null || landing.region == null) continue;
|
|
176
168
|
|
|
177
|
-
// CHANGED: Find ALL volumes for the landing zone
|
|
178
169
|
var landingVolumes = System.Array.FindAll(volumeAuthorings,
|
|
179
170
|
v => v.zone != null && v.zone.id.Equals(landing.landingZone.id)).ToList();
|
|
180
171
|
|
|
@@ -182,15 +173,13 @@ namespace jeanf.scenemanagement
|
|
|
182
173
|
|
|
183
174
|
var landingCenter = CalculateZoneCenter(landingVolumes);
|
|
184
175
|
|
|
185
|
-
// Connect landing zone center to volumes in OTHER regions only
|
|
186
176
|
foreach (var kvp in regionVolumeMap)
|
|
187
177
|
{
|
|
188
178
|
var region = kvp.Key;
|
|
189
179
|
var volumes = kvp.Value;
|
|
190
180
|
|
|
191
|
-
if (region.id.Equals(landing.region.id)) continue;
|
|
181
|
+
if (region.id.Equals(landing.region.id)) continue;
|
|
192
182
|
|
|
193
|
-
// Group volumes by zone and connect to zone centers
|
|
194
183
|
var zoneGroups = volumes.GroupBy(v => v.zone?.id.ToString()).Where(g => !string.IsNullOrEmpty(g.Key));
|
|
195
184
|
|
|
196
185
|
foreach (var zoneGroup in zoneGroups)
|
|
@@ -204,18 +193,15 @@ namespace jeanf.scenemanagement
|
|
|
204
193
|
}
|
|
205
194
|
}
|
|
206
195
|
|
|
207
|
-
// Priority 2: Draw landing zones on top (blue boxes, actual size)
|
|
208
196
|
foreach (var landing in connectivity.landingZones)
|
|
209
197
|
{
|
|
210
198
|
if (landing.landingZone == null || landing.region == null) continue;
|
|
211
199
|
|
|
212
|
-
// CHANGED: Find ALL volumes for the landing zone
|
|
213
200
|
var landingVolumes = System.Array.FindAll(volumeAuthorings,
|
|
214
201
|
v => v.zone != null && v.zone.id.Equals(landing.landingZone.id)).ToList();
|
|
215
202
|
|
|
216
203
|
if (landingVolumes.Count == 0) continue;
|
|
217
204
|
|
|
218
|
-
// Draw all landing zone volumes in blue, actual size
|
|
219
205
|
foreach (var landingVolume in landingVolumes)
|
|
220
206
|
{
|
|
221
207
|
var landingPos = landingVolume.transform.position;
|
|
@@ -227,7 +213,6 @@ namespace jeanf.scenemanagement
|
|
|
227
213
|
}
|
|
228
214
|
}
|
|
229
215
|
|
|
230
|
-
// Helper method to calculate the center point of a multi-volume zone
|
|
231
216
|
private Vector3 CalculateZoneCenter(List<VolumeAuthoring> volumes)
|
|
232
217
|
{
|
|
233
218
|
if (volumes.Count == 0) return Vector3.zero;
|
|
@@ -247,7 +232,6 @@ namespace jeanf.scenemanagement
|
|
|
247
232
|
{
|
|
248
233
|
if (landing.landingZone == null || landing.region == null) continue;
|
|
249
234
|
|
|
250
|
-
// CHANGED: Find ALL volumes for the landing zone
|
|
251
235
|
var landingVolumes = System.Array.FindAll(volumeAuthorings,
|
|
252
236
|
v => v.zone != null && v.zone.id.Equals(landing.landingZone.id)).ToList();
|
|
253
237
|
|
|
@@ -255,7 +239,6 @@ namespace jeanf.scenemanagement
|
|
|
255
239
|
|
|
256
240
|
var landingCenter = CalculateZoneCenter(landingVolumes);
|
|
257
241
|
|
|
258
|
-
// Draw all landing zone volumes
|
|
259
242
|
foreach (var landingVolume in landingVolumes)
|
|
260
243
|
{
|
|
261
244
|
var landingPos = landingVolume.transform.position;
|
|
@@ -279,7 +262,6 @@ namespace jeanf.scenemanagement
|
|
|
279
262
|
|
|
280
263
|
if (region.id.Equals(landing.region.id)) continue;
|
|
281
264
|
|
|
282
|
-
// Group volumes by zone and connect to zone centers
|
|
283
265
|
var zoneGroups = volumes.GroupBy(v => v.zone?.id.ToString()).Where(g => !string.IsNullOrEmpty(g.Key));
|
|
284
266
|
|
|
285
267
|
foreach (var zoneGroup in zoneGroups)
|
|
@@ -369,7 +351,7 @@ namespace jeanf.scenemanagement
|
|
|
369
351
|
|
|
370
352
|
private void DrawVolumeConnections(RegionConnectivity connectivity)
|
|
371
353
|
{
|
|
372
|
-
var volumeAuthorings =
|
|
354
|
+
var volumeAuthorings = Object.FindObjectsByType<VolumeAuthoring>(FindObjectsSortMode.None);
|
|
373
355
|
var regionVolumeMap = new Dictionary<Region, List<VolumeAuthoring>>();
|
|
374
356
|
|
|
375
357
|
foreach (var region in connectivity.activeRegions)
|
|
@@ -388,13 +370,11 @@ namespace jeanf.scenemanagement
|
|
|
388
370
|
{
|
|
389
371
|
if (zone == null) continue;
|
|
390
372
|
|
|
391
|
-
// CHANGED: Collect ALL volumes for this zone
|
|
392
373
|
foreach (var volumeAuth in volumeAuthorings)
|
|
393
374
|
{
|
|
394
375
|
if (volumeAuth.zone != null && volumeAuth.zone.id.Equals(zone.id))
|
|
395
376
|
{
|
|
396
377
|
regionVolumeMap[region].Add(volumeAuth);
|
|
397
|
-
// REMOVED: break statement
|
|
398
378
|
}
|
|
399
379
|
}
|
|
400
380
|
}
|
|
@@ -408,7 +388,6 @@ namespace jeanf.scenemanagement
|
|
|
408
388
|
|
|
409
389
|
Handles.color = color;
|
|
410
390
|
|
|
411
|
-
// Draw all volumes in this region
|
|
412
391
|
foreach (var volume in volumes)
|
|
413
392
|
{
|
|
414
393
|
if (volume == null) continue;
|
|
@@ -418,7 +397,6 @@ namespace jeanf.scenemanagement
|
|
|
418
397
|
|
|
419
398
|
Handles.DrawWireCube(currentPos, currentScale);
|
|
420
399
|
|
|
421
|
-
// Only show label for first volume of each zone to avoid clutter
|
|
422
400
|
var isFirstVolumeOfZone = volumes.Where(v => v?.zone?.id == volume.zone?.id).First() == volume;
|
|
423
401
|
if (isFirstVolumeOfZone)
|
|
424
402
|
{
|
|
@@ -428,7 +406,6 @@ namespace jeanf.scenemanagement
|
|
|
428
406
|
}
|
|
429
407
|
}
|
|
430
408
|
|
|
431
|
-
// CHANGED: Draw connections between zone centers
|
|
432
409
|
var zoneVolumeGroups = new Dictionary<string, List<VolumeAuthoring>>();
|
|
433
410
|
foreach (var volume in volumes)
|
|
434
411
|
{
|
|
@@ -479,7 +456,6 @@ namespace jeanf.scenemanagement
|
|
|
479
456
|
{
|
|
480
457
|
if (landing.landingZone == null || landing.region == null) continue;
|
|
481
458
|
|
|
482
|
-
// CHANGED: Find ALL volumes for the landing zone
|
|
483
459
|
var landingVolumes = System.Array.FindAll(volumeAuthorings,
|
|
484
460
|
v => v.zone != null && v.zone.id.Equals(landing.landingZone.id)).ToList();
|
|
485
461
|
|
|
@@ -487,7 +463,6 @@ namespace jeanf.scenemanagement
|
|
|
487
463
|
|
|
488
464
|
var landingCenter = CalculateZoneCenter(landingVolumes);
|
|
489
465
|
|
|
490
|
-
// Draw all landing zone volumes
|
|
491
466
|
foreach (var landingVolume in landingVolumes)
|
|
492
467
|
{
|
|
493
468
|
var landingPos = landingVolume.transform.position;
|
|
@@ -511,7 +486,6 @@ namespace jeanf.scenemanagement
|
|
|
511
486
|
|
|
512
487
|
if (region.id.Equals(landing.region.id)) continue;
|
|
513
488
|
|
|
514
|
-
// Group by zone and connect to zone centers
|
|
515
489
|
var zoneGroups = volumes.GroupBy(v => v.zone?.id.ToString()).Where(g => !string.IsNullOrEmpty(g.Key));
|
|
516
490
|
|
|
517
491
|
foreach (var zoneGroup in zoneGroups)
|
|
@@ -575,7 +549,7 @@ namespace jeanf.scenemanagement
|
|
|
575
549
|
{
|
|
576
550
|
if (_foundConnectivity != null) return;
|
|
577
551
|
|
|
578
|
-
var connectivityAuthoring =
|
|
552
|
+
var connectivityAuthoring = Object.FindFirstObjectByType<RegionConnectivityAuthoring>();
|
|
579
553
|
if (connectivityAuthoring != null && connectivityAuthoring.regionConnectivity != null)
|
|
580
554
|
{
|
|
581
555
|
_foundConnectivity = connectivityAuthoring.regionConnectivity;
|
|
@@ -590,7 +564,6 @@ namespace jeanf.scenemanagement
|
|
|
590
564
|
var currentZone = volumeAuth.zone;
|
|
591
565
|
Region currentRegion = null;
|
|
592
566
|
|
|
593
|
-
// Debug: Show what regions we have in the connectivity data
|
|
594
567
|
EditorGUILayout.LabelField("DEBUG - Active Regions in Connectivity:", EditorStyles.boldLabel);
|
|
595
568
|
foreach (var region in _foundConnectivity.activeRegions)
|
|
596
569
|
{
|
|
@@ -602,14 +575,12 @@ namespace jeanf.scenemanagement
|
|
|
602
575
|
|
|
603
576
|
EditorGUILayout.LabelField($" - {region.levelName} ({region.zonesInThisRegion.Count} zones)", EditorStyles.miniLabel);
|
|
604
577
|
|
|
605
|
-
// Check if current zone is in this region
|
|
606
578
|
if (region.zonesInThisRegion.Contains(currentZone))
|
|
607
579
|
{
|
|
608
580
|
currentRegion = region;
|
|
609
581
|
EditorGUILayout.LabelField($" → CURRENT REGION (contains {currentZone.zoneName})", EditorStyles.miniLabel);
|
|
610
582
|
}
|
|
611
583
|
|
|
612
|
-
// Show zones in this region
|
|
613
584
|
foreach (var zone in region.zonesInThisRegion)
|
|
614
585
|
{
|
|
615
586
|
if (zone != null)
|
|
@@ -695,11 +666,10 @@ namespace jeanf.scenemanagement
|
|
|
695
666
|
|
|
696
667
|
private void DrawVolumeConnectivity(VolumeAuthoring selectedVolume)
|
|
697
668
|
{
|
|
698
|
-
var allVolumeAuthorings =
|
|
669
|
+
var allVolumeAuthorings = Object.FindObjectsByType<VolumeAuthoring>(FindObjectsSortMode.None);
|
|
699
670
|
var currentZone = selectedVolume.zone;
|
|
700
671
|
Region currentRegion = null;
|
|
701
672
|
|
|
702
|
-
// Find which region this volume belongs to
|
|
703
673
|
foreach (var region in _foundConnectivity.activeRegions)
|
|
704
674
|
{
|
|
705
675
|
if (region != null && region.zonesInThisRegion.Contains(currentZone))
|
|
@@ -719,17 +689,14 @@ namespace jeanf.scenemanagement
|
|
|
719
689
|
|
|
720
690
|
var regionColor = _regionColors[currentRegion];
|
|
721
691
|
|
|
722
|
-
// CHANGED: Calculate center of the selected zone (which may have multiple volumes)
|
|
723
692
|
var selectedZoneVolumes = System.Array.FindAll(allVolumeAuthorings,
|
|
724
693
|
v => v.zone != null && v.zone.id.Equals(currentZone.id)).ToList();
|
|
725
694
|
var selectedZoneCenter = CalculateZoneCenter(selectedZoneVolumes);
|
|
726
695
|
|
|
727
|
-
// Priority 3: Draw other connections first (same region) - red dotted lines
|
|
728
696
|
foreach (var zone in currentRegion.zonesInThisRegion)
|
|
729
697
|
{
|
|
730
698
|
if (zone == null || zone == currentZone) continue;
|
|
731
699
|
|
|
732
|
-
// CHANGED: Find ALL volumes for this zone and draw connections to zone center
|
|
733
700
|
var zoneVolumes = System.Array.FindAll(allVolumeAuthorings,
|
|
734
701
|
v => v.zone != null && v.zone.id.Equals(zone.id)).ToList();
|
|
735
702
|
|
|
@@ -737,23 +704,19 @@ namespace jeanf.scenemanagement
|
|
|
737
704
|
|
|
738
705
|
var zoneCenter = CalculateZoneCenter(zoneVolumes);
|
|
739
706
|
|
|
740
|
-
// Draw all volumes in this zone
|
|
741
707
|
foreach (var volume in zoneVolumes)
|
|
742
708
|
{
|
|
743
709
|
Handles.color = regionColor;
|
|
744
710
|
Handles.DrawWireCube(volume.transform.position, volume.transform.localScale);
|
|
745
711
|
}
|
|
746
712
|
|
|
747
|
-
// Draw connection line between zone centers
|
|
748
713
|
Handles.color = Color.red;
|
|
749
714
|
Handles.DrawDottedLine(selectedZoneCenter, zoneCenter, 5f);
|
|
750
715
|
}
|
|
751
716
|
|
|
752
|
-
// Handle landing zone connections
|
|
753
717
|
var landingConnection = _foundConnectivity.landingZones.FirstOrDefault(l => l.landingZone == currentZone);
|
|
754
718
|
if (landingConnection != null)
|
|
755
719
|
{
|
|
756
|
-
// This zone IS a landing zone - show connections to OTHER regions
|
|
757
720
|
foreach (var region in _foundConnectivity.activeRegions)
|
|
758
721
|
{
|
|
759
722
|
if (region == null || region.id.Equals(currentRegion.id)) continue;
|
|
@@ -769,7 +732,6 @@ namespace jeanf.scenemanagement
|
|
|
769
732
|
|
|
770
733
|
var zoneCenter = CalculateZoneCenter(zoneVolumes);
|
|
771
734
|
|
|
772
|
-
// Draw zone volumes
|
|
773
735
|
foreach (var volume in zoneVolumes)
|
|
774
736
|
{
|
|
775
737
|
if (!_regionColors.ContainsKey(region))
|
|
@@ -782,14 +744,12 @@ namespace jeanf.scenemanagement
|
|
|
782
744
|
Handles.DrawWireCube(volume.transform.position, volume.transform.localScale);
|
|
783
745
|
}
|
|
784
746
|
|
|
785
|
-
// Draw landing connection
|
|
786
747
|
Handles.color = Color.yellow;
|
|
787
748
|
Handles.DrawLine(selectedZoneCenter, zoneCenter);
|
|
788
749
|
}
|
|
789
750
|
}
|
|
790
751
|
}
|
|
791
752
|
|
|
792
|
-
// Draw connections FROM other landing zones TO this zone
|
|
793
753
|
foreach (var landing in _foundConnectivity.landingZones)
|
|
794
754
|
{
|
|
795
755
|
if (landing.landingZone == null || landing.region == null) continue;
|
|
@@ -802,31 +762,26 @@ namespace jeanf.scenemanagement
|
|
|
802
762
|
|
|
803
763
|
var landingCenter = CalculateZoneCenter(landingVolumes);
|
|
804
764
|
|
|
805
|
-
// Draw landing zone volumes in blue
|
|
806
765
|
foreach (var volume in landingVolumes)
|
|
807
766
|
{
|
|
808
767
|
Handles.color = Color.blue;
|
|
809
768
|
Handles.DrawWireCube(volume.transform.position, volume.transform.localScale);
|
|
810
769
|
}
|
|
811
770
|
|
|
812
|
-
// Draw connection
|
|
813
771
|
Handles.color = Color.yellow;
|
|
814
772
|
Handles.DrawLine(landingCenter, selectedZoneCenter);
|
|
815
773
|
}
|
|
816
774
|
|
|
817
|
-
// Priority 2: Draw landing zones - blue boxes, same size as volume
|
|
818
775
|
foreach (var landing in _foundConnectivity.landingZones)
|
|
819
776
|
{
|
|
820
777
|
if (landing.landingZone == null || landing.region == null) continue;
|
|
821
|
-
if (landing.landingZone == currentZone) continue;
|
|
778
|
+
if (landing.landingZone == currentZone) continue;
|
|
822
779
|
|
|
823
|
-
// Find all landing zone volumes
|
|
824
780
|
var landingVolumes = System.Array.FindAll(allVolumeAuthorings,
|
|
825
781
|
v => v.zone != null && v.zone.id.Equals(landing.landingZone.id)).ToList();
|
|
826
782
|
|
|
827
783
|
if (landingVolumes.Count == 0) continue;
|
|
828
784
|
|
|
829
|
-
// Draw landing zone volumes in blue, same size as volume
|
|
830
785
|
foreach (var landingVolume in landingVolumes)
|
|
831
786
|
{
|
|
832
787
|
var landingPos = landingVolume.transform.position;
|
|
@@ -837,14 +792,12 @@ namespace jeanf.scenemanagement
|
|
|
837
792
|
}
|
|
838
793
|
}
|
|
839
794
|
|
|
840
|
-
// Priority 1: Draw selected zone volumes last - yellow boxes, actual size
|
|
841
795
|
foreach (var selectedVol in selectedZoneVolumes)
|
|
842
796
|
{
|
|
843
797
|
Handles.color = Color.yellow;
|
|
844
798
|
Handles.DrawWireCube(selectedVol.transform.position, selectedVol.transform.localScale);
|
|
845
799
|
}
|
|
846
800
|
|
|
847
|
-
// Add label for the selected zone at the zone center
|
|
848
801
|
Handles.Label(selectedZoneCenter + Vector3.up * 2f,
|
|
849
802
|
$"SELECTED ZONE\n{currentZone.zoneName}\n({selectedZoneVolumes.Count} volumes)",
|
|
850
803
|
new GUIStyle(GUI.skin.label) {
|
|
@@ -31,6 +31,9 @@ namespace jeanf.scenemanagement
|
|
|
31
31
|
private bool _precomputedDataInitialized;
|
|
32
32
|
private bool _initialRegionDetected;
|
|
33
33
|
|
|
34
|
+
private NativeQueue<FixedString128Bytes> _zoneChangeNotifications;
|
|
35
|
+
private NativeQueue<FixedString128Bytes> _regionChangeNotifications;
|
|
36
|
+
|
|
34
37
|
[BurstCompile]
|
|
35
38
|
public void OnCreate(ref SystemState state)
|
|
36
39
|
{
|
|
@@ -45,6 +48,9 @@ namespace jeanf.scenemanagement
|
|
|
45
48
|
_precomputedCheckableZones = new NativeHashMap<FixedString128Bytes, NativeArray<FixedString128Bytes>>(100, Allocator.Persistent);
|
|
46
49
|
_landingZones = new NativeHashSet<FixedString128Bytes>(50, Allocator.Persistent);
|
|
47
50
|
|
|
51
|
+
_zoneChangeNotifications = new NativeQueue<FixedString128Bytes>(Allocator.Persistent);
|
|
52
|
+
_regionChangeNotifications = new NativeQueue<FixedString128Bytes>(Allocator.Persistent);
|
|
53
|
+
|
|
48
54
|
_currentPlayerZone = new FixedString128Bytes();
|
|
49
55
|
_currentPlayerRegion = new FixedString128Bytes();
|
|
50
56
|
_lastNotifiedZone = new FixedString128Bytes();
|
|
@@ -68,6 +74,9 @@ namespace jeanf.scenemanagement
|
|
|
68
74
|
if (_landingZones.IsCreated) _landingZones.Dispose();
|
|
69
75
|
if (_allZones.IsCreated) _allZones.Dispose();
|
|
70
76
|
|
|
77
|
+
if (_zoneChangeNotifications.IsCreated) _zoneChangeNotifications.Dispose();
|
|
78
|
+
if (_regionChangeNotifications.IsCreated) _regionChangeNotifications.Dispose();
|
|
79
|
+
|
|
71
80
|
if (_precomputedCheckableZones.IsCreated)
|
|
72
81
|
{
|
|
73
82
|
var enumerator = _precomputedCheckableZones.GetEnumerator();
|
|
@@ -81,8 +90,15 @@ namespace jeanf.scenemanagement
|
|
|
81
90
|
}
|
|
82
91
|
}
|
|
83
92
|
|
|
84
|
-
[BurstCompile]
|
|
85
93
|
public void OnUpdate(ref SystemState state)
|
|
94
|
+
{
|
|
95
|
+
ProcessNotificationQueue();
|
|
96
|
+
|
|
97
|
+
OnUpdateBurst(ref state);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
[BurstCompile]
|
|
101
|
+
private void OnUpdateBurst(ref SystemState state)
|
|
86
102
|
{
|
|
87
103
|
_activeVolumes.Clear();
|
|
88
104
|
_toLoadList.Clear();
|
|
@@ -112,6 +128,19 @@ namespace jeanf.scenemanagement
|
|
|
112
128
|
if (relevantPositions.IsCreated) relevantPositions.Dispose();
|
|
113
129
|
}
|
|
114
130
|
|
|
131
|
+
private void ProcessNotificationQueue()
|
|
132
|
+
{
|
|
133
|
+
while (_zoneChangeNotifications.TryDequeue(out var zoneId))
|
|
134
|
+
{
|
|
135
|
+
WorldManager.NotifyZoneChangeFromECS(zoneId);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
while (_regionChangeNotifications.TryDequeue(out var regionId))
|
|
139
|
+
{
|
|
140
|
+
WorldManager.NotifyRegionChangeFromECS(regionId);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
115
144
|
[BurstCompile]
|
|
116
145
|
private FixedString128Bytes CheckVolumesForPlayerZone(ref SystemState state, float3 playerPosition)
|
|
117
146
|
{
|
|
@@ -250,26 +279,24 @@ namespace jeanf.scenemanagement
|
|
|
250
279
|
return _checkableZoneIds.Contains(zoneId);
|
|
251
280
|
}
|
|
252
281
|
|
|
282
|
+
[BurstCompile]
|
|
253
283
|
private void CheckForZoneAndRegionChange(FixedString128Bytes newPlayerZone)
|
|
254
284
|
{
|
|
255
285
|
var zoneChanged = !_currentPlayerZone.Equals(newPlayerZone);
|
|
256
286
|
var newPlayerRegion = new FixedString128Bytes();
|
|
257
287
|
var regionChanged = false;
|
|
258
288
|
|
|
259
|
-
// Always attempt to get region, regardless of zone change
|
|
260
289
|
if (!newPlayerZone.IsEmpty)
|
|
261
290
|
{
|
|
262
291
|
if (_zoneToRegionMap.TryGetValue(newPlayerZone, out newPlayerRegion))
|
|
263
292
|
{
|
|
264
|
-
// FIXED: Detect initial region setup OR actual region change
|
|
265
293
|
regionChanged = !_currentPlayerRegion.Equals(newPlayerRegion) || !_initialRegionDetected;
|
|
266
294
|
}
|
|
267
295
|
}
|
|
268
296
|
else
|
|
269
297
|
{
|
|
270
|
-
// Handle empty zone case - clear region if zone is empty
|
|
271
298
|
regionChanged = !_currentPlayerRegion.IsEmpty;
|
|
272
|
-
newPlayerRegion = new FixedString128Bytes();
|
|
299
|
+
newPlayerRegion = new FixedString128Bytes();
|
|
273
300
|
}
|
|
274
301
|
|
|
275
302
|
// Update internal state FIRST
|
|
@@ -281,26 +308,24 @@ namespace jeanf.scenemanagement
|
|
|
281
308
|
if (regionChanged)
|
|
282
309
|
{
|
|
283
310
|
_currentPlayerRegion = newPlayerRegion;
|
|
284
|
-
_initialRegionDetected = true;
|
|
311
|
+
_initialRegionDetected = true;
|
|
285
312
|
}
|
|
286
313
|
|
|
287
|
-
// Always notify on first detection (bootstrap) or when values actually change
|
|
288
314
|
if (zoneChanged && !newPlayerZone.IsEmpty)
|
|
289
315
|
{
|
|
290
316
|
if (!_lastNotifiedZone.Equals(newPlayerZone))
|
|
291
317
|
{
|
|
292
318
|
_lastNotifiedZone = newPlayerZone;
|
|
293
|
-
|
|
319
|
+
_zoneChangeNotifications.Enqueue(newPlayerZone);
|
|
294
320
|
}
|
|
295
321
|
}
|
|
296
322
|
|
|
297
|
-
// Notify region change including initial detection
|
|
298
323
|
if (regionChanged)
|
|
299
324
|
{
|
|
300
325
|
if (!_lastNotifiedRegion.Equals(newPlayerRegion))
|
|
301
326
|
{
|
|
302
327
|
_lastNotifiedRegion = newPlayerRegion;
|
|
303
|
-
|
|
328
|
+
_regionChangeNotifications.Enqueue(newPlayerRegion);
|
|
304
329
|
}
|
|
305
330
|
}
|
|
306
331
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fr.jeanf.scenemanagement",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.7",
|
|
4
4
|
"displayName": "Scene Management",
|
|
5
5
|
"description": "This package contains two scene loading system, one is additive, the other is to load subscenes. \nBoth system are living side-by-side.\nThe dynamic systems handles the loading of all static content (environment) using subscenes.\nThe additive system loads scene additively depending on zone & region and upon scenario load/unload requests. Each region or scenario can have dependency that will remain loaded until either a region or a scenario became irrelevant.",
|
|
6
6
|
"unity": "2021.3",
|