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

Commit 1ad0e27

Browse files
committed
Fix an issue where revealed ships would collide with the concealed grid and go flying. Altered nobeacon scan, fixed multiple scan commands, threaded grid scanning and group creation; test case went from 20s to 5.
1 parent e2e75a8 commit 1ad0e27

File tree

7 files changed

+186
-450
lines changed

7 files changed

+186
-450
lines changed
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
//53
1+
//75
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.6.53")]
10-
[assembly: AssemblyVersion("1.13.6.53")]
9+
[assembly: AssemblyFileVersion("1.13.6.75")]
10+
[assembly: AssemblyVersion("1.13.6.75")]

EssentialsPlugin/ChatHandlers/Admin/HandleAdminTest.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
namespace EssentialsPlugin.ChatHandlers.Admin
22
{
3+
using Sandbox.Definitions;
34
using Utility;
45
public class HandleAdminTest : ChatHandlerBase
56
{
@@ -36,7 +37,15 @@ public override bool AllowedInConsole()
3637

3738
public override bool HandleCommand( ulong userId, string[ ] words )
3839
{
39-
CargoShips.SpawnCargoShip( );
40+
//CargoShips.SpawnCargoShip( );
41+
foreach ( var material in MyDefinitionManager.Static.GetTransparentMaterialDefinitions( ) )
42+
{
43+
Essentials.Log.Info( material.Texture );
44+
}
45+
foreach (var material in MyDefinitionManager.Static.GetTransparentMaterialDefinitions())
46+
{
47+
Essentials.Log.Info(material.ToString);
48+
}
4049
return true;
4150
}
4251

EssentialsPlugin/ChatHandlers/AdminScan/HandleAdminScanNoBeacon.cs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using Sandbox.Game.Entities.Cube;
1010
using Sandbox.ModAPI;
1111
using Sandbox.ModAPI.Ingame;
12+
using SEModAPI.API.Utility;
1213
using SEModAPIInternal.API.Common;
1314
using SEModAPIInternal.API.Entity.Sector.SectorObject;
1415
using VRage.Game;
@@ -55,23 +56,25 @@ public override bool AllowedInConsole()
5556
public override bool HandleCommand(ulong userId, string[] words)
5657
{
5758
GridLinkTypeEnum connectionType = GridLinkTypeEnum.Logical;
59+
string linkType = "";
5860
if ( words.Length > 0 && words[0].ToLower( ) == "physical" )
59-
connectionType = GridLinkTypeEnum.Physical;
61+
linkType = " physical";
6062

6163
try
62-
{
63-
HashSet<GridGroup> groups = GridGroup.GetAllGroups( connectionType );
64-
int groupsCount = 0;
64+
{
65+
string command = $"excludesblocksubtype:beacon{linkType} quiet";
66+
HashSet<GridGroup> groups = CubeGrids.ScanGrids(0, CommandParser.GetCommandParts(command).ToArray());
67+
int groupsCount = 0;
6568
int gridsCount = 0;
6669

6770
foreach ( var group in groups )
6871
{
69-
if ( !group.CubeBlocks.Any( x => x?.FatBlock is IMyBeacon ) )
70-
{
71-
groupsCount++;
72-
gridsCount += group.Grids.Count;
73-
Communication.SendPrivateInformation( userId, $"Found group with parent {group.Parent.DisplayName} ({group.Parent.EntityId}) at {group.Parent.PositionComp.GetPosition( )} with no beacon." );
74-
}
72+
if ( group.GetFatBlocks( ).Any( x => x is IMyBeacon ) )
73+
continue;
74+
75+
groupsCount++;
76+
gridsCount += group.Grids.Count;
77+
Communication.SendPrivateInformation( userId, $"Found group with parent {group.Parent.DisplayName} ({group.Parent.EntityId}) at {group.Parent.PositionComp.GetPosition( )} with no beacon." );
7578
}
7679

7780
Communication.SendPrivateInformation( userId, $"Found {gridsCount} grids in {groupsCount} groups with no beacon." );

EssentialsPlugin/EntityManagers/EntityManagement.cs

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,9 +1030,9 @@ public static void RevealEntity( KeyValuePair<IMyEntity, string> item )
10301030
ownerId,
10311031
ownerName,
10321032
reason );
1033-
BaseEntityNetworkManager.BroadcastRemoveEntity( entity, false );
1034-
MyMultiplayer.ReplicateImmediatelly( MyExternalReplicable.FindByObject( entity ) );
1035-
}
1033+
entity.Close( );
1034+
//MyMultiplayer.ReplicateImmediatelly( MyExternalReplicable.FindByObject( entity ) );
1035+
}
10361036
else
10371037
{
10381038
if ( !PluginSettings.Instance.DynamicConcealServerOnly )
@@ -1047,9 +1047,10 @@ public static void RevealEntity( KeyValuePair<IMyEntity, string> item )
10471047
RemovedGrids.Add( entity.EntityId );
10481048
entity.InScene = true;
10491049
entity.OnAddedToScene( entity );
1050-
BaseEntityNetworkManager.BroadcastRemoveEntity( entity, false );
1050+
entity.Physics.Enabled = false;
1051+
entity.Close( );
10511052
MyAPIGateway.Entities.AddEntity( newEntity );
1052-
MyMultiplayer.ReplicateImmediatelly( MyExternalReplicable.FindByObject( newEntity ) );
1053+
//MyMultiplayer.ReplicateImmediatelly( MyExternalReplicable.FindByObject( newEntity ) );
10531054
entity.Physics.LinearVelocity = Vector3.Zero;
10541055
entity.Physics.AngularVelocity = Vector3.Zero;
10551056

@@ -1272,3 +1273,21 @@ public static void SetOnline( ulong steamId, bool online )
12721273
}
12731274
}
12741275
}
1276+
/*private static void UnregisterHierarchy(MyEntity entity)
1277+
{
1278+
if (entity.Hierarchy != null)
1279+
{
1280+
foreach (var child in entity.Hierarchy.Children)
1281+
{
1282+
MyEntity childEntity = (MyEntity)child.Container.Entity;
1283+
UnregisterHierarchy(childEntity);
1284+
MyEntities.UnregisterForUpdate(childEntity);
1285+
childEntity.RemoveFromGamePruningStructure();
1286+
1287+
//child.Container.Entity.InScene = false;
1288+
//if (child.Container.Entity.Physics != null)
1289+
// child.Container.Entity.Physics.Enabled = false;
1290+
}
1291+
}
1292+
}
1293+
*/

EssentialsPlugin/ProcessHandlers/ProcessCleanup.cs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,11 @@
33
using System;
44
using System.Collections.Generic;
55
using System.Linq;
6-
using EssentialsPlugin.Settings;
7-
using EssentialsPlugin.Utility;
6+
using Settings;
7+
using Utility;
88
using SEModAPI.API.Utility;
9-
using VRage.Game.Entity;
10-
using VRage.ModAPI;
119

12-
class ProcessCleanup : ProcessHandlerBase
10+
class ProcessCleanup : ProcessHandlerBase
1311
{
1412
private SettingsCleanupTriggerItem _triggerdItem;
1513
private DateTime _start = DateTime.Now;
@@ -64,7 +62,7 @@ private void ProcessTimedItem( SettingsCleanupTimedItem item )
6462

6563
if ( itemTime - DateTime.Now < _oneSecond && DateTime.Now - item.LastRan > _oneMinute )
6664
{
67-
string command = string.Format( "{0} quiet", item.ScanCommand );
65+
string command = $"{item.ScanCommand} quiet";
6866
HashSet<GridGroup> groups = CubeGrids.ScanGrids( 0, CommandParser.GetCommandParts( command ).ToArray( ) );
6967

7068
int groupCount = groups.Count;
@@ -74,7 +72,7 @@ private void ProcessTimedItem( SettingsCleanupTimedItem item )
7472
gridCount += group.Grids.Count;
7573
group.Close( );
7674
}
77-
Communication.SendPublicInformation( $"[NOTICE]: Timed cleanup has run. {gridCount} grids in {groupCount} removed." );
75+
Communication.SendPublicInformation( $"[NOTICE]: Timed cleanup has run. {gridCount} grids in {groupCount} groups removed." );
7876
item.LastRan = DateTime.Now;
7977
item.NotificationItemsRan.Clear( );
8078
return;
@@ -120,7 +118,7 @@ private void ProcessTriggerItem( SettingsCleanupTriggerItem item )
120118

121119
if ( gridsCount >= item.MaxCapacity )
122120
{
123-
Communication.SendPublicInformation( string.Format( "[NOTICE]: Cleanup triggered. ({0} of {1}) triggered grids found. Cleanup will run in {2} minutes. Reason: {3}", gridsCount, item.MaxCapacity, item.MinutesAfterCapacity, item.Reason ) );
121+
Communication.SendPublicInformation( $"[NOTICE]: Cleanup triggered. ({gridsCount} of {item.MaxCapacity}) triggered grids found. Cleanup will run in {item.MinutesAfterCapacity} minutes. Reason: {item.Reason}" );
124122
item.NotificationItemsRan.Clear( );
125123
_triggerdItem = item;
126124
}
@@ -140,7 +138,7 @@ private void ProcessTriggerItem( SettingsCleanupTriggerItem item )
140138
gridCount += group.Grids.Count;
141139
group.Close();
142140
}
143-
Communication.SendPublicInformation( $"[NOTICE]: Triggered cleanup has run. {gridCount} grids in {groups} removed." );
141+
Communication.SendPublicInformation( $"[NOTICE]: Triggered cleanup has run. {gridCount} grids in {groupCount} groups removed." );
144142
_triggerdItem = null;
145143
return;
146144
}

0 commit comments

Comments
 (0)