Skip to content
This repository was archived by the owner on Jun 23, 2023. It is now read-only.

Commit f278876

Browse files
committed
Fixed crash in concealment, tweaks to player block enforcement, added option to turn off physics for concealed grids, tweak to grid groups
1 parent 3a21403 commit f278876

File tree

7 files changed

+61
-51
lines changed

7 files changed

+61
-51
lines changed
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
//1
1+
//4
22
//
33
// This code was generated by a tool. Any changes made manually will be lost
44
// the next time this code is regenerated.
55
//
66

77
using System.Reflection;
88

9-
[assembly: AssemblyFileVersion("1.13.7.1")]
10-
[assembly: AssemblyVersion("1.13.7.1")]
9+
[assembly: AssemblyFileVersion("1.13.7.4")]
10+
[assembly: AssemblyVersion("1.13.7.4")]

EssentialsPlugin/EntityManagers/EntityManagement.cs

Lines changed: 17 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,27 @@
1-
using Sandbox.Game.Entities;
2-
using VRage.Game.Entity;
3-
4-
namespace EssentialsPlugin.EntityManagers
1+
namespace EssentialsPlugin.EntityManagers
52
{
63
using System;
7-
using System.Collections;
84
using System.Collections.Generic;
95
using System.Linq;
106
using System.Threading;
117
using EssentialsPlugin.ProcessHandlers;
128
using EssentialsPlugin.Utility;
13-
using Sandbox.Common;
14-
using Sandbox.Common.ObjectBuilders;
159
using Sandbox.ModAPI;
1610
using Sandbox.ModAPI.Ingame;
1711
using SEModAPIInternal.API.Common;
18-
using SEModAPIInternal.API.Entity;
1912
using VRage.ModAPI;
2013
using VRage.ObjectBuilders;
2114
using VRageMath;
22-
using IMyFunctionalBlock = Sandbox.ModAPI.Ingame.IMyFunctionalBlock;
2315
using IMyProductionBlock = Sandbox.ModAPI.Ingame.IMyProductionBlock;
24-
using IMyTerminalBlock = Sandbox.ModAPI.Ingame.IMyTerminalBlock;
25-
using Sandbox.Engine.Multiplayer;
26-
using Sandbox.Game.Replication;
2716
using Sandbox.Game.Entities;
28-
using Sandbox.Game.Multiplayer;
2917
using Sandbox.Game.World;
30-
using VRage.Collections;
3118
using Sandbox.Game.Entities.Blocks;
32-
using Sandbox.Game.Entities.Character;
3319
using Sandbox.Game.Entities.Cube;
3420
using SpaceEngineers.Game.ModAPI.Ingame;
3521
using VRage.Game;
3622
using VRage.Game.Entity;
3723
using VRage.Game.ModAPI;
38-
39-
class ConcealItem
40-
{
41-
public ConcealItem( IMyEntity _entity, string _reason )
42-
{
43-
this.entity = _entity;
44-
this.reason = _reason;
45-
}
46-
public ConcealItem( KeyValuePair<IMyEntity, string> kvp )
47-
{
48-
this.entity = kvp.Key;
49-
this.reason = kvp.Value;
50-
}
51-
52-
public IMyEntity entity;
53-
public string reason;
54-
}
55-
24+
5625
public class EntityManagement
5726
{
5827
private static volatile bool _checkReveal;
@@ -322,7 +291,7 @@ public static void CheckAndRevealEntitiesObsolete()
322291
if (entity.InScene)
323292
continue;
324293

325-
RevealEntityObsolete(new KeyValuePair<IMyEntity, string>(entity, "Obsolete Reveal"));
294+
Wrapper.GameAction( () => RevealEntityObsolete( new KeyValuePair<IMyEntity, string>( entity, "Obsolete Reveal" ) ) );
326295
}
327296

328297
DateTime reStart = DateTime.Now;
@@ -696,8 +665,12 @@ private static void UnregisterHierarchy( MyEntity entity )
696665
childEntity.RemoveFromGamePruningStructure();
697666

698667
//child.Container.Entity.InScene = false;
699-
//if (child.Container.Entity.Physics != null)
700-
// child.Container.Entity.Physics.Enabled = false;
668+
669+
if ( !PluginSettings.Instance.DynamicConcealPhysics )
670+
continue;
671+
672+
if (child.Container.Entity.Physics != null)
673+
child.Container.Entity.Physics.Enabled = false;
701674
}
702675

703676
UnregisteredEntities.Add( entity );
@@ -715,14 +688,16 @@ private static void ReregisterHierarchy( MyEntity entity )
715688
MyEntities.RegisterForUpdate(childEntity);
716689
childEntity.AddToGamePruningStructure();
717690

718-
//child.Container.Entity.InScene = false;
719-
//if (child.Container.Entity.Physics != null)
720-
// child.Container.Entity.Physics.Enabled = false;
691+
//child.Container.Entity.InScene = true;
692+
693+
if (!PluginSettings.Instance.DynamicConcealPhysics)
694+
continue;
695+
696+
if (child.Container.Entity.Physics != null)
697+
child.Container.Entity.Physics.Enabled = true;
721698
}
722699

723700
UnregisteredEntities.Remove( entity );
724701
}
725702
}
726-
}
727-
728-
//TODO: command to remove dead owners from grid
703+
}

EssentialsPlugin/Essentials.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,23 @@ public bool DynamicConcealPirates
649649
}
650650
}
651651

652+
[Category("Dynamic Entity Management")]
653+
[DisplayName("ConcealPhysics")]
654+
[Description("Setting this option will turn off physics on concealed grids.")]
655+
[Browsable(true)]
656+
[ReadOnly(false)]
657+
public bool DynamicConcealPhysics
658+
{
659+
get
660+
{
661+
return PluginSettings.Instance.DynamicConcealPhysics;
662+
}
663+
set
664+
{
665+
PluginSettings.Instance.DynamicConcealPhysics = value;
666+
}
667+
}
668+
652669
[Category( "Dynamic Entity Management" )]
653670
[DisplayName( "Conceal Distance" )]
654671
[Description( "The distance a player must be from a grid for it to be revealed due to distance. The smaller this value is, the longer a grid will be hidden from sight. Default is 8000m (max view distance)" )]

EssentialsPlugin/Settings/PluginSettings.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ public class PluginSettings
8686
private bool _dynamicConcealIncludeMedBays;
8787
private bool _dynamicShowMessages;
8888
private bool _dynamicConcealPirates;
89+
private bool _dynamicConcealPhysics;
8990
private bool _dynamicTurretManagementEnabled;
9091
private int _dynamicTurretTargetDistance;
9192
private bool _dynamicTurretAllowExemption;
@@ -622,6 +623,16 @@ public bool DynamicConcealPirates
622623
}
623624
}
624625

626+
public bool DynamicConcealPhysics
627+
{
628+
get {return _dynamicConcealPhysics;}
629+
set
630+
{
631+
_dynamicConcealPhysics = value;
632+
Save();
633+
}
634+
}
635+
625636
public float DynamicConcealDistance
626637
{
627638
get { return _dynamicConcealDistance; }
@@ -842,6 +853,8 @@ public bool PlayerBlockEnforcementEnabled
842853
set
843854
{
844855
_playerBlockEnforcementEnabled = value;
856+
if(value)
857+
PlayerBlockEnforcement.Init();
845858
Save();
846859
}
847860
}
@@ -1044,6 +1057,7 @@ public PluginSettings()
10441057

10451058
_dynamicConcealDistance = 8000;
10461059
_dynamicConcealPirates = false;
1060+
_dynamicConcealPhysics = false;
10471061
_dynamicShowMessages = false;
10481062
_dynamicTurretTargetDistance = 2000;
10491063
_dynamicTurretManagementEnabled = false;

EssentialsPlugin/Utility/Communication.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ public static void ReceiveMessageParts(byte[] data)
372372
} );
373373
}
374374

375-
private static Dictionary<int, PartialMessage> messages = new Dictionary<int, PartialMessage>();
375+
private static Dictionary<int, PartialMessage> messages = new Dictionary<int, PartialMessage>();
376376
private const int PACKET_SIZE = 4096;
377377
private const int META_SIZE = sizeof(int) * 2;
378378
private const int DATA_LENGTH = PACKET_SIZE - META_SIZE;

EssentialsPlugin/Utility/GridGroup.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,9 @@ public static HashSet<GridGroup> GetGroups( HashSet<MyEntity> entities, GridLink
129129
return;
130130

131131
lock (result)
132-
if (result.Any( x => x.Grids.Contains( grid ) ))
133-
return;
132+
foreach(var item in result)
133+
if ( item._grids.Contains( grid ) )
134+
return;
134135

135136
var newGroup = new GridGroup( grid, linkType );
136137

EssentialsPlugin/Utility/PlayerBlockEnforcement.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ public static class PlayerBlockEnforcement
2727

2828
public static void Init()
2929
{
30+
if ( !PluginSettings.Instance.PlayerBlockEnforcementEnabled )
31+
return;
32+
3033
if (_init)
3134
return;
3235

@@ -168,7 +171,7 @@ private static void ProcessEnforcement( MyCubeBlock newBlock = null)
168171

169172
Task.Run( () =>
170173
{
171-
Essentials.Log.Debug( "process enforcement" );
174+
//Essentials.Log.Debug( "process enforcement" );
172175
foreach ( var item in PluginSettings.Instance.PlayerBlockEnforcementItems )
173176
{
174177
string blockSearch;
@@ -226,11 +229,11 @@ private static void ProcessEnforcement( MyCubeBlock newBlock = null)
226229
if ( ( searchSubType && cubeBlock.BlockDefinition.Id.SubtypeId.ToString().Contains( blockSearch ) )
227230
|| ( !searchSubType && cubeBlock.BlockDefinition.Id.TypeId.ToString().Contains( blockSearch ) ) )
228231
{
229-
Essentials.Log.Debug( $"found block: {cubeBlock.BlockDefinition.Id.SubtypeName}" );
232+
//Essentials.Log.Debug( $"found block: {cubeBlock.BlockDefinition.Id.SubtypeName}" );
230233

231234
if ( MySession.Static.Players.IdentityIsNpc( cubeBlock.OwnerId ) )
232235
{
233-
Essentials.Log.Debug( "not processing NPC owned block" );
236+
//Essentials.Log.Debug( "not processing NPC owned block" );
234237
continue;
235238
}
236239

0 commit comments

Comments
 (0)