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

Commit 7c34881

Browse files
committed
Revert Concealment
1 parent 54e3688 commit 7c34881

File tree

10 files changed

+1119
-443
lines changed

10 files changed

+1119
-443
lines changed
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
//26
1+
//27
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.26")]
10-
[assembly: AssemblyVersion("1.13.7.26")]
9+
[assembly: AssemblyFileVersion("1.13.7.27")]
10+
[assembly: AssemblyVersion("1.13.7.27")]

EssentialsPlugin/ChatHandlers/AdminConceal/HandleAdminConceal.cs

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,29 +70,35 @@ public override bool HandleCommand(ulong userId, string[] words)
7070

7171
if (showConcealed)
7272
{
73-
HashSet<MyEntity> entities = new HashSet<MyEntity>();
73+
HashSet<IMyEntity> entities = new HashSet<IMyEntity>();
7474
Wrapper.GameAction(() =>
7575
{
76-
entities=MyEntities.GetEntities();
76+
MyAPIGateway.Entities.GetEntities(entities);
7777
});
7878

7979
Communication.SendPrivateInformation(userId, "==== Concealed Entities ===");
8080
int count = 0;
81-
foreach (MyEntity entity in entities)
81+
foreach (IMyEntity entity in entities)
8282
{
83-
if (!EntityManagement.RemovedGrids.Contains( entity.EntityId ))
83+
if (!(entity is IMyCubeGrid))
8484
continue;
85-
86-
MyCubeGrid grid = (MyCubeGrid)entity;
85+
86+
if (entity.InScene)
87+
continue;
88+
89+
IMyCubeGrid grid = (IMyCubeGrid)entity;
8790
long ownerId = 0;
8891
string ownerName = "";
8992
if (grid.BigOwners.Count > 0)
9093
{
9194
ownerId = grid.BigOwners.First();
92-
ownerName = PlayerMap.Instance.GetPlayerNameFromPlayerId( ownerId );
95+
ownerName = PlayerMap.Instance.GetPlayerItemFromPlayerId(ownerId).Name;
9396
}
94-
95-
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())));
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())));
96102
count++;
97103
}
98104

EssentialsPlugin/ChatHandlers/AdminConceal/HandleAdminReveal.cs

Lines changed: 97 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,22 @@
11
namespace EssentialsPlugin.ChatHandlers.AdminConceal
22
{
3+
using System.Collections.Generic;
34
using System.Linq;
45
using EntityManagers;
56
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;
620

721
public class HandleAdminReveal : ChatHandlerBase
822
{
@@ -18,15 +32,14 @@ public override string GetCommandText()
1832

1933
public override Communication.ServerDialogItem GetHelpDialog( )
2034
{
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-
};
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";
3043
return DialogItem;
3144
}
3245

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

47-
if ( force)
61+
if ( force && !now )
4862
EntityManagement.RevealAll( );
4963

5064
else
5165
{
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 )
52135
Communication.SendPrivateInformation( userId,
53-
$"Command would reveal {EntityManagement.RemovedGrids.Count} grids. Type /admin reveal force to reveal them." );
136+
$"Command would reveal {count} grids. Type /admin reveal force to reveal them." );
137+
138+
else
139+
Communication.SendPrivateInformation(userId, $"Command revealed {count} grids." );
54140
}
55141
return true;
56142
}

0 commit comments

Comments
 (0)