Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions Content.Client/Arachne/CocoonSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using Content.Shared.Arachne;
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;
}
}
}
16 changes: 0 additions & 16 deletions Content.Server/Arachne/ArachneSystem.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Content.Shared.Arachne;
using Content.Shared.Actions;
using Content.Shared.IdentityManagement;
using Content.Shared.Verbs;
using Content.Shared.Buckle.Components;
Expand All @@ -8,20 +7,16 @@
using Content.Shared.Eye.Blinding.Systems;
using Content.Shared.Containers.ItemSlots;
using Content.Shared.Damage;
using Content.Shared.Inventory;
using Content.Shared.Administration.Logs;
using Content.Shared.Database;
using Content.Shared.Humanoid;
using Content.Shared.Nutrition.EntitySystems;
using Content.Server.Buckle.Systems;
using Content.Server.Popups;
using Content.Server.DoAfter;
using Content.Server.Body.Components;
using Content.Server.Vampiric;
using Content.Server.Speech.Components;
using Robust.Shared.Physics.Components;
using Robust.Shared.Containers;
using Robust.Shared.Map;
using Robust.Shared.Utility;
using Robust.Server.Console;

Expand Down Expand Up @@ -207,17 +202,6 @@ private void OnCocoonDoAfter(EntityUid uid, ArachneComponent component, ArachneC
if (!TryComp<ItemSlotsComponent>(cocoon, out var slots))
return;

// todo: our species should use scale visuals probably...
// TODO: We need a client-accessible notion of scale influence here.
/* if (spawnProto == "CocoonedHumanoid" && TryComp<SpriteComponent>(args.Args.Target.Value, out var sprite)) */
/* { */
/* // why the fuck is this only available as a console command. */
/* _host.ExecuteCommand(null, "scale " + cocoon + " " + sprite.Scale.Y); */
if (TryComp<PhysicsComponent>(args.Args.Target.Value, out var physics))
{
var scale = Math.Clamp(1 / (35 / physics.FixturesMass), 0.35, 2.5);
_host.ExecuteCommand(null, "scale " + cocoon + " " + scale);
}
_itemSlots.SetLock(cocoon, BodySlot, false, slots);
_itemSlots.TryInsert(cocoon, BodySlot, args.Args.Target.Value, args.Args.User);
_itemSlots.SetLock(cocoon, BodySlot, true, slots);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Content.Server.Arachne
namespace Content.Shared.Arachne
{
[RegisterComponent]
public sealed partial class CocoonComponent : Component
Expand Down