Skip to content
This repository has been archived by the owner on Nov 18, 2024. It is now read-only.

Commit

Permalink
Merge branch 'Fansana:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Plyushsune authored Sep 18, 2024
2 parents 8c2aaef + 5542c7b commit 23626a0
Show file tree
Hide file tree
Showing 38 changed files with 1,751 additions and 618 deletions.
27 changes: 0 additions & 27 deletions Content.Shared/Floofstation/Leash/Components/LeashComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,27 +46,6 @@ public sealed partial class LeashComponent : Component
[DataField, AutoNetworkedField]
public TimeSpan PullInterval = TimeSpan.FromSeconds(1.5f);

/// <summary>
/// How much damage each leash joint can sustain before it breaks.
/// </summary>
/// <remarks>Not currently implemented; needs to be reworked in order to work.</remarks>
[DataField, AutoNetworkedField]
public float BreakDamage = 20f;

/// <summary>
/// How much damage each leash joint loses every <see cref="DamageInterval"/>.
/// </summary>
/// <remarks>Not currently implemented; needs to be reworked in order to work.</remarks>
[DataField, AutoNetworkedField]
public float JointRepairDamage = 1f;

/// <summary>
/// Interval at which damage is calculated for each joint.
/// </summary>
/// <remarks>Not currently implemented; needs to be reworked in order to work.</remarks>
[DataField, AutoNetworkedField]
public TimeSpan DamageInterval = TimeSpan.FromMilliseconds(200);

/// <summary>
/// List of all joints and their respective pulled entities created by this leash.
/// </summary>
Expand All @@ -88,12 +67,6 @@ public sealed partial class LeashData
[DataField]
public NetEntity? LeashVisuals = null;

[DataField]
public float Damage = 0f;

[DataField]
public TimeSpan NextDamage = TimeSpan.Zero;

public LeashData(string jointId, NetEntity pulled)
{
JointId = jointId;
Expand Down
88 changes: 36 additions & 52 deletions Content.Shared/Floofstation/Leash/LeashSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,8 @@ public override void Initialize()
UpdatesBefore.Add(typeof(SharedPhysicsSystem));

SubscribeLocalEvent<LeashAnchorComponent, BeingUnequippedAttemptEvent>(OnAnchorUnequipping);
SubscribeLocalEvent<LeashedComponent, ContainerGettingInsertedAttemptEvent>(OnLeashedInserting);
SubscribeLocalEvent<LeashComponent, JointRemovedEvent>(OnJointRemoved);
SubscribeLocalEvent<LeashAnchorComponent, GetVerbsEvent<EquipmentVerb>>(OnGetEquipmentVerbs);
SubscribeLocalEvent<LeashedComponent, JointRemovedEvent>(OnJointRemoved, after: [typeof(SharedJointSystem)]);
SubscribeLocalEvent<LeashedComponent, GetVerbsEvent<InteractionVerb>>(OnGetLeashedVerbs);

SubscribeLocalEvent<LeashAnchorComponent, LeashAttachDoAfterEvent>(OnAttachDoAfter);
Expand Down Expand Up @@ -73,30 +72,24 @@ public override void Update(float frameTime)
if (data.Pulled == NetEntity.Invalid || !TryGetEntity(data.Pulled, out var target))
continue;

// Client side only: set max distance to infinity to prevent the client from ever predicting leashes.
if (_net.IsClient
&& TryComp<JointComponent>(target, out var jointComp)
&& jointComp.GetJoints.TryGetValue(data.JointId, out var joint)
&& joint is DistanceJoint distanceJoint
)
distanceJoint.MaxLength = float.MaxValue;

if (_net.IsClient)
continue;

// Break each leash joint whose entities are on different maps or are too far apart
var targetXForm = Transform(target.Value);
if (targetXForm.MapUid != sourceXForm.MapUid
|| !sourceXForm.Coordinates.TryDistance(EntityManager, targetXForm.Coordinates, out var dst)
|| dst > leash.MaxDistance)
|| dst > leash.MaxDistance
)
RemoveLeash(target.Value, (leashEnt, leash));

// Calculate joint damage
if (_timing.CurTime < data.NextDamage
|| !TryComp<JointComponent>(target, out var jointComp)
|| !jointComp.GetJoints.TryGetValue(data.JointId, out var joint))
continue;

// TODO reaction force always returns 0 and thus damage doesn't work
// TODO find another way to calculate how much force is being excerted to hold the two entities together
// var damage = joint.GetReactionForce(1 / (float) leash.DamageInterval.TotalSeconds).Length() - leash.JointRepairDamage;
// data.Damage = Math.Max(0f, data.Damage + damage);
// data.NextDamage = _timing.CurTime + leash.DamageInterval;
//
// if (damage >= leash.BreakDamage && !_net.IsClient)
// {
// _popups.PopupPredicted(Loc.GetString("leash-snap-popup", ("leash", leashEnt)), target, null, PopupType.SmallCaution);
// RemoveLeash(target, (leashEnt, leash), true);
// }
}
}

Expand All @@ -115,33 +108,6 @@ private void OnAnchorUnequipping(Entity<LeashAnchorComponent> ent, ref BeingUneq
args.Cancel();
}

private void OnLeashedInserting(Entity<LeashedComponent> ent, ref ContainerGettingInsertedAttemptEvent args)
{
// Prevent the entity from entering crates and the like because that would instantly break all joints on it, including the leash
if (!Exists(ent.Comp.Puller)
|| !Exists(ent.Comp.Anchor)
|| !TryComp<LeashComponent>(ent.Comp.Puller, out var leashPuller)
|| !TryComp<LeashAnchorComponent>(ent.Comp.Anchor, out var leashAnchor))
return;

args.Cancel();
// This is hella unsafe to do, but we recreate the joint because dumb storage system removes it before raising the event.
// We have to pray that OnJointRemoved already was called and that it deferred the removal of everything that used to exist
// I HATE STORAGE
DoLeash((ent.Comp.Anchor.Value, leashAnchor), (ent.Comp.Puller.Value, leashPuller), ent);
}

private void OnJointRemoved(Entity<LeashComponent> ent, ref JointRemovedEvent args)
{
var id = args.Joint.ID;
if (!ent.Comp.Leashed.TryFirstOrDefault(it => it.JointId == id, out var data)
|| !TryGetEntity(data.Pulled, out var leashedEnt)
|| !TryComp<LeashedComponent>(leashedEnt, out var leashed))
return;

RemoveLeash((leashedEnt.Value, leashed), ent!, false);
}

private void OnGetEquipmentVerbs(Entity<LeashAnchorComponent> ent, ref GetVerbsEvent<EquipmentVerb> args)
{
if (!args.CanAccess
Expand Down Expand Up @@ -193,6 +159,26 @@ private void OnGetLeashedVerbs(Entity<LeashedComponent> ent, ref GetVerbsEvent<I
});
}

private void OnJointRemoved(Entity<LeashedComponent> ent, ref JointRemovedEvent args)
{
var id = args.Joint.ID;
if (_timing.ApplyingState
|| ent.Comp.LifeStage >= ComponentLifeStage.Removing
|| ent.Comp.Puller is not { } puller
|| !TryComp<LeashAnchorComponent>(ent.Comp.Anchor, out var anchor)
|| !TryComp<LeashComponent>(puller, out var leash)
|| !Transform(ent).Coordinates.TryDistance(EntityManager, Transform(puller).Coordinates, out var dst)
|| dst > leash.MaxDistance
)
return;

// If the entity still has a leashed comp, and is on the same map, and is within the max distance of the leash
// Then the leash was likely broken due to some weird unforeseen fucking robust toolbox magic. We can try to recreate it.
// This is hella unsafe to do. It will crash in debug builds under certain conditions. Luckily, release builds are safe.
RemoveLeash(ent!, (puller, leash), false);
DoLeash((ent.Comp.Anchor.Value, anchor), (puller, leash), ent);
}

private void OnAttachDoAfter(Entity<LeashAnchorComponent> ent, ref LeashAttachDoAfterEvent args)
{
if (args.Cancelled || args.Handled
Expand Down Expand Up @@ -279,6 +265,7 @@ private DistanceJoint CreateLeashJoint(string jointId, Entity<LeashComponent> le
joint.MaxLength = leash.Comp.Length;
joint.Stiffness = 1f;
joint.CollideConnected = true; // This is just for performance reasons and doesn't actually make mobs collide.
joint.Damping = 1f;

return joint;
}
Expand Down Expand Up @@ -380,10 +367,7 @@ public void DoLeash(Entity<LeashAnchorComponent> anchor, Entity<LeashComponent>

// I'd like to use a chain joint or smth, but it's too hard and oftentimes buggy - lamia is a good bad example of that.
var joint = CreateLeashJoint(leashedComp.JointId, leash, leashTarget);
var data = new LeashComponent.LeashData(leashedComp.JointId, netLeashTarget)
{
NextDamage = _timing.CurTime + leash.Comp.DamageInterval
};
var data = new LeashComponent.LeashData(leashedComp.JointId, netLeashTarget);

if (leash.Comp.LeashSprite is { } sprite)
{
Expand Down
38 changes: 38 additions & 0 deletions Resources/Changelog/Floof.yml
Original file line number Diff line number Diff line change
Expand Up @@ -926,3 +926,41 @@ Entries:
id: 126
time: '2024-09-13T11:03:42.0000000+00:00'
url: https://github.com/Fansana/floofstation1/pull/189
- author: ShatteredSwords
changes:
- type: Add
message: Suspenders are now in loadouts.
- type: Tweak
message: >-
Loadouts items from Floof are a lot cheaper, but you cannot take an
extra change of clothes.
id: 127
time: '2024-09-15T06:53:49.0000000+00:00'
url: https://github.com/Fansana/floofstation1/pull/186
- author: cynical24
changes:
- type: Add
message: three new harpy instruments
id: 128
time: '2024-09-16T09:28:14.0000000+00:00'
url: https://github.com/Fansana/floofstation1/pull/184
- author: neuPanda
changes:
- type: Add
message: >-
Added 4 new drinks: Axel's Ale, The Cute Captain, Jenn in Tonic,
Hallelujah
id: 129
time: '2024-09-17T18:59:00.0000000+00:00'
url: https://github.com/Fansana/floofstation1/pull/180
- author: Mnemotechnician
changes:
- type: Add
message: You can now leash janibots, medibots, and more.
- type: Fix
message: >-
Leashes no longer cause broken client-side behavior, and no longer break
during FTL.
id: 130
time: '2024-09-17T19:07:13.0000000+00:00'
url: https://github.com/Fansana/floofstation1/pull/193
4 changes: 4 additions & 0 deletions Resources/Locale/en-US/Floof/flavors/flavor-profiles.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,7 @@ flavor-complex-thewaterslide = like unsanitary depravity
flavor-complex-whiskeysour = sour and like molasses
flavor-complex-whitechocolatechip = like white chocolate chips
flavor-complex-yeolhandy = like oranges and solitude
flavor-complex-thecutecaptain = like moonlight
flavor-complex-axelsale = like a long day on the frontier
flavor-complex-jenntonic = sweet with a hidden bite
flavor-complex-hallelujah = a moment of peace
8 changes: 8 additions & 0 deletions Resources/Locale/en-US/Floof/loadouts/itemgroups.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
character-item-group-LoadoutEyes2 = Civilian Eyewear
character-item-group-LoadoutGloves2 = Civilian Gloves
character-item-group-LoadoutHead2 = Civilian Headgear
character-item-group-LoadoutMasks2 = Civilian Masks
character-item-group-LoadoutNeck2 = Civilian Neckwear
character-item-group-LoadoutOuter2 = Civilian Outerwear
character-item-group-LoadoutShoes2 = Civilian Shoes
character-item-group-LoadoutUniformsCivilian2 = Civilian Uniforms
Original file line number Diff line number Diff line change
Expand Up @@ -177,3 +177,15 @@ reagent-desc-whiskeysour = Shelter from the Noöspheric Storm.
reagent-name-yeolhandy = ye ol handy
reagent-desc-yeolhandy = The loner's choice, cold as their bed.
reagent-name-the-cute-captain = The Cute Captain
reagent-desc-the-cute-captain = Light blue liquid with a sweet floral scent and a hint of pomegranate
reagent-name-axels-ale = Axel's Ale
reagent-desc-axels-ale = Red like the color of a setting sun on a beach
reagent-name-jenn-tonic = Jenn in Tonic
reagent-desc-jenn-tonic = Light golden and bubbly, what could go wrong?
reagent-name-hallelujah = Hallelujah
reagent-desc-hallelujah = Exactly what you need.
1 change: 1 addition & 0 deletions Resources/Prototypes/Entities/Mobs/NPCs/silicon.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@
- GalacticCommon
- RobotTalk
- type: PsionicInsulation
- type: LeashAnchor # Floofstation

- type: entity
parent: MobSiliconBase
Expand Down
25 changes: 25 additions & 0 deletions Resources/Prototypes/Floof/CharacterItemGroups/eyesGroup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
- type: characterItemGroup
id: LoadoutEyes2
items:
- type: loadout
id: LoadoutEyesEyepatch
- type: loadout
id: LoadoutEyesGlasses
- type: loadout
id: LoadoutEyesGlassesJamjar
- type: loadout
id: LoadoutEyesGlassesJensen
- type: loadout
id: LoadoutEyesBlindfold
- type: loadout
id: LoadoutItemCheapSunglasses
- type: loadout
id: LoadoutItemSunglasses
- type: loadout
id: LoadoutItemBlindfoldFake
- type: loadout
id: LoadoutEyesThermalBudget
- type: loadout
id: LoadoutEyesChemicalBudget
- type: loadout
id: LoadoutEyesMesonBudget
47 changes: 47 additions & 0 deletions Resources/Prototypes/Floof/CharacterItemGroups/gloveGroup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
- type: characterItemGroup
id: LoadoutGloves2
items:
- type: loadout
id: LoadoutHandsColorPurple
- type: loadout
id: LoadoutHandsColorRed
- type: loadout
id: LoadoutHandsColorBlack
- type: loadout
id: LoadoutHandsColorBlue
- type: loadout
id: LoadoutHandsColorBrown
- type: loadout
id: LoadoutHandsColorGray
- type: loadout
id: LoadoutHandsColorGreen
- type: loadout
id: LoadoutHandsColorLightBrown
- type: loadout
id: LoadoutHandsColorOrange
- type: loadout
id: LoadoutHandsColorWhite
- type: loadout
id: LoadoutHandsColorYellowBudget
- type: loadout
id: LoadoutHandsGlovesLeather
- type: loadout
id: LoadoutHandsGlovesPowerglove
- type: loadout
id: LoadoutHandsGlovesRobohands
- type: loadout
id: LoadoutHandsGlovesFingerless
- type: loadout
id: LoadoutHandsGlovesTacticalMaid
- type: loadout
id: LoadoutClothingHandsPlainWarmers
- type: loadout
id: LoadoutClothingHandsStripePurpleWarmers
- type: loadout
id: LoadoutClothingHandsStripeRainbowWarmers
- type: loadout
id: LoadoutClothingHandsCoderWarmers
- type: loadout
id: LoadoutClothingHandsCoderValidWarmers
- type: loadout
id: LoadoutClothingHandsBeeWarmers
Loading

0 comments on commit 23626a0

Please sign in to comment.