Skip to content

Commit

Permalink
Merge branch 'master' into prowlerupdateagain
Browse files Browse the repository at this point in the history
  • Loading branch information
dvir001 authored Oct 17, 2024
2 parents 44e9ddc + f029ce4 commit ee2aaa1
Show file tree
Hide file tree
Showing 14 changed files with 512 additions and 228 deletions.
10 changes: 10 additions & 0 deletions Content.Shared/_NF/Foldable/FoldableFixtureComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace Content.Shared._NF.Foldable.Systems;

[RegisterComponent]
public sealed partial class FoldableFixtureComponent : Component
{
[DataField(required: true)]
public List<string> FoldedFixtures;
[DataField(required: true)]
public List<string> UnfoldedFixtures;
}
56 changes: 56 additions & 0 deletions Content.Shared/_NF/Foldable/FoldableFixtureSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
using Content.Shared.Foldable;
using Robust.Shared.Physics.Systems;

namespace Content.Shared._NF.Foldable.Systems;

public sealed class FoldableFixtureSystem : EntitySystem
{
[Dependency] private readonly FixtureSystem _fixtures = default!;
[Dependency] private readonly SharedPhysicsSystem _physics = default!;

public override void Initialize()
{
SubscribeLocalEvent<FoldableFixtureComponent, MapInitEvent>(OnMapInit);
SubscribeLocalEvent<FoldableFixtureComponent, FoldedEvent>(OnFolded);
}

private void OnMapInit(EntityUid uid, FoldableFixtureComponent component, MapInitEvent args)
{
if (TryComp<FoldableComponent>(uid, out var foldable))
SetFoldedFixtures(uid, foldable.IsFolded, component);
}

private void OnFolded(EntityUid uid, FoldableFixtureComponent? component, ref FoldedEvent args)
{
SetFoldedFixtures(uid, args.IsFolded, component);
}

// Sets all relevant fixtures for the entity to an appropriate hard/soft state.
private void SetFoldedFixtures(EntityUid uid, bool isFolded, FoldableFixtureComponent? component)
{
if (!Resolve(uid, ref component))
return;

if (isFolded)
{
SetAllFixtureHardness(uid, component.FoldedFixtures, true);
SetAllFixtureHardness(uid, component.UnfoldedFixtures, false);
}
else
{
SetAllFixtureHardness(uid, component.FoldedFixtures, false);
SetAllFixtureHardness(uid, component.UnfoldedFixtures, true);
}
}

// Sets all fixtures on an entity in a list to either be hard or soft.
void SetAllFixtureHardness(EntityUid uid, List<string> fixtures, bool hard)
{
foreach (var fixName in fixtures)
{
var fixture = _fixtures.GetFixtureOrNull(uid, fixName);
if (fixture != null)
_physics.SetHard(uid, fixture, hard);
}
}
}
18 changes: 18 additions & 0 deletions Resources/Changelog/Frontier.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4678,3 +4678,21 @@ Entries:
message: Lubrication now affects base and hyper lathe print times at 0.5x rates.
id: 5418
time: '2024-10-17T18:41:39.0000000+00:00'
- author: erhardsteinhauer
changes:
- type: Add
message: Added foldable plastic table to compliment folding chairs.
id: 5419
time: '2024-10-17T20:59:15.0000000+00:00'
- author: dustylens
changes:
- type: Add
message: FSB Stasis now boasts a medical assembler.
id: 5420
time: '2024-10-17T21:35:46.0000000+00:00'
- author: whatston3
changes:
- type: Remove
message: The salvage magnet is no longer printable from the circuit imprinter.
id: 5421
time: '2024-10-17T21:55:25.0000000+00:00'
Loading

0 comments on commit ee2aaa1

Please sign in to comment.