Skip to content

Commit

Permalink
Add CanMove field to POI prototype (new-frontiers-14#1892)
Browse files Browse the repository at this point in the history
* Add CanMove field to POI definitions

* Reversed the damping strengths
  • Loading branch information
whatston3 authored Aug 22, 2024
1 parent 2ed6364 commit e14202d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
16 changes: 16 additions & 0 deletions Content.Server/_NF/GameRule/NfAdventureRuleSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
using Content.Shared.CCVar;
using Content.Shared.NF14.CCVar;
using Robust.Shared.Configuration;
using Robust.Shared.Physics.Components;
using Content.Server.Shuttles.Components;

namespace Content.Server._NF.GameRule;

Expand All @@ -49,6 +51,7 @@ public sealed class NfAdventureRuleSystem : GameRuleSystem<AdventureRuleComponen
[Dependency] private readonly IConsoleHost _console = default!;
[Dependency] private readonly StationSystem _station = default!;
[Dependency] private readonly ShuttleSystem _shuttle = default!;
[Dependency] private readonly PhysicsSystem _physics = default!;

private readonly HttpClient _httpClient = new();

Expand Down Expand Up @@ -337,6 +340,9 @@ private bool TrySpawnPoiGrid(PointOfInterestPrototype proto, Vector2 offset, out
_station.InitializeNewStation(stationProto.Stations[proto.ID], mapUids, stationName);
}

// Cache our damping strength
float dampingStrength = proto.CanMove ? 0.05f : 999999f;

foreach (var grid in mapUids)
{
var meta = EnsureComp<MetaDataComponent>(grid);
Expand All @@ -346,6 +352,16 @@ private bool TrySpawnPoiGrid(PointOfInterestPrototype proto, Vector2 offset, out
{
_shuttle.AddIFFFlag(grid, IFFFlags.HideLabel);
}

// Ensure damping for each grid in the POI - set the shuttle component if it exists just to be safe
var physics = EnsureComp<PhysicsComponent>(grid);
_physics.SetAngularDamping(grid, physics, dampingStrength);
_physics.SetLinearDamping(grid, physics, dampingStrength);
if (TryComp<ShuttleComponent>(grid, out var shuttle))
{
shuttle.AngularDamping = dampingStrength;
shuttle.LinearDamping = dampingStrength;
}
}
gridUid = mapUids[0];
return true;
Expand Down
6 changes: 6 additions & 0 deletions Content.Shared/_NF/GameRule/PointOfInterestPrototype.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ public sealed partial class PointOfInterestPrototype : IPrototype
[DataField("iffColor")]
public Color IffColor { get; private set; } = (100, 100, 100, 100);

/// <summary>
/// Whether or not the POI itself should be able to move or be moved. Should be false for immobile POIs (static stations) and true for ship-like POIs.
/// </summary>
[DataField("canMove")]
public bool CanMove { get; private set; }

/// <summary>
/// Whether or not the POI is shown on IFF.
/// </summary>
Expand Down

0 comments on commit e14202d

Please sign in to comment.