Admin Ghosting

This commit is contained in:
PJB3005
2018-09-20 18:19:04 +02:00
parent 43d5be40f0
commit b92a9b6d1a
8 changed files with 102 additions and 16 deletions

View File

@@ -20,6 +20,13 @@ namespace Content.Client.Input
human.AddFunction(ContentKeyFunctions.UseItemInHand);
human.AddFunction(ContentKeyFunctions.ActivateItemInWorld);
human.AddFunction(ContentKeyFunctions.ThrowItemInHand);
var ghost = contexts.New("ghost", "common");
ghost.AddFunction(EngineKeyFunctions.MoveUp);
ghost.AddFunction(EngineKeyFunctions.MoveDown);
ghost.AddFunction(EngineKeyFunctions.MoveLeft);
ghost.AddFunction(EngineKeyFunctions.MoveRight);
ghost.AddFunction(EngineKeyFunctions.Run);
}
}
}

View 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);
}
}
}
}

View File

@@ -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>

View File

@@ -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);

View File

@@ -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);

View File

@@ -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;
}
}
}

View File

@@ -34,4 +34,5 @@
- me
- ooc
- showtime
- aghost
CanViewVar: true

View File

@@ -57,12 +57,18 @@
save: false
description: Boo!
components:
- type: Sprite
sprite: Mob/observer.png
drawdepth: Mobs
- type: Icon
icon: Mob/observer.png
- type: Physics
mass: 5
- type: Eye
zoom: 0.5, 0.5
- type: BoundingBox
aabb: "-0.5,-0.25,-0.05,0.25"
- type: Input
context: "ghost"
- type: entity
parent: MobObserver
save: false
id: AdminObserver