Skip to content
Open
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
10 changes: 9 additions & 1 deletion Content.Server/Physics/Controllers/MoverController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,15 @@ public Vector2 GetDirectionThrust(Vector2 dir, ShuttleComponent shuttle, Physics
dir = dir - dirCompVel + scaledComp;
}

return dir * shuttle.AccelerationMultiplier;
// return dir * shuttle.AccelerationMultiplier; // LuaM comented
// LuaM-start:
var thrust = dir * shuttle.AccelerationMultiplier;
if (shuttle.BodyModifier == ShuttleSystem.DampenDampingStrength)
{
return thrust * 1.3f;
}
return thrust;
// LuaM-end
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ public sealed partial class ShuttleConsoleComponent : SharedShuttleConsoleCompon
public SoundSpecifier? AutopilotDoneSound = new SoundPathSpecifier("/Audio/Effects/Shuttle/radar_ping.ogg");
// </Mono>

// LuaM-start:
[ViewVariables(VVAccess.ReadWrite)]
public float? AutopilotMaxSpeed;
// LuaM-end

// Network Port Button Source Ports
[DataField]
public List<ProtoId<SourcePortPrototype>> SourcePorts = new()
Expand Down
20 changes: 20 additions & 0 deletions Content.Server/Shuttles/Systems/ShuttleConsoleSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
using Robust.Shared.Prototypes;
using Content.Shared._Crescent.ShipShields; // Forge
using Robust.Shared.Timing; // Forge
using Content.Server._Mono.NPC.HTN; // LuaM

namespace Content.Server.Shuttles.Systems;

Expand Down Expand Up @@ -463,6 +464,25 @@ private void OnConsoleShutdown(EntityUid uid, ShuttleConsoleComponent component,
ClearPilots(component);
}

// LuaM-start: | check for pilot or autopilot
public bool IsGridManned(EntityUid gridUid)
{
var consoles = new HashSet<Entity<ShuttleConsoleComponent>>();
_lookup.GetChildEntities(gridUid, consoles);

foreach (var console in consoles)
{
if (console.Comp.SubscribedPilots.Count > 0)
return true;

if (HasComp<ShipSteererComponent>(console.Owner))
return true;
}

return false;
}
// LuaM-end

public void AddPilot(EntityUid uid, EntityUid entity, ShuttleConsoleComponent component)
{
if (!EntityManager.TryGetComponent(entity, out PilotComponent? pilotComponent)
Expand Down
1 change: 1 addition & 0 deletions Content.Server/Shuttles/Systems/ShuttleSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ public override void Update(float frameTime)
{
base.Update(frameTime);
UpdateHyperspace();
UpdateUnmannedShuttles(); // LuaM stop uncontrolled shuttles
}

private void OnGridFixtureChange(EntityUid uid, FixturesComponent manager, GridFixtureChangeEvent args)
Expand Down
2 changes: 2 additions & 0 deletions Content.Server/_Mono/NPC/HTN/ShipSteererComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@ public sealed partial class ShipSteererComponent : Component
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
public float TargetRotation = 0f;

public float? MaxVelocity = null; // LuaM
}

public enum ShipSteeringStatus : byte
Expand Down
1 change: 1 addition & 0 deletions Content.Server/_Mono/NPC/HTN/ShipSteeringSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ private void OnSteererGetInputs(Entity<ShipSteererComponent> ent, ref GetShuttle
};

args.Input = ProcessMovement(ref context, config);
args.SetMaxVelocity = ent.Comp.MaxVelocity; // LuaM
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public sealed partial class ToggleableSignatureComponent : Component
public bool Examinable = true;

[DataField]
public bool Enabled = false;
public bool Enabled = true; // LuaM: false > true

[DataField]
public RadarBlipComponent Blip = new();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Content.Shared._Mono.Shuttles;
using Robust.Shared.Audio;
using Robust.Shared.Audio.Systems;
using Content.Server._Mono.NPC.HTN; // LuaM

namespace Content.Server._Mono.Shuttles;

Expand All @@ -30,6 +31,11 @@ private void OnAutopilotMessage(Entity<ShuttleConsoleComponent> ent, ref Shuttle
var blackboard = htn.Blackboard;
blackboard.SetValue(ent.Comp.AutopilotTargetKey, _transform.ToCoordinates(args.Coordinates));
blackboard.SetValue(ent.Comp.AutopilotRotationKey, args.Angle + MathF.PI);

// LuaM-start:
var steerer = EnsureComp<ShipSteererComponent>(ent.Owner);
steerer.MaxVelocity = ent.Comp.AutopilotMaxSpeed;
// LuaM-end
}

private void OnSteeringDone(Entity<ShuttleConsoleComponent> ent, ref SteeringDoneEvent args)
Expand Down
50 changes: 36 additions & 14 deletions Content.Server/_NF/PacifiedZone/PacifiedZoneGeneratorSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Content.Shared.Mind;
using Content.Shared.Roles.Jobs;
using Content.Server.Players.PlayTimeTracking;
using Content.Shared.Mobs.Components; // LuaM

namespace Content.Server._NF.PacifiedZone
{
Expand Down Expand Up @@ -63,27 +64,48 @@ public override void Update(float frameTime)
private void UpdatePacifiedState(EntityUid genUid, PacifiedZoneGeneratorComponent component)
{
List<EntityUid> newEntities = new List<EntityUid>();
var query = _lookup.GetEntitiesInRange<HumanoidAppearanceComponent>(Transform(genUid).Coordinates, component.Radius);
// var query = _lookup.GetEntitiesInRange<HumanoidAppearanceComponent>(Transform(genUid).Coordinates, component.Radius); // LuaM comented
var query = _lookup.GetEntitiesInRange<MobStateComponent>(Transform(genUid).Coordinates, component.Radius); // LuaM
foreach (var humanoidUid in query)
{
// Check preconditions for an entity to be pacified at all.
// If player matches an immune role, or has playtime above a zone's threshold, it should not be pacified.
if (!_mindSystem.TryGetMind(humanoidUid, out var mindId, out var mind))
continue;

_jobSystem.MindTryGetJobId(mindId, out var jobId);
// LuaM-comented-start:
// // Check preconditions for an entity to be pacified at all.
// // If player matches an immune role, or has playtime above a zone's threshold, it should not be pacified.
// if (!_mindSystem.TryGetMind(humanoidUid, out var mindId, out var mind))
// continue;

// _jobSystem.MindTryGetJobId(mindId, out var jobId);

// if (jobId != null && component.ImmuneRoles.Contains(jobId.Value))
// continue;

// if (component.ImmunePlaytime != null)
// {
// var playerInfo = _admin.GetCachedPlayerInfo(mind?.UserId);
// if (playerInfo != null && playerInfo.OverallPlaytime >= component.ImmunePlaytime)
// {
// continue;
// }
// }
// LuaM-comented-end
// LuaM-start:
if (_mindSystem.TryGetMind(humanoidUid, out var mindId, out var mind))
{
_jobSystem.MindTryGetJobId(mindId, out var jobId);

if (jobId != null && component.ImmuneRoles.Contains(jobId.Value))
continue;
if (jobId != null && component.ImmuneRoles.Contains(jobId.Value))
continue;

if (component.ImmunePlaytime != null)
{
var playerInfo = _admin.GetCachedPlayerInfo(mind?.UserId);
if (playerInfo != null && playerInfo.OverallPlaytime >= component.ImmunePlaytime)
if (component.ImmunePlaytime != null)
{
continue;
var playerInfo = _admin.GetCachedPlayerInfo(mind?.UserId);
if (playerInfo != null && playerInfo.OverallPlaytime >= component.ImmunePlaytime)
{
continue;
}
}
}
// LuaM-end

// Existing entity, note it still exists.
if (component.TrackedEntities.Contains(humanoidUid))
Expand Down
44 changes: 43 additions & 1 deletion Content.Server/_NF/Shuttles/Systems/ShuttleSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using Content.Shared.Shuttles.Components;
using Robust.Shared.Physics; // Mono
using Robust.Shared.Physics.Components;
using Robust.Shared.Timing; // LuaM

namespace Content.Server.Shuttles.Systems;

Expand All @@ -18,8 +19,13 @@ public sealed partial class ShuttleSystem
[Dependency] private readonly RadarConsoleSystem _radarConsole = default!;

private const float SpaceFrictionStrength = 0.0075f;
private const float DampenDampingStrength = 0.25f;
public const float DampenDampingStrength = 0.25f; // LuaM private > public
private const float AnchorDampingStrength = 2.5f;
// LuaM-start:
private readonly Dictionary<EntityUid, TimeSpan> _unmannedSince = new();
private static readonly TimeSpan UnmannedGracePeriod = TimeSpan.FromSeconds(3);
private static readonly TimeSpan UnmannedDampenPeriod = TimeSpan.FromSeconds(5);
// LuaM-end
private void NfInitialize()
{
SubscribeLocalEvent<ShuttleConsoleComponent, SetInertiaDampeningRequest>(OnSetInertiaDampening);
Expand Down Expand Up @@ -95,6 +101,7 @@ private void OnSetMaxShuttleSpeed(EntityUid uid, ShuttleConsoleComponent compone
maxSpeed = Math.Max(speed, 0f);

pilot.SetMaxVelocity = maxSpeed;
component.AutopilotMaxSpeed = maxSpeed; // LuaM sync max speed

// Refresh the shuttle consoles to update the UI
_console.RefreshShuttleConsoles(xform.GridUid.Value);
Expand Down Expand Up @@ -148,7 +155,42 @@ public void NfSetPowered(EntityUid uid, ShuttleConsoleComponent component, bool
}
}
}
// LuaM-start: | stop shuttles without control
private void UpdateUnmannedShuttles()
{
var now = _gameTiming.CurTime;
var query = AllEntityQuery<ShuttleComponent, PhysicsComponent, TransformComponent>();

while (query.MoveNext(out var uid, out var shuttle, out var physics, out var xform))
{
if (_console.IsGridManned(uid))
{
_unmannedSince.Remove(uid);
continue;
}

if (!_unmannedSince.TryGetValue(uid, out var since))
{
_unmannedSince[uid] = now;
continue;
}

var elapsed = now - since;

if (elapsed < UnmannedGracePeriod)
continue;

var targetMode = elapsed < UnmannedGracePeriod + UnmannedDampenPeriod
? InertiaDampeningMode.Dampen
: InertiaDampeningMode.Anchor;

if (NfGetInertiaDampeningMode(uid) == targetMode)
continue;

SetInertiaDampening(uid, physics, shuttle, xform, targetMode);
}
}
// LuaM-end
public void NfSetTargetCoordinates(EntityUid uid, ShuttleConsoleComponent component, SetTargetCoordinatesRequest args)
{
if (!TryComp<RadarConsoleComponent>(uid, out var radarConsole))
Expand Down
Loading
Loading