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

Commit 0722e34

Browse files
committed
General performance increases with scan, delete, stop chat commands. Remove docking. Tweaks to concealment. Crash fix in player block enforcement. New commands: /admin scan insideplanet /admin delete insideplanet
1 parent e47b14f commit 0722e34

20 files changed

+335
-311
lines changed

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,3 +128,10 @@ $RECYCLE.BIN/
128128
ClientEntityManagement.cs
129129
ProcessClientConceal.cs
130130
packages/*/*
131+
.vs/Supercharger/EssentialsPlugin/code_marker.dat
132+
.vs/Supercharger/EssentialsPlugin/codemap.dat
133+
.vs/Supercharger/EssentialsPlugin/codemap.sync-conflict-20160901-211216.dat
134+
.vs/Supercharger/EssentialsPlugin/global_history.dat
135+
.vs/Supercharger/EssentialsPlugin/global_history.sync-conflict-20160901-211216.dat
136+
.vs/Supercharger/EssentialsPlugin/rich_code_format.dat
137+
.vs/Supercharger/EssentialsPlugin/workbench.dat
0 Bytes
Binary file not shown.
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
//243
1+
//257
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.243")]
10-
[assembly: AssemblyVersion("1.13.7.243")]
9+
[assembly: AssemblyFileVersion("1.13.7.257")]
10+
[assembly: AssemblyVersion("1.13.7.257")]

EssentialsPlugin/ChatHandlers/Admin/HandleAdminOwnershipChange.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public class HandleAdminOwnershipChange : ChatHandlerBase
1616
{
1717
public override string GetHelp( )
1818
{
19-
return "This command allows you to change the ownership of a ship. Usage: /admin ownership change <entityId> <PlayerName>";
19+
return "This command allows you to change the ownership of a ship. Usage: /admin ownership change <entityId/entityName> <PlayerName>";
2020
}
2121
public override string GetCommandText( )
2222
{

EssentialsPlugin/ChatHandlers/Admin/HandleAdminStop.cs

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
using VRageMath;
1414
using Sandbox.Game.Entities;
1515
using Sandbox.Game.Entities.Cube;
16+
using VRage.Game.Entity;
1617
using VRage.Game.ModAPI;
1718

1819
public class HandleAdminStop : ChatHandlerBase
@@ -77,25 +78,23 @@ public override bool HandleCommand( ulong userId, string[ ] words )
7778
// arg_ships = true;
7879
// arg_piloted = true;
7980
//}
80-
HashSet<IMyEntity> entities = new HashSet<IMyEntity>( );
81+
HashSet<MyEntity> entities = new HashSet<MyEntity>( );
8182
Wrapper.GameAction( ( ) =>
82-
{
83-
MyAPIGateway.Entities.GetEntities( entities );
84-
} );
83+
{
84+
entities = MyEntities.GetEntities( );
85+
} );
8586

86-
foreach ( IMyEntity entity in entities )
87+
foreach ( MyEntity entity in entities )
8788
{
8889
bool found = false;
89-
if ( entity == null )
90-
continue;
9190

92-
if ( entity.Physics == null )
91+
if ( entity?.Physics == null )
9392
continue;
9493

9594
//if ( !(entity is IMyCubeGrid) || !(entity is IMyFloatingObject) || !(entity is MyInventoryBagEntity) )
9695
// continue;
9796

98-
if ( arg_ships && entity is IMyCubeGrid )
97+
if ( arg_ships && entity is MyCubeGrid )
9998
{
10099
//TODO: find a way to stop piloted ships
101100
//even if we try to stop the grid entity, it won't work if there's a pilot
@@ -119,10 +118,10 @@ public override bool HandleCommand( ulong userId, string[ ] words )
119118
*/
120119
Stop( entity.GetTopMostParent( ) );
121120
}
122-
else if ( arg_floating && (entity is IMyFloatingObject || entity is MyInventoryBagEntity) )
121+
else if ( arg_floating && (entity is MyFloatingObject || entity is MyInventoryBagEntity) )
123122
Stop( entity );
124123
}
125-
Communication.SendPrivateInformation( userId, count.ToString( ) + " entities have been stopped." );
124+
Communication.SendPrivateInformation( userId, count + " entities have been stopped." );
126125
count = 0;
127126
return true;
128127
}
@@ -133,11 +132,10 @@ private static void Stop( IMyEntity entity )
133132
if ( entity.Physics.LinearVelocity == Vector3D.Zero && entity.Physics.AngularVelocity == Vector3D.Zero )
134133
return;
135134

136-
Wrapper.GameAction( ( ) =>
135+
Wrapper.BeginGameAction( ( ) =>
137136
{
138-
entity.Physics.LinearVelocity = Vector3D.Zero;
139-
entity.Physics.AngularVelocity = Vector3D.Zero;
140-
} );
137+
entity.Physics.SetSpeeds( Vector3.Zero, Vector3.Zero );
138+
}, null, null );
141139
++count;
142140
}
143141

EssentialsPlugin/ChatHandlers/AdminDelete/HandleAdminDeleteFloating.cs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
using SEModAPIInternal.API.Entity.Sector.SectorObject;
1212
using SEModAPIInternal.API.Entity.Sector.SectorObject.CubeGrid;
1313
using SEModAPIInternal.API.Entity.Sector.SectorObject.CubeGrid.CubeBlock;
14+
using VRage.Game.Entity;
1415
using VRage.Game.ModAPI;
1516
using VRage.ModAPI;
1617
public class HandleAdminDeleteFloating : ChatHandlerBase
@@ -47,26 +48,19 @@ public override bool AllowedInConsole( )
4748
public override bool HandleCommand( ulong userId, string[ ] words )
4849
{
4950
int count = 0;
50-
HashSet<IMyEntity> entities = new HashSet<IMyEntity>( );
51+
HashSet<MyEntity> entities = new HashSet<MyEntity>( );
5152

52-
Wrapper.GameAction( ( ) =>
53-
{
54-
MyAPIGateway.Entities.GetEntities( entities );
55-
} );
53+
Wrapper.GameAction( ( ) => entities = MyEntities.GetEntities( ) );
5654

57-
foreach ( IMyEntity entity in entities )
55+
foreach ( MyEntity entity in entities )
5856
{
5957
if ( entity == null )
6058
continue;
6159

62-
if ( entity is IMyFloatingObject || entity is MyInventoryBagEntity || entity is IMyMeteor )
60+
if ( entity is MyFloatingObject || entity is MyInventoryBagEntity || entity is MyMeteor )
6361
{
6462
count++;
65-
Wrapper.GameAction(()=>
66-
{
67-
entity.Close( );
68-
} );
69-
//MyMultiplayer.ReplicateImmediatelly( MyExternalReplicable.FindByObject( entity ) );
63+
Wrapper.BeginGameAction( entity.Close, null, null );
7064
}
7165
}
7266
Communication.SendPrivateInformation( userId, count.ToString( ) + " floating objects deleted." );
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
namespace EssentialsPlugin.ChatHandlers
2+
{
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
using EssentialsPlugin.Utility;
6+
using Sandbox.Game.Entities;
7+
using Sandbox.Game.Entities.Character;
8+
using VRageMath;
9+
10+
public class HandleAdminDeleteInsidePlanet : ChatHandlerBase
11+
{
12+
public override string GetHelp()
13+
{
14+
return "This command allows you to delete entities that are trapped inside planets. Usage /admin delete insideplanet";
15+
}
16+
public override string GetCommandText()
17+
{
18+
return "/admin delete insideplanet";
19+
}
20+
21+
public override bool IsAdminCommand()
22+
{
23+
return true;
24+
}
25+
26+
public override bool AllowedInConsole()
27+
{
28+
return true;
29+
}
30+
31+
public override bool HandleCommand(ulong userId, string[] words)
32+
{
33+
var entities = MyEntities.GetEntities( ).ToArray( );
34+
var planets = new HashSet<MyPlanet>( );
35+
int count = 0;
36+
foreach (var entity in entities)
37+
{
38+
MyPlanet item = entity as MyPlanet;
39+
if (item != null)
40+
planets.Add( item );
41+
}
42+
43+
foreach (var planet in planets)
44+
{
45+
var sphere25 = new BoundingSphereD(planet.PositionComp.GetPosition(), planet.MinimumRadius * 0.25);
46+
var sphere75 = new BoundingSphereD(planet.PositionComp.GetPosition(), planet.MinimumRadius * 0.75);
47+
foreach (var entity in entities)
48+
{
49+
if (entity.MarkedForClose || entity.Physics == null || entity is MyCharacter)
50+
continue;
51+
52+
if (sphere25.Contains(entity.PositionComp.GetPosition()) != ContainmentType.Disjoint)
53+
{
54+
count++;
55+
Wrapper.BeginGameAction( entity.Close, null, null );
56+
continue;
57+
}
58+
59+
if (Vector3.IsZero(entity.Physics.LinearVelocity))
60+
continue;
61+
62+
if (sphere75.Contains(entity.PositionComp.GetPosition()) == ContainmentType.Disjoint)
63+
continue;
64+
65+
count++;
66+
Wrapper.BeginGameAction(entity.Close, null, null);
67+
}
68+
}
69+
70+
Communication.SendPrivateInformation( userId, $"Deleted {count} entities trapped in planets." );
71+
return true;
72+
}
73+
}
74+
}

EssentialsPlugin/ChatHandlers/AdminScan/HandleAdminScanAreaAt.cs

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44
using System.Linq;
55
using EssentialsPlugin.Utility;
66
using Sandbox.Common.ObjectBuilders;
7+
using Sandbox.Game.Entities;
78
using Sandbox.ModAPI;
89
using VRage.Game;
10+
using VRage.Game.Entity;
911
using VRage.Game.ModAPI;
1012
using VRage.ModAPI;
1113
using VRageMath;
@@ -71,19 +73,21 @@ public override bool HandleCommand(ulong userId, string[] words)
7173
List<MyObjectBuilder_CubeGrid> gridsToMove = new List<MyObjectBuilder_CubeGrid>();
7274
BoundingSphereD sphere = new BoundingSphereD(startPosition, radius);
7375
List<IMyEntity> entitiesToMove = MyAPIGateway.Entities.GetEntitiesInSphere(ref sphere);
74-
int count = 0;
76+
List<MyEntity> entities;
77+
int count = 0;
78+
Wrapper.GameAction( ( ) =>
79+
{
80+
entities = MyEntities.GetTopMostEntitiesInSphere( ref sphere );
7581

76-
Wrapper.GameAction(() =>
77-
{
78-
foreach (IMyEntity entity in entitiesToMove)
79-
{
80-
if (!(entity is IMyCubeGrid))
81-
continue;
82+
foreach (MyEntity entity in entities)
83+
{
84+
if (!( entity is MyCubeGrid ))
85+
continue;
8286

83-
Communication.SendPrivateInformation(userId, string.Format("Found ship '{0}' ({1}) at {2}", entity.DisplayName, entity.EntityId, General.Vector3DToString(entity.GetPosition())));
84-
count++;
85-
}
86-
});
87+
Communication.SendPrivateInformation( userId, string.Format( "Found ship '{0}' ({1}) at {2}", entity.DisplayName, entity.EntityId, General.Vector3DToString( entity.PositionComp.GetPosition( ) ) ) );
88+
count++;
89+
}
90+
} );
8791

8892
Communication.SendPrivateInformation(userId, string.Format("Total ships found: {0}", count));
8993
return true;
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
namespace EssentialsPlugin.ChatHandlers
2+
{
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
using EssentialsPlugin.Utility;
6+
using Sandbox.Game.Entities;
7+
using Sandbox.Game.Entities.Character;
8+
using VRageMath;
9+
10+
public class HandleAdminScanInsidePlanet : ChatHandlerBase
11+
{
12+
public override string GetHelp()
13+
{
14+
return "This command allows you to scan for entities that are trapped inside planets. Usage /admin scan insideplanet";
15+
}
16+
public override string GetCommandText()
17+
{
18+
return "/admin scan insideplanet";
19+
}
20+
21+
public override bool IsAdminCommand()
22+
{
23+
return true;
24+
}
25+
26+
public override bool AllowedInConsole()
27+
{
28+
return true;
29+
}
30+
31+
public override bool HandleCommand(ulong userId, string[] words)
32+
{
33+
var entities = MyEntities.GetEntities( ).ToArray( );
34+
var planets = new HashSet<MyPlanet>( );
35+
int count = 0;
36+
foreach (var entity in entities)
37+
{
38+
MyPlanet item = entity as MyPlanet;
39+
if (item != null)
40+
planets.Add( item );
41+
}
42+
43+
foreach (var planet in planets)
44+
{
45+
var sphere25 = new BoundingSphereD( planet.PositionComp.GetPosition( ), planet.MinimumRadius * 0.25 );
46+
var sphere75 = new BoundingSphereD( planet.PositionComp.GetPosition( ), planet.MinimumRadius * 0.75 );
47+
foreach (var entity in entities)
48+
{
49+
if (entity.MarkedForClose || entity.Physics == null || entity is MyCharacter)
50+
continue;
51+
52+
if (sphere25.Contains( entity.PositionComp.GetPosition( ) ) != ContainmentType.Disjoint)
53+
{
54+
count++;
55+
continue;
56+
}
57+
58+
if (Vector3.IsZero( entity.Physics.LinearVelocity ))
59+
continue;
60+
61+
if (sphere75.Contains( entity.PositionComp.GetPosition( ) ) == ContainmentType.Disjoint)
62+
continue;
63+
64+
count++;
65+
}
66+
}
67+
68+
Communication.SendPrivateInformation( userId, $"Found {count} entities trapped in planets." );
69+
return true;
70+
}
71+
}
72+
}

EssentialsPlugin/ChatHandlers/ChatHandlerBase.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@ public abstract class ChatHandlerBase
1313
protected static readonly Logger Log = LogManager.GetLogger( "PluginLog" );
1414
public ChatHandlerBase( )
1515
{
16-
if ( ExtenderOptions.IsDebugging )
17-
Log.Debug( $"Added chat handler: {GetCommandText()}" );
18-
}
16+
#if DEBUG
17+
Log.Debug( $"Added chat handler: {GetCommandText()}" );
18+
#endif
19+
}
1920

2021
public virtual Boolean CanHandle(ulong steamId, String[] words, ref int commandCount)
2122
{

0 commit comments

Comments
 (0)