Admin Ghosting
This commit is contained in:
40
Content.Server/Administration/AGhost.cs
Normal file
40
Content.Server/Administration/AGhost.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using Content.Server.Players;
|
||||
using SS14.Server.Interfaces.Console;
|
||||
using SS14.Server.Interfaces.Player;
|
||||
using SS14.Shared.Interfaces.GameObjects;
|
||||
using SS14.Shared.IoC;
|
||||
|
||||
namespace Content.Server.Administration
|
||||
{
|
||||
public class AGhost : IClientCommand
|
||||
{
|
||||
public string Command => "aghost";
|
||||
public string Description => "Makes you an admin ghost.";
|
||||
public string Help => "aghost";
|
||||
|
||||
public void Execute(IConsoleShell shell, IPlayerSession player, string[] args)
|
||||
{
|
||||
if (player == null)
|
||||
{
|
||||
shell.SendText((IPlayerSession) null, "Nah");
|
||||
return;
|
||||
}
|
||||
|
||||
var mind = player.ContentData().Mind;
|
||||
if (mind.VisitingEntity != null && mind.VisitingEntity.Prototype.ID == "AdminObserver")
|
||||
{
|
||||
var visiting = mind.VisitingEntity;
|
||||
mind.UnVisit();
|
||||
visiting.Delete();
|
||||
}
|
||||
else
|
||||
{
|
||||
var entityManager = IoCManager.Resolve<IEntityManager>();
|
||||
var ghost = entityManager.ForceSpawnEntityAt("AdminObserver",
|
||||
player.AttachedEntity.Transform.LocalPosition);
|
||||
|
||||
mind.Visit(ghost);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -63,6 +63,7 @@
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Administration\AGhost.cs" />
|
||||
<Compile Include="AI\AimShootLifeProcessor.cs" />
|
||||
<Compile Include="EntryPoint.cs" />
|
||||
<Compile Include="GameObjects\Components\Doors\ServerDoorComponent.cs" />
|
||||
@@ -162,5 +163,4 @@
|
||||
<Compile Include="GameObjects\Components\Construction\ConstructorComponent.cs" />
|
||||
<Compile Include="GameObjects\Components\Construction\ConstructionComponent.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
</Project>
|
||||
</Project>
|
||||
@@ -213,7 +213,7 @@ namespace Content.Server
|
||||
}
|
||||
else
|
||||
{
|
||||
if (data.Mind.CurrentMob == null)
|
||||
if (data.Mind.CurrentEntity == null)
|
||||
{
|
||||
var mob = SpawnPlayerMob();
|
||||
data.Mind.TransferTo(mob);
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace Content.Server.Mobs
|
||||
var mind = data.ContentData().Mind;
|
||||
|
||||
var builder = new StringBuilder();
|
||||
builder.AppendFormat("player: {0}, mob: {1}\nroles: ", mind.SessionId, mind.CurrentMob?.Owner?.Uid);
|
||||
builder.AppendFormat("player: {0}, mob: {1}\nroles: ", mind.SessionId, mind.OwnedMob?.Owner?.Uid);
|
||||
foreach (var role in mind.AllRoles)
|
||||
{
|
||||
builder.AppendFormat("{0} ", role.Name);
|
||||
|
||||
@@ -36,29 +36,42 @@ namespace Content.Server.Mobs
|
||||
/// <summary>
|
||||
/// The session ID of the player owning this mind.
|
||||
/// </summary>
|
||||
[ViewVariables]
|
||||
public NetSessionId SessionId { get; }
|
||||
|
||||
[ViewVariables]
|
||||
public bool IsVisitingEntity => VisitingEntity != null;
|
||||
|
||||
[ViewVariables]
|
||||
public IEntity VisitingEntity { get; private set; }
|
||||
|
||||
[ViewVariables] public IEntity CurrentEntity => VisitingEntity ?? OwnedEntity;
|
||||
|
||||
/// <summary>
|
||||
/// The component currently owned by this mind.
|
||||
/// Can be null.
|
||||
/// </summary>
|
||||
public MindComponent CurrentMob { get; private set; }
|
||||
[ViewVariables]
|
||||
public MindComponent OwnedMob { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The entity currently owned by this mind.
|
||||
/// Can be null.
|
||||
/// </summary>
|
||||
public IEntity CurrentEntity => CurrentMob?.Owner;
|
||||
[ViewVariables]
|
||||
public IEntity OwnedEntity => OwnedMob?.Owner;
|
||||
|
||||
/// <summary>
|
||||
/// An enumerable over all the roles this mind has.
|
||||
/// </summary>
|
||||
[ViewVariables]
|
||||
public IEnumerable<Role> AllRoles => _roles.Values;
|
||||
|
||||
/// <summary>
|
||||
/// The session of the player owning this mind.
|
||||
/// Can be null, in which case the player is currently not logged in.
|
||||
/// </summary>
|
||||
[ViewVariables]
|
||||
public IPlayerSession Session
|
||||
{
|
||||
get
|
||||
@@ -186,15 +199,34 @@ namespace Content.Server.Mobs
|
||||
}
|
||||
}
|
||||
|
||||
CurrentMob?.InternalEjectMind();
|
||||
CurrentMob = component;
|
||||
CurrentMob?.InternalAssignMind(this);
|
||||
OwnedMob?.InternalEjectMind();
|
||||
OwnedMob = component;
|
||||
OwnedMob?.InternalAssignMind(this);
|
||||
|
||||
// Player is CURRENTLY connected.
|
||||
if (Session != null && CurrentMob != null)
|
||||
if (Session != null && OwnedMob != null)
|
||||
{
|
||||
Session.AttachToEntity(entity);
|
||||
}
|
||||
|
||||
VisitingEntity = null;
|
||||
}
|
||||
|
||||
public void Visit(IEntity entity)
|
||||
{
|
||||
Session?.AttachToEntity(entity);
|
||||
VisitingEntity = entity;
|
||||
}
|
||||
|
||||
public void UnVisit()
|
||||
{
|
||||
if (!IsVisitingEntity)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Session?.AttachToEntity(OwnedEntity);
|
||||
VisitingEntity = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user