Fix ghost role exceptions (#6106)
This commit is contained in:
@@ -5,7 +5,9 @@ using JetBrains.Annotations;
|
|||||||
using Robust.Server.Player;
|
using Robust.Server.Player;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
|
using Robust.Shared.Prototypes;
|
||||||
using Robust.Shared.Serialization.Manager.Attributes;
|
using Robust.Shared.Serialization.Manager.Attributes;
|
||||||
|
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
||||||
using Robust.Shared.ViewVariables;
|
using Robust.Shared.ViewVariables;
|
||||||
|
|
||||||
namespace Content.Server.Ghost.Roles.Components
|
namespace Content.Server.Ghost.Roles.Components
|
||||||
@@ -31,7 +33,7 @@ namespace Content.Server.Ghost.Roles.Components
|
|||||||
|
|
||||||
[CanBeNull]
|
[CanBeNull]
|
||||||
[ViewVariables(VVAccess.ReadWrite)]
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
[DataField("prototype")]
|
[DataField("prototype", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
|
||||||
public string? Prototype { get; private set; }
|
public string? Prototype { get; private set; }
|
||||||
|
|
||||||
public override bool Take(IPlayerSession session)
|
public override bool Take(IPlayerSession session)
|
||||||
|
|||||||
@@ -1,11 +1,8 @@
|
|||||||
using System;
|
|
||||||
using Content.Server.Mind.Commands;
|
using Content.Server.Mind.Commands;
|
||||||
using Content.Server.Mind.Components;
|
using Content.Server.Mind.Components;
|
||||||
using Content.Server.Players;
|
|
||||||
using Robust.Server.Player;
|
using Robust.Server.Player;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
using Robust.Shared.Utility;
|
|
||||||
|
|
||||||
namespace Content.Server.Ghost.Roles.Components
|
namespace Content.Server.Ghost.Roles.Components
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -50,7 +50,6 @@ namespace Content.Server.Ghost.Roles
|
|||||||
SubscribeLocalEvent<PlayerAttachedEvent>(OnPlayerAttached);
|
SubscribeLocalEvent<PlayerAttachedEvent>(OnPlayerAttached);
|
||||||
SubscribeLocalEvent<GhostTakeoverAvailableComponent, MindRemovedMessage>(OnMindRemoved);
|
SubscribeLocalEvent<GhostTakeoverAvailableComponent, MindRemovedMessage>(OnMindRemoved);
|
||||||
SubscribeLocalEvent<GhostTakeoverAvailableComponent, MobStateChangedEvent>(OnMobStateChanged);
|
SubscribeLocalEvent<GhostTakeoverAvailableComponent, MobStateChangedEvent>(OnMobStateChanged);
|
||||||
|
|
||||||
_playerManager.PlayerStatusChanged += PlayerStatusChanged;
|
_playerManager.PlayerStatusChanged += PlayerStatusChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -231,8 +230,10 @@ namespace Content.Server.Ghost.Roles
|
|||||||
|
|
||||||
private void OnMindRemoved(EntityUid uid, GhostRoleComponent component, MindRemovedMessage args)
|
private void OnMindRemoved(EntityUid uid, GhostRoleComponent component, MindRemovedMessage args)
|
||||||
{
|
{
|
||||||
if (!component.ReregisterOnGhost)
|
// Avoid re-registering it for duplicate entries and potential exceptions.
|
||||||
|
if (!component.ReregisterOnGhost || component.LifeStage > ComponentLifeStage.Running)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
component.Taken = false;
|
component.Taken = false;
|
||||||
RegisterGhostRole(component);
|
RegisterGhostRole(component);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,7 @@
|
|||||||
sprite: Markers/jobs.rsi
|
sprite: Markers/jobs.rsi
|
||||||
state: centcom
|
state: centcom
|
||||||
- type: GhostRoleMobSpawner
|
- type: GhostRoleMobSpawner
|
||||||
prototype: HumanMob_CentcomOfficial
|
prototype: MobHumanCentcomOfficial
|
||||||
deleteOnSpawn: true
|
deleteOnSpawn: true
|
||||||
makeSentient: false
|
makeSentient: false
|
||||||
name: centcom official
|
name: centcom official
|
||||||
|
|||||||
Reference in New Issue
Block a user