Skip to content

Commit

Permalink
Merge branch 'DeltaV-Station:master' into Paradox-Patch
Browse files Browse the repository at this point in the history
  • Loading branch information
Stop-Signs authored Oct 15, 2024
2 parents 33acbdc + 054bd8b commit 4390b46
Show file tree
Hide file tree
Showing 63 changed files with 454 additions and 349 deletions.
2 changes: 1 addition & 1 deletion Content.Client/Inventory/StrippableBoundUserInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public void UpdateMenu()
}
}

if (EntMan.TryGetComponent<HandsComponent>(Owner, out var handsComp))
if (EntMan.TryGetComponent<HandsComponent>(Owner, out var handsComp) && handsComp.CanBeStripped)
{
// good ol hands shit code. there is a GuiHands comparer that does the same thing... but these are hands
// and not gui hands... which are different...
Expand Down
2 changes: 2 additions & 0 deletions Content.Client/Paper/UI/PaperWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,8 @@ protected override DragMode GetDragModeFor(Vector2 relativeMousePos)

private void RunOnSaved()
{
// Prevent further saving while text processing still in
SaveButton.Disabled = true;
OnSaved?.Invoke(Rope.Collapse(Input.TextRope));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -398,10 +398,6 @@ private void OnActionsUpdated()
{
QueueWindowUpdate();

// TODO ACTIONS allow buttons to persist across state applications
// Then we don't have to interrupt drags any time the buttons get rebuilt.
_menuDragHelper.EndDrag();

if (_actionsSystem != null)
_container?.SetActionData(_actionsSystem, _actions.ToArray());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,26 @@ public ActionButton this[int index]
get => (ActionButton) GetChild(index);
}

private void BuildActionButtons(int count)
public void SetActionData(ActionsSystem system, params EntityUid?[] actionTypes)
{
var uniqueCount = Math.Min(system.GetClientActions().Count(), actionTypes.Length + 1);
var keys = ContentKeyFunctions.GetHotbarBoundKeys();

Children.Clear();
for (var index = 0; index < count; index++)
for (var i = 0; i < uniqueCount; i++)
{
if (i >= ChildCount)
{
AddChild(MakeButton(i));
}

if (!actionTypes.TryGetValue(i, out var action))
action = null;
((ActionButton) GetChild(i)).UpdateData(action, system);
}

for (var i = ChildCount - 1; i >= uniqueCount; i--)
{
Children.Add(MakeButton(index));
RemoveChild(GetChild(i));
}

ActionButton MakeButton(int index)
Expand All @@ -55,20 +67,6 @@ ActionButton MakeButton(int index)
}
}

public void SetActionData(ActionsSystem system, params EntityUid?[] actionTypes)
{
var uniqueCount = Math.Min(system.GetClientActions().Count(), actionTypes.Length + 1);
if (ChildCount != uniqueCount)
BuildActionButtons(uniqueCount);

for (var i = 0; i < uniqueCount; i++)
{
if (!actionTypes.TryGetValue(i, out var action))
action = null;
((ActionButton) GetChild(i)).UpdateData(action, system);
}
}

public void ClearActionData()
{
foreach (var button in Children)
Expand Down
21 changes: 15 additions & 6 deletions Content.Server/DeltaV/StationEvents/Events/GlimmerMobSpawnRule.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Linq;
using Content.Server.Psionics.Glimmer;
using Content.Server.Station.Systems;
using Content.Server.StationEvents;
using Content.Server.StationEvents.Components;
using Content.Server.StationEvents.Events;
Expand All @@ -15,14 +16,18 @@ namespace Content.Server.DeltaV.StationEvents.Events;
public sealed class GlimmerMobRule : StationEventSystem<GlimmerMobRuleComponent>
{
[Dependency] private readonly GlimmerSystem _glimmer = default!;
[Dependency] private readonly StationSystem _stationSystem = default!;

protected override void Started(EntityUid uid, GlimmerMobRuleComponent comp, GameRuleComponent gameRule, GameRuleStartedEvent args)
{
base.Started(uid, comp, gameRule, args);

var glimmerSources = GetCoords<GlimmerSourceComponent>();
var normalSpawns = GetCoords<VentCritterSpawnLocationComponent>();
var hiddenSpawns = GetCoords<MidRoundAntagSpawnLocationComponent>();
if (!TryGetRandomStation(out var station))
return;

var glimmerSources = GetCoords<GlimmerSourceComponent>(station.Value);
var normalSpawns = GetCoords<VentCritterSpawnLocationComponent>(station.Value);
var hiddenSpawns = GetCoords<MidRoundAntagSpawnLocationComponent>(station.Value);

var psionics = EntityQuery<PsionicComponent, NpcFactionMemberComponent>().Count();
var baseCount = Math.Max(1, psionics / comp.MobsPerPsionic);
Expand All @@ -43,15 +48,19 @@ protected override void Started(EntityUid uid, GlimmerMobRuleComponent comp, Gam
}
}

private List<EntityCoordinates> GetCoords<T>() where T : IComponent
private List<EntityCoordinates> GetCoords<T>(EntityUid station) where T : IComponent
{
var coords = new List<EntityCoordinates>();
var query = EntityQueryEnumerator<TransformComponent, T>();

while (query.MoveNext(out var xform, out _))
{
coords.Add(xform.Coordinates);
}
if (xform.GridUid == null)
continue;

if (_stationSystem.GetOwningStation(xform.GridUid.Value) == station)
coords.Add(xform.Coordinates);
}
return coords;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace Content.Server.Destructible.Thresholds.Behaviors;

[DataDefinition]
public sealed partial class TimerStartBehavior : IThresholdBehavior
{
public void Execute(EntityUid owner, DestructibleSystem system, EntityUid? cause = null)
{
system.TriggerSystem.StartTimer(owner, cause);
}
}
15 changes: 15 additions & 0 deletions Content.Server/Explosion/Components/TimerStartOnSignalComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using Content.Shared.DeviceLinking;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;

namespace Content.Server.Explosion.Components
{
/// <summary>
/// Sends a trigger when signal is received.
/// </summary>
[RegisterComponent]
public sealed partial class TimerStartOnSignalComponent : Component
{
[DataField("port", customTypeSerializer: typeof(PrototypeIdSerializer<SinkPortPrototype>))]
public string Port = "Timer";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -487,9 +487,12 @@ private void ProcessEntity(
&& physics.BodyType == BodyType.Dynamic)
{
var pos = _transformSystem.GetWorldPosition(xform);
var dir = pos - epicenter.Position;
if (dir.IsLengthZero())
dir = _robustRandom.NextVector2().Normalized();
_throwingSystem.TryThrow(
uid,
pos - epicenter.Position,
dir,
physics,
xform,
_projectileQuery,
Expand Down
15 changes: 15 additions & 0 deletions Content.Server/Explosion/EntitySystems/TriggerSystem.Signal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ private void InitializeSignal()
{
SubscribeLocalEvent<TriggerOnSignalComponent,SignalReceivedEvent>(OnSignalReceived);
SubscribeLocalEvent<TriggerOnSignalComponent,ComponentInit>(OnInit);

SubscribeLocalEvent<TimerStartOnSignalComponent,SignalReceivedEvent>(OnTimerSignalReceived);
SubscribeLocalEvent<TimerStartOnSignalComponent,ComponentInit>(OnTimerSignalInit);
}

private void OnSignalReceived(EntityUid uid, TriggerOnSignalComponent component, ref SignalReceivedEvent args)
Expand All @@ -24,5 +27,17 @@ private void OnInit(EntityUid uid, TriggerOnSignalComponent component, Component
{
_signalSystem.EnsureSinkPorts(uid, component.Port);
}

private void OnTimerSignalReceived(EntityUid uid, TimerStartOnSignalComponent component, ref SignalReceivedEvent args)
{
if (args.Port != component.Port)
return;

StartTimer(uid, args.Trigger);
}
private void OnTimerSignalInit(EntityUid uid, TimerStartOnSignalComponent component, ComponentInit args)
{
_signalSystem.EnsureSinkPorts(uid, component.Port);
}
}
}
3 changes: 2 additions & 1 deletion Content.Server/Explosion/EntitySystems/TriggerSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,8 @@ private void HandleRattleTrigger(EntityUid uid, RattleComponent component, Trigg
return;

// Gets location of the implant
var posText = FormattedMessage.RemoveMarkupOrThrow(_navMap.GetNearestBeaconString(uid));
var position = _transformSystem.GetMapCoordinates(Transform(uid)).Position; // DeltaV
var posText = FormattedMessage.RemoveMarkupOrThrow(_navMap.GetNearestBeaconString(uid) + $" ({(int)position[0]}, {(int)position[1]})"); // DeltaV modified, adds the GPS coordinates on the message.
var critMessage = Loc.GetString(component.CritMessage, ("user", implanted.ImplantedEntity.Value), ("position", posText));
var deathMessage = Loc.GetString(component.DeathMessage, ("user", implanted.ImplantedEntity.Value), ("position", posText));

Expand Down
3 changes: 3 additions & 0 deletions Content.Server/Shuttles/Systems/ShuttleConsoleSystem.FTL.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ private void ConsoleFTL(Entity<ShuttleConsoleComponent> ent, EntityCoordinates t
if (!TryComp(shuttleUid, out ShuttleComponent? shuttleComp))
return;

if (shuttleComp.Enabled == false)
return;

// Check shuttle can even FTL
if (!_shuttle.CanFTL(shuttleUid.Value, out var reason))
{
Expand Down
20 changes: 15 additions & 5 deletions Content.Server/Shuttles/Systems/ShuttleSystem.FasterThanLight.cs
Original file line number Diff line number Diff line change
Expand Up @@ -225,18 +225,28 @@ public void RemoveFTLDestination(EntityUid uid)
/// </summary>
public bool CanFTL(EntityUid shuttleUid, [NotNullWhen(false)] out string? reason)
{
// Currently in FTL already
if (HasComp<FTLComponent>(shuttleUid))
{
reason = Loc.GetString("shuttle-console-in-ftl");
return false;
}

if (FTLMassLimit > 0 &&
TryComp(shuttleUid, out PhysicsComponent? shuttlePhysics) &&
shuttlePhysics.Mass > FTLMassLimit)
if (TryComp<PhysicsComponent>(shuttleUid, out var shuttlePhysics))
{
reason = Loc.GetString("shuttle-console-mass");
return false;
// Static physics type is set when station anchor is enabled
if (shuttlePhysics.BodyType == BodyType.Static)
{
reason = Loc.GetString("shuttle-console-static");
return false;
}

// Too large to FTL
if (FTLMassLimit > 0 && shuttlePhysics.Mass > FTLMassLimit)
{
reason = Loc.GetString("shuttle-console-mass");
return false;
}
}

if (HasComp<PreventPilotComponent>(shuttleUid))
Expand Down
6 changes: 6 additions & 0 deletions Content.Shared/Hands/Components/HandsComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ public sealed partial class HandsComponent : Component

[DataField]
public DisplacementData? HandDisplacement;

/// <summary>
/// If false, hands cannot be stripped, and they do not show up in the stripping menu.
/// </summary>
[DataField]
public bool CanBeStripped = true;
}

[Serializable, NetSerializable]
Expand Down
9 changes: 9 additions & 0 deletions Content.Shared/Strip/SharedStrippableSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ private void StripHand(
!Resolve(target, ref targetStrippable))
return;

if (!target.Comp.CanBeStripped)
return;

if (!_handsSystem.TryGetHand(target.Owner, handId, out var handSlot))
return;

Expand Down Expand Up @@ -349,6 +352,9 @@ private bool CanStripInsertHand(
!Resolve(target, ref target.Comp))
return false;

if (!target.Comp.CanBeStripped)
return false;

if (user.Comp.ActiveHand == null)
return false;

Expand Down Expand Up @@ -449,6 +455,9 @@ private bool CanStripRemoveHand(
if (!Resolve(target, ref target.Comp))
return false;

if (!target.Comp.CanBeStripped)
return false;

if (!_handsSystem.TryGetHand(target, handName, out var handSlot, target.Comp))
{
_popupSystem.PopupCursor(Loc.GetString("strippable-component-item-slot-free-message", ("owner", Identity.Name(target, EntityManager, user))));
Expand Down
Loading

0 comments on commit 4390b46

Please sign in to comment.