using Content.Server.Storage.Components;
using Content.Shared._EE.Shadowling;
using Content.Shared.Inventory;
namespace Content.Server._EE.Shadowling;
///
/// This handles only the Hatching Ability
///
public sealed partial class ShadowlingSystem
{
public void SubscribeAbilities()
{
SubscribeLocalEvent(OnHatch);
}
# region Hatch
private void OnHatch(EntityUid uid, ShadowlingComponent comp, HatchEvent args)
{
_actions.RemoveAction(uid, args.Action);
StartHatchingProgress(uid, comp);
}
private void StartHatchingProgress(EntityUid uid, ShadowlingComponent comp)
{
comp.IsHatching = true;
// Drop all items
if (TryComp(uid, out var inv))
{
foreach (var slot in inv.Slots)
_inventorySystem.DropSlotContents(uid, slot.Name, inv);
}
var egg = SpawnAtPosition(comp.Egg, Transform(uid).Coordinates);
if (TryComp(egg, out var eggComp) &&
TryComp(egg, out var eggStorage))
{
eggComp.ShadowlingInside = uid;
_entityStorage.Insert(uid, egg, eggStorage);
}
// It should be noted that Shadowling shouldn't be able to take damage during this process.
}
#endregion
}