Fix can't return to body bug (#4424)
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
using Content.Server.Ghost.Components;
|
using Content.Server.Ghost.Components;
|
||||||
using Content.Server.Players;
|
using Content.Server.Players;
|
||||||
using Content.Shared.Administration;
|
using Content.Shared.Administration;
|
||||||
|
using Content.Shared.Ghost;
|
||||||
using Robust.Server.Player;
|
using Robust.Server.Player;
|
||||||
using Robust.Shared.Console;
|
using Robust.Shared.Console;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
@@ -55,7 +56,8 @@ namespace Content.Server.Administration.Commands
|
|||||||
mind.TransferTo(ghost);
|
mind.TransferTo(ghost);
|
||||||
}
|
}
|
||||||
|
|
||||||
ghost.GetComponent<GhostComponent>().CanReturnToBody = canReturn;
|
var comp = ghost.GetComponent<GhostComponent>();
|
||||||
|
EntitySystem.Get<SharedGhostSystem>().SetCanReturnToBody(comp, canReturn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ using Content.Server.Roles;
|
|||||||
using Content.Server.Spawners.Components;
|
using Content.Server.Spawners.Components;
|
||||||
using Content.Server.Speech.Components;
|
using Content.Server.Speech.Components;
|
||||||
using Content.Shared.GameTicking;
|
using Content.Shared.GameTicking;
|
||||||
|
using Content.Shared.Ghost;
|
||||||
using Content.Shared.Inventory;
|
using Content.Shared.Inventory;
|
||||||
using Content.Shared.Preferences;
|
using Content.Shared.Preferences;
|
||||||
using Content.Shared.Roles;
|
using Content.Shared.Roles;
|
||||||
@@ -144,7 +145,8 @@ namespace Content.Server.GameTicking
|
|||||||
|
|
||||||
var mob = SpawnObserverMob();
|
var mob = SpawnObserverMob();
|
||||||
mob.Name = name;
|
mob.Name = name;
|
||||||
mob.GetComponent<GhostComponent>().CanReturnToBody = false;
|
var ghost = mob.GetComponent<GhostComponent>();
|
||||||
|
EntitySystem.Get<SharedGhostSystem>().SetCanReturnToBody(ghost, false);
|
||||||
data.Mind.TransferTo(mob);
|
data.Mind.TransferTo(mob);
|
||||||
|
|
||||||
_playersInLobby[player] = LobbyPlayerStatus.Observer;
|
_playersInLobby[player] = LobbyPlayerStatus.Observer;
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||||||
using Content.Server.Ghost.Components;
|
using Content.Server.Ghost.Components;
|
||||||
using Content.Shared.Damage;
|
using Content.Shared.Damage;
|
||||||
using Content.Shared.Damage.Components;
|
using Content.Shared.Damage.Components;
|
||||||
|
using Content.Shared.Ghost;
|
||||||
using Content.Shared.MobState;
|
using Content.Shared.MobState;
|
||||||
using Content.Shared.Preferences;
|
using Content.Shared.Preferences;
|
||||||
using Robust.Server.Player;
|
using Robust.Server.Player;
|
||||||
@@ -75,7 +76,7 @@ namespace Content.Server.GameTicking.Presets
|
|||||||
ghost.Name = mind.CharacterName ?? string.Empty;
|
ghost.Name = mind.CharacterName ?? string.Empty;
|
||||||
|
|
||||||
var ghostComponent = ghost.GetComponent<GhostComponent>();
|
var ghostComponent = ghost.GetComponent<GhostComponent>();
|
||||||
ghostComponent.CanReturnToBody = canReturn;
|
EntitySystem.Get<SharedGhostSystem>().SetCanReturnToBody(ghostComponent, canReturn);
|
||||||
|
|
||||||
if (canReturn)
|
if (canReturn)
|
||||||
mind.Visit(ghost);
|
mind.Visit(ghost);
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using Content.Server.GameTicking;
|
using Content.Server.GameTicking;
|
||||||
using Content.Server.Ghost.Components;
|
using Content.Server.Ghost.Components;
|
||||||
using Content.Shared.Examine;
|
using Content.Shared.Examine;
|
||||||
|
using Content.Shared.Ghost;
|
||||||
using Content.Shared.MobState;
|
using Content.Shared.MobState;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
@@ -86,7 +87,7 @@ namespace Content.Server.Mind.Components
|
|||||||
{
|
{
|
||||||
if (visiting.TryGetComponent(out GhostComponent? ghost))
|
if (visiting.TryGetComponent(out GhostComponent? ghost))
|
||||||
{
|
{
|
||||||
ghost.CanReturnToBody = false;
|
EntitySystem.Get<SharedGhostSystem>().SetCanReturnToBody(ghost, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
Mind!.TransferTo(visiting);
|
Mind!.TransferTo(visiting);
|
||||||
@@ -108,7 +109,7 @@ namespace Content.Server.Mind.Components
|
|||||||
|
|
||||||
var ghost = Owner.EntityManager.SpawnEntity("MobObserver", spawnPosition);
|
var ghost = Owner.EntityManager.SpawnEntity("MobObserver", spawnPosition);
|
||||||
var ghostComponent = ghost.GetComponent<GhostComponent>();
|
var ghostComponent = ghost.GetComponent<GhostComponent>();
|
||||||
ghostComponent.CanReturnToBody = false;
|
EntitySystem.Get<SharedGhostSystem>().SetCanReturnToBody(ghostComponent, false);
|
||||||
|
|
||||||
if (Mind != null)
|
if (Mind != null)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -16,8 +16,9 @@ namespace Content.Shared.Ghost
|
|||||||
public override string Name => "Ghost";
|
public override string Name => "Ghost";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Changed by <see cref="GhostChangeCanReturnToBodyEvent"/>
|
/// Changed by <see cref="SharedGhostSystem.SetCanReturnToBody"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
// TODO MIRROR change this to use friend classes when thats merged
|
||||||
[DataField("canReturnToBody")]
|
[DataField("canReturnToBody")]
|
||||||
[ViewVariables(VVAccess.ReadWrite)]
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
public bool CanReturnToBody { get; set; }
|
public bool CanReturnToBody { get; set; }
|
||||||
|
|||||||
@@ -10,36 +10,20 @@ namespace Content.Shared.Ghost
|
|||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
base.Initialize();
|
base.Initialize();
|
||||||
|
|
||||||
SubscribeLocalEvent<SharedGhostComponent, GhostChangeCanReturnToBodyEvent>(OnGhostChangeCanReturnToBody);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnGhostChangeCanReturnToBody(EntityUid uid, SharedGhostComponent component, GhostChangeCanReturnToBodyEvent args)
|
public void SetCanReturnToBody(SharedGhostComponent component, bool canReturn)
|
||||||
{
|
{
|
||||||
if (component.CanReturnToBody == args.CanReturnToBody)
|
if (component.CanReturnToBody == canReturn)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
component.CanReturnToBody = args.CanReturnToBody;
|
component.CanReturnToBody = canReturn;
|
||||||
component.Dirty();
|
component.Dirty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Raised to change the value of <see cref="SharedGhostComponent.CanReturnToBody"/>
|
|
||||||
/// </summary>
|
|
||||||
[Serializable, NetSerializable]
|
|
||||||
public class GhostChangeCanReturnToBodyEvent : EntityEventArgs
|
|
||||||
{
|
|
||||||
public GhostChangeCanReturnToBodyEvent(bool canReturnToBody)
|
|
||||||
{
|
|
||||||
CanReturnToBody = canReturnToBody;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool CanReturnToBody { get; }
|
|
||||||
}
|
|
||||||
|
|
||||||
[Serializable, NetSerializable]
|
[Serializable, NetSerializable]
|
||||||
public class GhostWarpsRequestEvent : EntityEventArgs
|
public class GhostWarpsRequestEvent : EntityEventArgs
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user