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

Commit 8def9ba

Browse files
committed
Change back to the new concealment system
1 parent f7ed76e commit 8def9ba

File tree

5 files changed

+384
-1101
lines changed

5 files changed

+384
-1101
lines changed

EssentialsPlugin/ChatHandlers/AdminConceal/HandleAdminConceal.cs

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,7 @@ public override bool AllowedInConsole()
5050

5151
public override bool HandleCommand(ulong userId, string[] words)
5252
{
53-
bool showConcealed = true;
54-
if (words.Length > 0 && words[0].ToLower() == "revealed")
55-
showConcealed = false;
53+
bool showConcealed = !( words.Length > 0 && words[0].ToLower() == "revealed" );
5654

5755
if ( words.Length > 0 && words[0].ToLower( ) == "force" )
5856
{
@@ -70,35 +68,29 @@ public override bool HandleCommand(ulong userId, string[] words)
7068

7169
if (showConcealed)
7270
{
73-
HashSet<IMyEntity> entities = new HashSet<IMyEntity>();
71+
HashSet<MyEntity> entities = new HashSet<MyEntity>();
7472
Wrapper.GameAction(() =>
7573
{
76-
MyAPIGateway.Entities.GetEntities(entities);
74+
entities=MyEntities.GetEntities();
7775
});
7876

7977
Communication.SendPrivateInformation(userId, "==== Concealed Entities ===");
8078
int count = 0;
81-
foreach (IMyEntity entity in entities)
79+
foreach (MyEntity entity in entities)
8280
{
83-
if (!(entity is IMyCubeGrid))
84-
continue;
85-
86-
if (entity.InScene)
81+
if (!EntityManagement.RemovedGrids.Contains( entity.EntityId ))
8782
continue;
88-
89-
IMyCubeGrid grid = (IMyCubeGrid)entity;
83+
84+
MyCubeGrid grid = (MyCubeGrid)entity;
9085
long ownerId = 0;
9186
string ownerName = "";
9287
if (grid.BigOwners.Count > 0)
9388
{
9489
ownerId = grid.BigOwners.First();
95-
ownerName = PlayerMap.Instance.GetPlayerItemFromPlayerId(ownerId).Name;
90+
ownerName = PlayerMap.Instance.GetPlayerNameFromPlayerId( ownerId );
9691
}
97-
98-
if (ownerName == "")
99-
ownerName = "No one";
100-
101-
Communication.SendPrivateInformation(userId, string.Format("Id: {0} Display: {1} OwnerId: {2} OwnerName: {3} Position: {4}", entity.EntityId, entity.DisplayName, ownerId, ownerName, General.Vector3DToString(entity.GetPosition())));
92+
93+
Communication.SendPrivateInformation(userId, string.Format("Id: {0} Display: {1} OwnerId: {2} OwnerName: {3} Position: {4}", entity.EntityId, entity.DisplayName, ownerId, ownerName, General.Vector3DToString(entity.PositionComp.GetPosition())));
10294
count++;
10395
}
10496

EssentialsPlugin/ChatHandlers/AdminConceal/HandleAdminReveal.cs

Lines changed: 11 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,8 @@
11
namespace EssentialsPlugin.ChatHandlers.AdminConceal
22
{
3-
using System.Collections.Generic;
43
using System.Linq;
54
using EntityManagers;
65
using EssentialsPlugin.Utility;
7-
using Sandbox.Common.ObjectBuilders;
8-
using Sandbox.Engine.Multiplayer;
9-
using Sandbox.Game.Entities;
10-
using Sandbox.Game.Replication;
11-
using Sandbox.ModAPI;
12-
using SEModAPIInternal.API.Common;
13-
using SEModAPIInternal.API.Entity;
14-
using VRage.Game;
15-
using VRage.Game.Entity;
16-
using VRage.Game.ModAPI;
17-
using VRage.ModAPI;
18-
using VRage.ObjectBuilders;
19-
using VRageMath;
206

217
public class HandleAdminReveal : ChatHandlerBase
228
{
@@ -32,14 +18,15 @@ public override string GetCommandText()
3218

3319
public override Communication.ServerDialogItem GetHelpDialog( )
3420
{
35-
Communication.ServerDialogItem DialogItem = new Communication.ServerDialogItem( );
36-
DialogItem.title = "Help";
37-
DialogItem.header = "Admin Reveal";
38-
DialogItem.content =
39-
" This command allows you to reveal concealed grids.|" +
40-
"Usage: /admin reveal (force) - this command without 'force' only show you how many grids would be revealed.||" +
41-
"This command will run when concealment is disabled, and respects the update time setting.";
42-
DialogItem.buttonText = "close";
21+
Communication.ServerDialogItem DialogItem = new Communication.ServerDialogItem
22+
{
23+
title = "Help",
24+
header = "Admin Reveal",
25+
content = " This command allows you to reveal concealed grids.|" +
26+
"Usage: /admin reveal (force) - this command without 'force' only show you how many grids would be revealed.||" +
27+
"This command will run when concealment is disabled, and respects the update time setting.",
28+
buttonText = "close"
29+
};
4330
return DialogItem;
4431
}
4532

@@ -56,87 +43,14 @@ public override bool AllowedInConsole()
5643
public override bool HandleCommand(ulong userId, string[] words)
5744
{
5845
bool force = words.FirstOrDefault( x => x.ToLower( ) == "force" ) != null;
59-
bool now = words.Count( ) > 1 && words[1] == "now";
6046

61-
if ( force && !now )
47+
if ( force)
6248
EntityManagement.RevealAll( );
6349

6450
else
6551
{
66-
HashSet<IMyEntity> entities = new HashSet<IMyEntity>( );
67-
Wrapper.GameAction( ( ) => MyAPIGateway.Entities.GetEntities( entities ) );
68-
69-
List<MyObjectBuilder_EntityBase> addList = new List<MyObjectBuilder_EntityBase>( );
70-
int count = 0;
71-
72-
if ( !now )
73-
{
74-
Wrapper.GameAction( ( ) =>
75-
{
76-
foreach ( IMyEntity entity in entities )
77-
{
78-
if ( entity.InScene )
79-
continue;
80-
81-
if ( !(entity is IMyCubeGrid) )
82-
continue;
83-
84-
//if ( now )
85-
// EntityManagement.RevealEntity( new KeyValuePair<IMyEntity, string>( entity, "Immediate force reveal" ) );
86-
87-
count++;
88-
}
89-
} );
90-
}
91-
92-
if ( now )
93-
{
94-
Wrapper.GameAction( ( ) =>
95-
{
96-
foreach ( IMyEntity entity in entities )
97-
{
98-
if ( entity.InScene )
99-
continue;
100-
101-
if ( !(entity is MyCubeGrid) )
102-
continue;
103-
104-
count++;
105-
106-
MyCubeGrid grid = (MyCubeGrid)entity;
107-
MyObjectBuilder_EntityBase builder = grid.GetObjectBuilder( );
108-
109-
long ownerId = 0;
110-
string ownerName = "";
111-
if ( grid.BigOwners.Count > 0 )
112-
{
113-
ownerId = grid.BigOwners.First( );
114-
ownerName = PlayerMap.Instance.GetPlayerItemFromPlayerId( ownerId ).Name;
115-
}
116-
117-
118-
entity.PersistentFlags = (MyPersistentEntityFlags2.InScene | MyPersistentEntityFlags2.CastShadows);
119-
MyAPIGateway.Entities.RemapObjectBuilder( builder );
120-
121-
//Log.Info("Conceal", string.Format("Force Revealing - Id: {0} -> {4} Display: {1} OwnerId: {2} OwnerName: {3}", entity.EntityId, entity.DisplayName.Replace("\r", "").Replace("\n", ""), ownerId, ownerName, builder.EntityId));
122-
Log.Info( "Revealing" );
123-
IMyEntity newEntity = MyAPIGateway.Entities.CreateFromObjectBuilder( builder );
124-
entity.InScene = true;
125-
entity.OnAddedToScene( entity );
126-
entity.Close( );
127-
MyAPIGateway.Entities.AddEntity( newEntity );
128-
MyMultiplayer.ReplicateImmediatelly( MyExternalReplicable.FindByObject( newEntity ) );
129-
entity.Stop( );
130-
}
131-
} );
132-
}
133-
134-
if ( !now )
13552
Communication.SendPrivateInformation( userId,
136-
$"Command would reveal {count} grids. Type /admin reveal force to reveal them." );
137-
138-
else
139-
Communication.SendPrivateInformation(userId, $"Command revealed {count} grids." );
53+
$"Command would reveal {EntityManagement.RemovedGrids.Count} grids. Type /admin reveal force to reveal them." );
14054
}
14155
return true;
14256
}

0 commit comments

Comments
 (0)