Skip to content

Commit ca69f35

Browse files
committed
Fixed bug in reveal, disabled medbay reveal to see if it works without it
1 parent 3760167 commit ca69f35

2 files changed

Lines changed: 23 additions & 9 deletions

File tree

Concealment/ConcealGroup.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public class ConcealGroup
1717
/// Entity ID of the first grid in the group.
1818
/// </summary>
1919
public long Id { get; }
20-
public DateTime ConcealTime { get; set; }
20+
public bool IsConcealed { get; set; }
2121
public BoundingBoxD WorldAABB { get; private set; }
2222
public List<MyCubeGrid> Grids { get; }
2323
public List<MyMedicalRoom> MedicalRooms { get; } = new List<MyMedicalRoom>();
@@ -38,6 +38,7 @@ public string GridNames
3838

3939
public void UpdatePostConceal()
4040
{
41+
IsConcealed = true;
4142
UpdateAABB();
4243
CacheSpawns();
4344
HookOnClosing();

Concealment/ConcealmentPlugin.cs

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
using System;
22
using System.Collections.Concurrent;
33
using System.Collections.Generic;
4+
using System.Diagnostics;
45
using System.Linq;
6+
using System.Threading;
57
using System.Threading.Tasks;
68
using System.Windows.Controls;
79
using NLog;
@@ -22,7 +24,7 @@
2224

2325
namespace Concealment
2426
{
25-
[Plugin("Concealment", "1.0", "17f44521-b77a-4e85-810f-ee73311cf75d")]
27+
[Plugin("Concealment", "1.1", "17f44521-b77a-4e85-810f-ee73311cf75d")]
2628
public class ConcealmentPlugin : TorchPluginBase, IWpfPlugin
2729
{
2830
public Persistent<Settings> Settings { get; }
@@ -74,7 +76,7 @@ public override void Update()
7476
if (_init)
7577
return;
7678

77-
MySession.Static.Players.PlayerRequesting += RevealSpawns;
79+
//MySession.Static.Players.PlayerRequesting += RevealSpawns;
7880
MyMultiplayer.Static.ClientJoined += RevealCryoPod;
7981

8082
_init = true;
@@ -183,18 +185,18 @@ private int ConcealGroup(ConcealGroup group)
183185
if (_concealGroups.Any(g => g.Id == group.Id))
184186
return 0;
185187

186-
Log.Info($"Concealing grids: {string.Join(", ", group.Grids.Select(g => g.DisplayName))}");
187-
group.ConcealTime = DateTime.Now;
188+
Log.Info($"Concealing grids: {group.GridNames}");
188189
group.Grids.ForEach(ConcealEntity);
190+
var aabb = group.WorldAABB;
191+
group.ProxyId = _concealedAabbTree.AddProxy(ref aabb, group, 0);
192+
group.Closing += Group_Closing;
189193
Task.Run(() =>
190194
{
191195
group.UpdatePostConceal();
192-
var aabb = group.WorldAABB;
193-
group.ProxyId = _concealedAabbTree.AddProxy(ref aabb, group, 0);
194196
Log.Debug($"Group {group.Id} cached");
197+
group.IsConcealed = true;
195198
Torch.Invoke(() => _concealGroups.Add(group));
196199
});
197-
group.Closing += Group_Closing;
198200
return group.Grids.Count;
199201
}
200202

@@ -205,7 +207,13 @@ private void Group_Closing(ConcealGroup group)
205207

206208
public int RevealGroup(ConcealGroup group)
207209
{
208-
Log.Info($"Revealing grids: {string.Join(", ", group.Grids.Select(g => g.DisplayName))}");
210+
if (!group.IsConcealed)
211+
{
212+
Log.Warn($"Attempted to reveal a group that wasn't concealed: {group.GridNames}");
213+
Log.Warn(new StackTrace());
214+
return 0;
215+
}
216+
Log.Debug($"Revealing grids: {group.GridNames}");
209217
group.Grids.ForEach(RevealEntity);
210218
_concealGroups.Remove(group);
211219
_concealedAabbTree.RemoveProxy(group.ProxyId);
@@ -232,6 +240,8 @@ public int RevealNearbyGrids(double distanceFromPlayers)
232240
foreach (var sphere in playerSpheres)
233241
revealed += RevealGridsInSphere(sphere);
234242

243+
if (revealed != 0)
244+
Log.Info($"Revealed {revealed} grids near players.");
235245
return revealed;
236246
}
237247

@@ -260,6 +270,9 @@ public int ConcealDistantGrids(double distanceFromPlayers)
260270
concealed += ConcealGroup(group);
261271
}
262272

273+
if (concealed != 0)
274+
Log.Info($"Concealed {concealed} grids distant from players.");
275+
263276
return concealed;
264277
}
265278

0 commit comments

Comments
 (0)