Skip to content

Commit

Permalink
Merge remote-tracking branch 'EE-Master/LamiaSystem' into upstream-me…
Browse files Browse the repository at this point in the history
…rge-7-21-2024
  • Loading branch information
VMSolidus committed Jul 22, 2024
2 parents c8c65df + c630d63 commit ee847e6
Show file tree
Hide file tree
Showing 26 changed files with 1,014 additions and 19 deletions.
42 changes: 42 additions & 0 deletions Content.Client/DeltaV/Lamiae/ClientLamiaVisuals.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Delta-V - This file is licensed under AGPLv3
* Copyright (c) 2024 Delta-V Contributors
* See AGPLv3.txt for details.
*/

using Robust.Client.GameObjects;
using System.Numerics;
using Content.Shared.SegmentedEntity;

namespace Content.Client.DeltaV.Lamiae;

public sealed class ClientLamiaVisualSystem : VisualizerSystem<SegmentedEntitySegmentVisualsComponent>
{

public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<SegmentedEntitySegmentComponent, AppearanceChangeEvent>(OnAppearanceChange);
}
private void OnAppearanceChange(EntityUid uid, SegmentedEntitySegmentComponent component, ref AppearanceChangeEvent args)
{
if (args.Sprite == null) return;

if (AppearanceSystem.TryGetData<float>(uid, ScaleVisuals.Scale, out var scale) && TryComp<SpriteComponent>(uid, out var sprite))
{
sprite.Scale = new Vector2(scale, scale);
}

if (AppearanceSystem.TryGetData<bool>(uid, SegmentedEntitySegmentVisualLayers.Armor, out var worn)
&& AppearanceSystem.TryGetData<string>(uid, SegmentedEntitySegmentVisualLayers.ArmorRsi, out var path))
{
var valid = !string.IsNullOrWhiteSpace(path);
if (valid)
{
args.Sprite.LayerSetRSI(SegmentedEntitySegmentVisualLayers.Armor, path);
}
args.Sprite.LayerSetVisible(SegmentedEntitySegmentVisualLayers.Armor, worn);
}
}
}
11 changes: 11 additions & 0 deletions Content.Client/DeltaV/Lamiae/LamiaSegmentVisualsComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
* Delta-V - This file is licensed under AGPLv3
* Copyright (c) 2024 Delta-V Contributors
* See AGPLv3.txt for details.
*/

namespace Content.Client.DeltaV.Lamiae;

[RegisterComponent]
public sealed partial class SegmentedEntitySegmentVisualsComponent : Component
{}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using Content.Shared.Ghost;
using Content.Shared.Maps;
using Content.Shared.Parallax;
using Content.Shared.SegmentedEntity;
using Content.Shared.Shuttles.Components;
using Content.Shared.Shuttles.Systems;
using Content.Shared.StatusEffect;
Expand Down Expand Up @@ -601,7 +602,9 @@ private void KnockOverKids(TransformComponent xform, ref ValueList<EntityUid> to
var childEnumerator = xform.ChildEnumerator;
while (childEnumerator.MoveNext(out var child))
{
if (!_buckleQuery.TryGetComponent(child, out var buckle) || buckle.Buckled)
if (!_buckleQuery.TryGetComponent(child, out var buckle) || buckle.Buckled
|| HasComp<SegmentedEntityComponent>(child)
|| HasComp<SegmentedEntitySegmentComponent>(child))
continue;

toKnock.Add(child);
Expand Down
1 change: 1 addition & 0 deletions Content.Shared/Roles/StartingGearPrototype.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public string GetGear(string slot, HumanoidCharacterProfile? profile)
{
case "jumpsuit" when profile.Clothing == ClothingPreference.Jumpskirt && !string.IsNullOrEmpty(InnerClothingSkirt):
case "jumpsuit" when profile.Species == "Harpy" && !string.IsNullOrEmpty(InnerClothingSkirt):
case "jumpsuit" when profile.Species == "Lamia" && !string.IsNullOrEmpty(InnerClothingSkirt):
return InnerClothingSkirt;
case "back" when profile.Backpack == BackpackPreference.Satchel && !string.IsNullOrEmpty(Satchel):
return Satchel;
Expand Down
10 changes: 10 additions & 0 deletions Content.Shared/SegmentedEntity/SegmentSpawnedEvent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace Content.Shared.SegmentedEntity;
public sealed class SegmentSpawnedEvent : EntityEventArgs
{
public EntityUid Lamia = default!;

public SegmentSpawnedEvent(EntityUid lamia)
{
Lamia = lamia;
}
}
84 changes: 84 additions & 0 deletions Content.Shared/SegmentedEntity/SegmentedEntityComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/*
* Delta-V - This file is licensed under AGPLv3
* Copyright (c) 2024 Delta-V Contributors
* See AGPLv3.txt for details.
*/

namespace Content.Shared.SegmentedEntity
{
/// <summary>
/// Controls initialization of any Multi-segmented entity
/// </summary>
[RegisterComponent]
public sealed partial class SegmentedEntityComponent : Component
{
/// <summary>
/// A list of each UID attached to the Lamia, in order of spawn
/// </summary>
[DataField("segments")]
public List<EntityUid> Segments = new();

/// <summary>
/// A clamped variable that represents the number of segments to be spawned
/// </summary>
[DataField("numberOfSegments")]
public int NumberOfSegments = 18;

/// <summary>
/// If UseTaperSystem is true, this constant represents the rate at which a segmented entity will taper towards the tip. Tapering is on a logarithmic scale, and will asymptotically approach 0.
/// </summary>
[DataField("offsetConstant")]
public float OffsetConstant = 1.03f;

/// <summary>
/// Represents the prototype used to parent all segments
/// </summary>
[DataField("initialSegmentId")]
public string InitialSegmentId = "LamiaInitialSegment";

/// <summary>
/// Represents the segment prototype to be spawned
/// </summary>
[DataField("SegmentId")]
public string SegmentId = "LamiaSegment";

/// <summary>
/// Toggles the tapering system on and off. When false, segmented entities will have a constant width.
/// </summary>
[DataField("useTaperSystem")]
public bool UseTaperSystem = true;

/// <summary>
/// The standard distance between the centerpoint of each segment.
/// </summary>
[DataField("staticOffset")]
public float StaticOffset = 0.15f;

/// <summary>
/// The standard sprite scale of each segment.
/// </summary>
[DataField("staticScale")]
public float StaticScale = 1f;

/// <summary>
/// Used to more finely tune how much damage should be transfered from tail to body.
/// </summary>
[DataField("damageModifierOffset")]
public float DamageModifierOffset = 0.4f;

/// <summary>
/// A clamped variable that represents how far from the tip should tapering begin.
/// </summary>
[DataField("taperOffset")]
public int TaperOffset = 18;

/// <summary>
/// Coefficient used to finely tune how much explosion damage should be transfered to the body. This is calculated multiplicatively with the derived damage modifier set.
/// </summary>
[DataField("explosiveModifierOffset")]
public float ExplosiveModifierOffset = 0.1f;

[DataField("bulletPassover")]
public bool BulletPassover = true;
}
}
35 changes: 35 additions & 0 deletions Content.Shared/SegmentedEntity/SegmentedEntitySegmentComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Delta-V - This file is licensed under AGPLv3
* Copyright (c) 2024 Delta-V Contributors
* See AGPLv3.txt for details.
*/

using Robust.Shared.GameStates;

namespace Content.Shared.SegmentedEntity
{
/// <summary>
/// Lamia segment
/// </summary>
[RegisterComponent]
[NetworkedComponent]
public sealed partial class SegmentedEntitySegmentComponent : Component
{
[DataField("AttachedToUid")]
public EntityUid AttachedToUid = default!;
public float DamageModifyFactor = default!;
public float OffsetSwitching = default!;
public float ScaleFactor = default!;
[DataField("DamageModifierCoefficient")]
public float DamageModifierCoefficient = default!;
public float ExplosiveModifyFactor = default!;
public float OffsetConstant = default!;
[DataField("Lamia")]
public EntityUid Lamia = default!;
public int MaxSegments = default!;
public int SegmentNumber = default!;
public float DamageModifierConstant = default!;
[DataField("segmentId")]
public string? segmentId;
}
}
18 changes: 18 additions & 0 deletions Content.Shared/SegmentedEntity/SegmentedEntitySegmentVisuals.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* Delta-V - This file is licensed under AGPLv3
* Copyright (c) 2024 Delta-V Contributors
* See AGPLv3.txt for details.
*/

using Robust.Shared.Serialization;

namespace Content.Shared.SegmentedEntity
{
[Serializable, NetSerializable]
public enum SegmentedEntitySegmentVisualLayers
{
Tail,
Armor,
ArmorRsi,
}
}
Loading

0 comments on commit ee847e6

Please sign in to comment.