11namespace 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