From 857ab69c21aedd608f599feb96fad708b6eb7989 Mon Sep 17 00:00:00 2001 From: in0finite Date: Sun, 23 Jan 2022 04:59:52 +0100 Subject: [PATCH] CreateStaticGeometry() and InitStaticGeometry() will only be done once --- Assets/Scripts/Behaviours/World/Cell.cs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/Assets/Scripts/Behaviours/World/Cell.cs b/Assets/Scripts/Behaviours/World/Cell.cs index 91de4930..646d2a58 100644 --- a/Assets/Scripts/Behaviours/World/Cell.cs +++ b/Assets/Scripts/Behaviours/World/Cell.cs @@ -20,7 +20,10 @@ namespace SanAndreasUnity.Behaviours.World private MapObject[] m_cars; private List m_enexes; - public IReadOnlyList CellIds { get; } = Enumerable.Range(0, 19).ToList(); + private bool m_createdStaticGeometry = false; + private bool m_initializedStaticGeometry = false; + + public IReadOnlyList CellIds { get; } = Enumerable.Range(0, 19).ToList(); public bool ignoreLodObjectsWhenInitializing = false; @@ -137,8 +140,13 @@ namespace SanAndreasUnity.Behaviours.World } - internal void CreateStaticGeometry () + public void CreateStaticGeometry () { + if (m_createdStaticGeometry) + return; + + m_createdStaticGeometry = true; + var placements = Item.GetPlacements(CellIds.ToArray()); m_insts = new Dictionary (48 * 1024); @@ -161,8 +169,13 @@ namespace SanAndreasUnity.Behaviours.World this.FocusPointManager = new FocusPointManager(_worldSystem, this.MaxDrawDistance); } - internal void InitStaticGeometry () + public void InitStaticGeometry () { + if (m_initializedStaticGeometry) + return; + + m_initializedStaticGeometry = true; + foreach (var inst in m_insts) { var staticGeometry = inst.Value;