Skip to content

Commit

Permalink
QOL changes on the matter of life and death (#782)
Browse files Browse the repository at this point in the history
* Fix cremation accepting connected players

* Fix ghostrespawn

* Support for components that are carried over to cloned bodies

* Whitespace
Mnemotechnician authored Dec 29, 2023
1 parent 202fc55 commit e6c4977
Showing 6 changed files with 48 additions and 3 deletions.
3 changes: 2 additions & 1 deletion Content.Server/Body/Systems/BodySystem.cs
Original file line number Diff line number Diff line change
@@ -42,7 +42,8 @@ private void OnRelayMoveInput(EntityUid uid, BodyComponent component, ref MoveIn
{
if (_mobState.IsDead(uid) && _mindSystem.TryGetMind(uid, out var mindId, out var mind))
{
mind.TimeOfDeath ??= _gameTiming.RealTime;
// mind.TimeOfDeath ??= _gameTiming.RealTime;
mind.TimeOfDeath ??= _gameTiming.CurTime; // Frontier - fix returning to body messing with the your TOD
_ticker.OnGhostAttempt(mindId, true, mind: mind);
}
}
16 changes: 16 additions & 0 deletions Content.Server/Cloning/CloningSystem.cs
Original file line number Diff line number Diff line change
@@ -37,7 +37,9 @@
using Content.Shared.Emag.Systems;
using Content.Server.Popups;
using Content.Server.Traits.Assorted;
using Content.Shared._NF.Cloning;
using Content.Shared.Bank.Components;
using Robust.Shared.Serialization.Manager;

namespace Content.Server.Cloning
{
@@ -65,6 +67,8 @@ public sealed class CloningSystem : EntitySystem
[Dependency] private readonly SharedMindSystem _mindSystem = default!;
[Dependency] private readonly MetaDataSystem _metaSystem = default!;
[Dependency] private readonly SharedJobSystem _jobs = default!;
// Frontier
[Dependency] private readonly ISerializationManager _serialization = default!;

public readonly Dictionary<MindComponent, EntityUid> ClonesWaitingForMind = new();
public const float EasyModeCloningCost = 0.7f;
@@ -255,6 +259,18 @@ public bool TryCloning(EntityUid uid, EntityUid bodyToClone, Entity<MindComponen
bankComp.Balance = bank.Balance;
}

// Frontier
// Transfer of special components, e.g. small/big traits
foreach (var comp in EntityManager.GetComponents(bodyToClone))
{
if (comp is ITransferredByCloning)
{
var copy = _serialization.CreateCopy(comp, notNullableOverride: true);
copy.Owner = mob;
EntityManager.AddComponent(mob, copy, overwrite: true);
}
}

var ev = new CloningEvent(bodyToClone, mob);
RaiseLocalEvent(bodyToClone, ref ev);

15 changes: 15 additions & 0 deletions Content.Server/Morgue/CrematoriumSystem.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Linq;
using Content.Server.GameTicking;
using Content.Server.Morgue.Components;
using Content.Server.Storage.Components;
@@ -7,13 +8,16 @@
using Content.Shared.IdentityManagement;
using Content.Shared.Interaction.Events;
using Content.Shared.Mind;
using Content.Shared.Mobs.Components;
using Content.Shared.Mobs.Systems;
using Content.Shared.Morgue;
using Content.Shared.Popups;
using Content.Shared.Standing;
using Content.Shared.Storage;
using Content.Shared.Storage.Components;
using Content.Shared.Verbs;
using Robust.Server.GameObjects;
using Robust.Shared.Enums;
using Robust.Shared.Player;

namespace Content.Server.Morgue;
@@ -27,6 +31,8 @@ public sealed class CrematoriumSystem : EntitySystem
[Dependency] private readonly SharedPopupSystem _popup = default!;
[Dependency] private readonly StandingStateSystem _standing = default!;
[Dependency] private readonly SharedMindSystem _minds = default!;
[Dependency] private readonly MobStateSystem _mobState = default!; // Frontier
[Dependency] private readonly SharedMindSystem _mind = default!; // frontier

public override void Initialize()
{
@@ -108,6 +114,15 @@ public bool TryCremate(EntityUid uid, CrematoriumComponent? component = null, En
if (storage.Open || storage.Contents.ContainedEntities.Count < 1)
return false;

// Frontier - refuse to accept alive mobs and dead-but-connected players
var entity = storage.Contents.ContainedEntities.First();
if (entity is not { Valid: true })
return false;
if (TryComp<MobStateComponent>(entity, out var comp) && !_mobState.IsDead(entity, comp))
return false;
if (_mind.TryGetMind(entity, out var _, out var mind) && mind.Session?.State?.Status == SessionStatus.InGame)
return false;

return Cremate(uid, component, storage);
}

Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@

using Content.Shared._NF.Cloning;

namespace Content.Server.Item.PseudoItem
{
/// <summary>
/// For entities that behave like an item under certain conditions,
/// but not under most conditions.
/// </summary>
[RegisterComponent]
public sealed partial class PseudoItemComponent : Component
public sealed partial class PseudoItemComponent : Component, ITransferredByCloning
{
[DataField("size")]
public int Size = 120;
4 changes: 3 additions & 1 deletion Content.Server/_NF/SizeAttribute/SizeAttributeComponent.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@

using Content.Shared._NF.Cloning;

namespace Content.Server.SizeAttribute
{
[RegisterComponent]
public sealed partial class SizeAttributeComponent : Component
public sealed partial class SizeAttributeComponent : Component, ITransferredByCloning
{
[DataField("short")]
public bool Short = false;
9 changes: 9 additions & 0 deletions Content.Shared/_NF/Cloning/ITransferredByCloning.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace Content.Shared._NF.Cloning;

/// <summary>
/// Indicates that this Component should be transferred to the new entity when the entity is cloned (for example, using a cloner)
/// </summary>
public interface ITransferredByCloning
{
}

0 comments on commit e6c4977

Please sign in to comment.