Diona Nymphs & Splitting (#24630)
* Porting & implementation * Fix two stupid errors * Human not humans * fix audio path * Fix test fails & update cooldown * Work on reviews & test fail * Rework nymph organ system. * Make the nymph organs nospawn. * IsDeadIC
This commit is contained in:
61
Content.Shared/Species/Systems/GibActionSystem.cs
Normal file
61
Content.Shared/Species/Systems/GibActionSystem.cs
Normal file
@@ -0,0 +1,61 @@
|
||||
using Content.Shared.Species.Components;
|
||||
using Content.Shared.Actions;
|
||||
using Content.Shared.Body.Systems;
|
||||
using Content.Shared.Mobs;
|
||||
using Content.Shared.Mobs.Components;
|
||||
using Content.Shared.Popups;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
|
||||
namespace Content.Shared.Species;
|
||||
|
||||
public sealed partial class GibActionSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly SharedActionsSystem _actionsSystem = default!;
|
||||
[Dependency] private readonly SharedBodySystem _bodySystem = default!;
|
||||
[Dependency] private readonly IPrototypeManager _protoManager = default!;
|
||||
[Dependency] private readonly SharedPopupSystem _popupSystem = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<GibActionComponent, MobStateChangedEvent>(OnMobStateChanged);
|
||||
SubscribeLocalEvent<GibActionComponent, GibActionEvent>(OnGibAction);
|
||||
}
|
||||
|
||||
private void OnMobStateChanged(EntityUid uid, GibActionComponent comp, MobStateChangedEvent args)
|
||||
{
|
||||
// When the mob changes state, check if they're dead and give them the action if so.
|
||||
if (!TryComp<MobStateComponent>(uid, out var mobState))
|
||||
return;
|
||||
|
||||
if (!_protoManager.TryIndex<EntityPrototype>(comp.ActionPrototype, out var actionProto))
|
||||
return;
|
||||
|
||||
|
||||
foreach (var allowedState in comp.AllowedStates)
|
||||
{
|
||||
if(allowedState == mobState.CurrentState)
|
||||
{
|
||||
// The mob should never have more than 1 state so I don't see this being an issue
|
||||
_actionsSystem.AddAction(uid, ref comp.ActionEntity, comp.ActionPrototype);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// If they aren't given the action, remove it.
|
||||
_actionsSystem.RemoveAction(uid, comp.ActionEntity);
|
||||
}
|
||||
|
||||
private void OnGibAction(EntityUid uid, GibActionComponent comp, GibActionEvent args)
|
||||
{
|
||||
// When they use the action, gib them.
|
||||
_popupSystem.PopupClient(Loc.GetString(comp.PopupText, ("name", uid)), uid, uid);
|
||||
_bodySystem.GibBody(uid, true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public sealed partial class GibActionEvent : InstantActionEvent { }
|
||||
}
|
||||
41
Content.Shared/Species/Systems/NymphSystem.cs
Normal file
41
Content.Shared/Species/Systems/NymphSystem.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using Content.Shared.Species.Components;
|
||||
using Content.Shared.Body.Events;
|
||||
using Content.Shared.Mind;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
namespace Content.Shared.Species;
|
||||
|
||||
public sealed partial class NymphSystem : EntitySystem
|
||||
{
|
||||
[Dependency] protected readonly IPrototypeManager _protoManager = default!;
|
||||
[Dependency] private readonly SharedMindSystem _mindSystem = default!;
|
||||
[Dependency] private readonly IGameTiming _timing = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<NymphComponent, RemovedFromPartInBodyEvent>(OnRemovedFromPart);
|
||||
}
|
||||
|
||||
private void OnRemovedFromPart(EntityUid uid, NymphComponent comp, RemovedFromPartInBodyEvent args)
|
||||
{
|
||||
if (!_timing.IsFirstTimePredicted)
|
||||
return;
|
||||
|
||||
if (TerminatingOrDeleted(uid) || TerminatingOrDeleted(args.OldBody))
|
||||
return;
|
||||
|
||||
if (!_protoManager.TryIndex<EntityPrototype>(comp.EntityPrototype, out var entityProto))
|
||||
return;
|
||||
|
||||
var coords = Transform(uid).Coordinates;
|
||||
var nymph = EntityManager.SpawnEntity(entityProto.ID, coords);
|
||||
|
||||
if (comp.TransferMind == true && _mindSystem.TryGetMind(args.OldBody, out var mindId, out var mind))
|
||||
_mindSystem.TransferTo(mindId, nymph, mind: mind);
|
||||
|
||||
EntityManager.QueueDeleteEntity(uid);
|
||||
}
|
||||
}
|
||||
108
Content.Shared/Species/Systems/ReformSystem.cs
Normal file
108
Content.Shared/Species/Systems/ReformSystem.cs
Normal file
@@ -0,0 +1,108 @@
|
||||
using Content.Shared.Species.Components;
|
||||
using Content.Shared.Actions;
|
||||
using Content.Shared.DoAfter;
|
||||
using Content.Shared.Popups;
|
||||
using Content.Shared.Stunnable;
|
||||
using Content.Shared.Mind;
|
||||
using Content.Shared.Humanoid;
|
||||
using Robust.Shared.Network;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Timing;
|
||||
using Robust.Shared.Serialization.Manager;
|
||||
|
||||
namespace Content.Shared.Species;
|
||||
|
||||
public sealed partial class ReformSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly SharedActionsSystem _actionsSystem = default!;
|
||||
[Dependency] private readonly INetManager _netMan = default!;
|
||||
[Dependency] private readonly SharedDoAfterSystem _doAfterSystem = default!;
|
||||
[Dependency] private readonly SharedPopupSystem _popupSystem = default!;
|
||||
[Dependency] private readonly IPrototypeManager _protoManager = default!;
|
||||
[Dependency] private readonly SharedStunSystem _stunSystem = default!;
|
||||
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
||||
[Dependency] private readonly SharedMindSystem _mindSystem = default!;
|
||||
[Dependency] private readonly MetaDataSystem _metaData = default!;
|
||||
[Dependency] private readonly ISerializationManager _serializationManager = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<ReformComponent, MapInitEvent>(OnMapInit);
|
||||
SubscribeLocalEvent<ReformComponent, ComponentShutdown>(OnCompRemove);
|
||||
|
||||
SubscribeLocalEvent<ReformComponent, ReformEvent>(OnReform);
|
||||
SubscribeLocalEvent<ReformComponent, ReformDoAfterEvent>(OnDoAfter);
|
||||
}
|
||||
|
||||
private void OnMapInit(EntityUid uid, ReformComponent comp, MapInitEvent args)
|
||||
{
|
||||
// When the map is initialized, give them the action
|
||||
if (comp.ActionPrototype != default && !_protoManager.TryIndex<EntityPrototype>(comp.ActionPrototype, out var actionProto))
|
||||
return;
|
||||
|
||||
_actionsSystem.AddAction(uid, ref comp.ActionEntity, out var reformAction, comp.ActionPrototype);
|
||||
|
||||
// See if the action should start with a delay, and give it that starting delay if so.
|
||||
if (comp.StartDelayed && reformAction != null && reformAction.UseDelay != null)
|
||||
{
|
||||
var start = _gameTiming.CurTime;
|
||||
var end = _gameTiming.CurTime + reformAction.UseDelay.Value;
|
||||
|
||||
_actionsSystem.SetCooldown(comp.ActionEntity!.Value, start, end);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnCompRemove(EntityUid uid, ReformComponent comp, ComponentShutdown args)
|
||||
{
|
||||
_actionsSystem.RemoveAction(uid, comp.ActionEntity);
|
||||
}
|
||||
|
||||
private void OnReform(EntityUid uid, ReformComponent comp, ReformEvent args)
|
||||
{
|
||||
// Stun them when they use the action for the amount of reform time.
|
||||
if (comp.ShouldStun)
|
||||
_stunSystem.TryStun(uid, TimeSpan.FromSeconds(comp.ReformTime), true);
|
||||
_popupSystem.PopupClient(Loc.GetString(comp.PopupText, ("name", uid)), uid, uid);
|
||||
|
||||
// Create a doafter & start it
|
||||
var doAfter = new DoAfterArgs(EntityManager, uid, comp.ReformTime, new ReformDoAfterEvent(), uid)
|
||||
{
|
||||
BreakOnUserMove = true,
|
||||
BlockDuplicate = true,
|
||||
BreakOnDamage = true,
|
||||
CancelDuplicate = true,
|
||||
RequireCanInteract = false,
|
||||
};
|
||||
|
||||
_doAfterSystem.TryStartDoAfter(doAfter);
|
||||
args.Handled = true;
|
||||
}
|
||||
|
||||
private void OnDoAfter(EntityUid uid, ReformComponent comp, ReformDoAfterEvent args)
|
||||
{
|
||||
if (args.Cancelled || args.Handled || comp.Deleted)
|
||||
return;
|
||||
|
||||
if (_netMan.IsClient)
|
||||
return;
|
||||
|
||||
// Spawn a new entity
|
||||
// This is, to an extent, taken from polymorph. I don't use polymorph for various reasons- most notably that this is permanent.
|
||||
var child = Spawn(comp.ReformPrototype, Transform(uid).Coordinates);
|
||||
|
||||
// This transfers the mind to the new entity
|
||||
if (_mindSystem.TryGetMind(uid, out var mindId, out var mind))
|
||||
_mindSystem.TransferTo(mindId, child, mind: mind);
|
||||
|
||||
// Delete the old entity
|
||||
QueueDel(uid);
|
||||
}
|
||||
|
||||
public sealed partial class ReformEvent : InstantActionEvent { }
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed partial class ReformDoAfterEvent : SimpleDoAfterEvent { }
|
||||
}
|
||||
Reference in New Issue
Block a user