Files
wwdpublic/Content.Client/Cocoon/CocoonSystem.cs
Aiden 2b10679f87 Cocoon Cleanup & Minor Bloodsucker Tweaks (#1058)
# Description

- Generalizes cocooning
- Allows any mob to be cocooned
- Cocoon bloodsucking moved to vampirism system
- Any blood sucker can drink from cocoons
- Vampirism no longer fails if bloodstream isn't normal blood, but gives
a pop up
- Vampirism `WebRequired` actually works in a way that makes sense
- Adds cocooning and bloodsucker to all spider mobs + Arachnids

resolves #978

---

# Changelog

🆑
- tweak: All spiders, arachne, and arachnids can cocoon mobs, and drink
their blood.

---------

Co-authored-by: VMSolidus <evilexecutive@gmail.com>
2024-10-19 15:04:27 +07:00

34 lines
1.5 KiB
C#

using Content.Shared.Cocoon;
using Content.Shared.Humanoid;
using Robust.Client.GameObjects;
using Robust.Shared.Containers;
using System.Numerics;
namespace Content.Client.Cocoon
{
public sealed class CocoonSystem : EntitySystem
{
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<CocoonComponent, EntInsertedIntoContainerMessage>(OnCocEntInserted);
}
private void OnCocEntInserted(EntityUid uid, CocoonComponent component, EntInsertedIntoContainerMessage args)
{
if (!TryComp<SpriteComponent>(uid, out var cocoonSprite))
return;
if (TryComp<HumanoidAppearanceComponent>(args.Entity, out var humanoidAppearance)) // If humanoid, use height and width
cocoonSprite.Scale = new Vector2(humanoidAppearance.Width, humanoidAppearance.Height);
else if (!TryComp<SpriteComponent>(args.Entity, out var entSprite))
return;
else if (entSprite.BaseRSI != null) // Set scale based on sprite scale + sprite dimensions. Ideally we would somehow get a bounding box from the sprite size not including transparent pixels, but FUCK figuring that out.
cocoonSprite.Scale = entSprite.Scale * (entSprite.BaseRSI.Size / 32);
else if (entSprite.Scale != cocoonSprite.Scale) // if basersi somehow not found (?) just use scale
cocoonSprite.Scale = entSprite.Scale;
}
}
}