Skip to content

Commit 710c47d

Browse files
committed
Make concealed grids static
1 parent b3c2f1e commit 710c47d

2 files changed

Lines changed: 19 additions & 8 deletions

File tree

‎Concealment/ConcealGroup.cs‎

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,12 @@ public class ConcealGroup
2323
/// Entity ID of the first grid in the group.
2424
/// </summary>
2525
public long Id { get; }
26-
public bool IsConcealed { get; set; }
26+
public bool IsConcealed { get; private set; }
2727
public BoundingBoxD WorldAABB { get; private set; }
2828
public List<MyCubeGrid> Grids { get; }
2929
public List<MyMedicalRoom> MedicalRooms { get; } = new List<MyMedicalRoom>();
3030
public List<MyCryoChamber> CryoChambers { get; } = new List<MyCryoChamber>();
31+
private Dictionary<long, bool> _unstatic = new Dictionary<long, bool>();
3132
public event Action<ConcealGroup> Closing;
3233
internal volatile int ProxyId = -1;
3334

@@ -131,9 +132,15 @@ public bool IsCryoOccupied(ulong steamId)
131132
/// </summary>
132133
public void Conceal()
133134
{
134-
foreach (var body in Grids)
135-
if (body.Parent == null)
136-
UnregisterRecursive(body);
135+
_unstatic.Clear();
136+
foreach (var grid in Grids)
137+
{
138+
_unstatic[grid.EntityId] = !grid.IsStatic;
139+
grid.ConvertToStatic();
140+
141+
if (grid.Parent == null)
142+
UnregisterRecursive(grid);
143+
}
137144

138145
//foreach (var entity in Grids)
139146
// if (entity.Parent == null)
@@ -160,9 +167,14 @@ public void Reveal()
160167
// if (entity.Parent == null)
161168
// MyGamePruningStructure.Add(entity);
162169

163-
foreach (var entity in Grids)
164-
if (entity.Parent == null)
165-
RegisterRecursive(entity);
170+
foreach (var grid in Grids)
171+
{
172+
if (_unstatic[grid.EntityId])
173+
grid.OnConvertToDynamic();
174+
175+
if (grid.Parent == null)
176+
RegisterRecursive(grid);
177+
}
166178

167179
void RegisterRecursive(IMyEntity e)
168180
{

‎Concealment/ConcealmentPlugin.cs‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,6 @@ private int ConcealGroup(ConcealGroup group)
236236
{
237237
group.UpdatePostConceal();
238238
Log.Debug($"Group {group.Id} cached");
239-
group.IsConcealed = true;
240239
Torch.Invoke(() => ConcealedGroups.Add(group));
241240
});
242241
return group.Grids.Count;

0 commit comments

Comments
 (0)