Zombie Rework & Polymorph Expansion (#8413)

Co-authored-by: Kara <lunarautomaton6@gmail.com>
Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
This commit is contained in:
EmoGarbage404
2022-06-12 01:53:13 -04:00
committed by GitHub
parent a45529d649
commit 63fd01f3bb
30 changed files with 485 additions and 422 deletions

View File

@@ -1,11 +1,16 @@
using Content.Server.Actions;
using Content.Server.Inventory;
using Content.Server.Mind.Components;
using Content.Server.Polymorph.Components;
using Content.Server.Popups;
using Content.Shared.Actions;
using Content.Shared.Actions.ActionTypes;
using Content.Shared.Damage;
using Content.Shared.Hands.EntitySystems;
using Content.Shared.MobState.Components;
using Content.Shared.Polymorph;
using Robust.Server.Containers;
using Robust.Shared.Containers;
using Robust.Shared.Player;
namespace Content.Server.Polymorph.Systems
@@ -15,6 +20,9 @@ namespace Content.Server.Polymorph.Systems
[Dependency] private readonly ActionsSystem _actions = default!;
[Dependency] private readonly DamageableSystem _damageable = default!;
[Dependency] private readonly PopupSystem _popup = default!;
[Dependency] private readonly ServerInventorySystem _inventory = default!;
[Dependency] private readonly SharedHandsSystem _sharedHands = default!;
[Dependency] private readonly ContainerSystem _container = default!;
public override void Initialize()
{
@@ -35,22 +43,51 @@ namespace Content.Server.Polymorph.Systems
/// <param name="uid">The entityuid of the entity being reverted</param>
public void Revert(EntityUid uid)
{
if (Deleted(uid))
return;
if (!TryComp<PolymorphedEntityComponent>(uid, out var component))
return;
var proto = component.Prototype;
var uidXform = Transform(uid);
var parentXform = Transform(component.Parent);
parentXform.AttachParent(uidXform.ParentUid);
parentXform.Coordinates = uidXform.Coordinates;
parentXform.LocalRotation = uidXform.LocalRotation;
if (TryComp<DamageableComponent>(component.Parent, out var damageParent) &&
if (_container.TryGetContainingContainer(uid, out var cont))
cont.Insert(component.Parent);
if (component.Prototype.TransferDamage &&
TryComp<DamageableComponent>(component.Parent, out var damageParent) &&
_damageable.GetScaledDamage(uid, component.Parent, out var damage) &&
damage != null)
{
_damageable.SetDamage(damageParent, damage);
}
if (proto.Inventory == PolymorphInventoryChange.Transfer)
{
_inventory.TransferEntityInventories(uid, component.Parent);
foreach (var hand in _sharedHands.EnumerateHeld(component.Parent))
{
hand.TryRemoveFromContainer();
_sharedHands.TryPickupAnyHand(component.Parent, hand);
}
}
else if (proto.Inventory == PolymorphInventoryChange.Drop)
{
if (_inventory.TryGetContainerSlotEnumerator(uid, out var enumerator))
while (enumerator.MoveNext(out var slot))
slot.EmptyContainer();
foreach (var hand in _sharedHands.EnumerateHeld(uid))
hand.TryRemoveFromContainer();
}
if (TryComp<MindComponent>(uid, out var mind) && mind.Mind != null)
{
mind.Mind.TransferTo(component.Parent);