Skip to content

Commit

Permalink
Merge branch 'master' into 2024-11-22-AjustedMerc
Browse files Browse the repository at this point in the history
  • Loading branch information
dvir001 authored Dec 26, 2024
2 parents 7480455 + f354739 commit e52035a
Show file tree
Hide file tree
Showing 94 changed files with 10,056 additions and 1,180 deletions.
30 changes: 17 additions & 13 deletions Content.Client/IconSmoothing/IconSmoothSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,21 +81,25 @@ public void SetStateBase(EntityUid uid, IconSmoothComponent component, string ne

private void SetCornerLayers(SpriteComponent sprite, IconSmoothComponent component)
{
sprite.LayerMapRemove(CornerLayers.SE);
sprite.LayerMapRemove(CornerLayers.NE);
sprite.LayerMapRemove(CornerLayers.NW);
sprite.LayerMapRemove(CornerLayers.SW);

// Frontier: Allow overlays on entities using CornerLayers smoothing - don't remove layers, adjust existing ones or create new ones.
var state0 = $"{component.StateBase}0";
sprite.LayerMapSet(CornerLayers.SE, sprite.AddLayerState(state0));
sprite.LayerSetDirOffset(CornerLayers.SE, DirectionOffset.None);
sprite.LayerMapSet(CornerLayers.NE, sprite.AddLayerState(state0));
sprite.LayerSetDirOffset(CornerLayers.NE, DirectionOffset.CounterClockwise);
sprite.LayerMapSet(CornerLayers.NW, sprite.AddLayerState(state0));
sprite.LayerSetDirOffset(CornerLayers.NW, DirectionOffset.Flip);
sprite.LayerMapSet(CornerLayers.SW, sprite.AddLayerState(state0));
sprite.LayerSetDirOffset(CornerLayers.SW, DirectionOffset.Clockwise);
SetCornerLayerState(sprite, CornerLayers.SE, DirectionOffset.None, state0);
SetCornerLayerState(sprite, CornerLayers.NE, DirectionOffset.CounterClockwise, state0);
SetCornerLayerState(sprite, CornerLayers.NW, DirectionOffset.Flip, state0);
SetCornerLayerState(sprite, CornerLayers.SW, DirectionOffset.Clockwise, state0);
// End Frontier: Allow overlays on entities using CornerLayers smoothing - don't remove layers, adjust existing ones or create new ones.
}

// Frontier: set layer function to remove redundancy
private void SetCornerLayerState(SpriteComponent sprite, CornerLayers corner, DirectionOffset offset, string state)
{
if (sprite.LayerMapTryGet(corner, out var layer))
sprite.LayerSetState(layer, state);
else
sprite.LayerMapSet(corner, sprite.AddLayerState(state));
sprite.LayerSetDirOffset(corner, offset);
}
// End Frontier: set layer function to remove redundancy

private void OnShutdown(EntityUid uid, IconSmoothComponent component, ComponentShutdown args)
{
Expand Down
41 changes: 41 additions & 0 deletions Content.Client/Stack/StackCustomSplitBoundUserInterface.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Cherry-picked from space-station-14#32938 courtesy of Ilya246
using JetBrains.Annotations;
using Content.Shared.Stacks;
using Robust.Client.GameObjects;
using Robust.Client.UserInterface;

namespace Content.Client.Stack
{
[UsedImplicitly]
public sealed class StackCustomSplitBoundUserInterface : BoundUserInterface
{
private IEntityManager _entManager;
private EntityUid _owner;
[ViewVariables]
private StackCustomSplitWindow? _window;

public StackCustomSplitBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
_owner = owner;
_entManager = IoCManager.Resolve<IEntityManager>();
}

protected override void Open()
{
base.Open();
_window = this.CreateWindow<StackCustomSplitWindow>();

if (_entManager.TryGetComponent<StackComponent>(_owner, out var comp))
_window.SetMax(comp.Count);

_window.ApplyButton.OnPressed += _ =>
{
if (int.TryParse(_window.AmountLineEdit.Text, out var i))
{
SendMessage(new StackCustomSplitAmountMessage(i));
_window.Close();
}
};
}
}
}
15 changes: 15 additions & 0 deletions Content.Client/Stack/StackCustomSplitWindow.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<DefaultWindow xmlns="https://spacestation14.io"
Title="{Loc 'ui-custom-stack-split-title'}"
Resizable="False">
<!--Cherry-picked from space-station-14#32938 courtesy of Ilya246-->

<BoxContainer Orientation="Vertical" SeparationOverride="4" MinSize="240 80">
<BoxContainer Orientation="Horizontal">
<LineEdit Name="AmountLineEdit" Access="Public" HorizontalExpand="True" PlaceHolder="{Loc 'ui-custom-stack-split-line-edit-placeholder'}"/>
</BoxContainer>
<BoxContainer Orientation="Horizontal">
<Label Name="MaximumAmount" Access="Public" />
</BoxContainer>
<Button Name="ApplyButton" Access="Public" Text="{Loc 'ui-custom-stack-split-apply'}"/>
</BoxContainer>
</DefaultWindow>
35 changes: 35 additions & 0 deletions Content.Client/Stack/StackCustomSplitWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Cherry-picked from space-station-14#32938 courtesy of Ilya246
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.CustomControls;
using Robust.Client.UserInterface.XAML;

namespace Content.Client.Stack
{
[GenerateTypedNameReferences]
public sealed partial class StackCustomSplitWindow : DefaultWindow
{
private int _max = Int32.MaxValue;
private int _min = 1;

public StackCustomSplitWindow()
{
RobustXamlLoader.Load(this);
AmountLineEdit.OnTextChanged += OnValueChanged;
}

public void SetMax(int max)
{
_max = max;
MaximumAmount.Text = Loc.GetString("comp-stack-split-size", ("size", _max));
}

private void OnValueChanged(LineEdit.LineEditEventArgs args)
{
if (!int.TryParse(AmountLineEdit.Text, out var amount) || amount > _max || amount < _min)
ApplyButton.Disabled = true;
else
ApplyButton.Disabled = false;
}
}
}
4 changes: 2 additions & 2 deletions Content.IntegrationTests/PoolSettings.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#nullable enable
#nullable enable

using Robust.Shared.Random;

Expand Down Expand Up @@ -93,7 +93,7 @@ public sealed class PoolSettings
/// <summary>
/// Frontier: the preset to run the game in.
/// Set to secret for upstream tests to mimic upstream behaviour.
/// If you need to check adventure game rule things, set this to Adventure.
/// If you need to check adventure game rule things, set this to nfadventure or nfpirate.
/// </summary>
public string GameLobbyDefaultPreset { get; set; } = "secret";

Expand Down
16 changes: 16 additions & 0 deletions Content.Server/Gatherable/GatherableSystem.Projectile.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Content.Server.Gatherable.Components;
using Content.Shared.Mining.Components;
using Content.Shared.Projectiles;
using Robust.Shared.Physics.Events;

Expand All @@ -21,6 +22,21 @@ private void OnProjectileCollide(Entity<GatheringProjectileComponent> gathering,
return;
}

// Frontier: gathering changes
// bad gatherer - not strong enough
if (_whitelistSystem.IsWhitelistFail(gatherable.ToolWhitelist, gathering.Owner))
{
QueueDel(gathering);
return;
}
// Too strong (e.g. overpen) - gathers ore but destroys it
if (TryComp<OreVeinComponent>(args.OtherEntity, out var oreVein)
&& _whitelistSystem.IsWhitelistPass(oreVein.GatherDestructionWhitelist, gathering.Owner))
{
oreVein.PreventSpawning = true;
}
// End Frontier: gathering changes

Gather(args.OtherEntity, gathering, gatherable);
gathering.Comp.Amount--;

Expand Down
5 changes: 5 additions & 0 deletions Content.Server/Mining/MiningSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ private void OnDestruction(EntityUid uid, OreVeinComponent component, Destructio
if (component.CurrentOre == null)
return;

// Frontier
if (component.PreventSpawning)
return;
// End Frontier

var proto = _proto.Index<OrePrototype>(component.CurrentOre);

if (proto.OreEntity == null)
Expand Down
41 changes: 41 additions & 0 deletions Content.Server/Radio/EntitySystems/RadioDeviceSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
using Robust.Server.GameObjects; // Nuclear-14
using Robust.Shared.Prototypes;
using Content.Shared.Access.Systems; // Frontier
using Content.Shared.Verbs; //Frontier
using Robust.Shared.Utility; //Frontier

namespace Content.Server.Radio.EntitySystems;

Expand Down Expand Up @@ -51,6 +53,7 @@ public override void Initialize()
SubscribeLocalEvent<RadioMicrophoneComponent, ListenEvent>(OnListen);
SubscribeLocalEvent<RadioMicrophoneComponent, ListenAttemptEvent>(OnAttemptListen);
SubscribeLocalEvent<RadioMicrophoneComponent, PowerChangedEvent>(OnPowerChanged);
SubscribeLocalEvent<RadioMicrophoneComponent, GetVerbsEvent<AlternativeVerb>>(OnGetAltVerbs); // Frontier

SubscribeLocalEvent<RadioSpeakerComponent, ComponentInit>(OnSpeakerInit);
SubscribeLocalEvent<RadioSpeakerComponent, ActivateInWorldEvent>(OnActivateSpeaker);
Expand Down Expand Up @@ -366,6 +369,44 @@ private void UpdateHandheldRadioUi(Entity<RadioMicrophoneComponent> radio)
#endregion
// Nuclear-14-End

// Frontier Start
/// <summary>
/// Adds an alt verb allowing for the mic to be toggled easily.
/// </summary>
private void OnGetAltVerbs(EntityUid uid, RadioMicrophoneComponent microphone, GetVerbsEvent<AlternativeVerb> args)
{
if (!args.CanInteract || !args.CanAccess)
return;

AlternativeVerb verb = new()
{
Text = Loc.GetString("handheld-radio-component-toggle"),
Icon = new SpriteSpecifier.Texture(new ResPath("/Textures/Interface/VerbIcons/settings.svg.192dpi.png")),
Act = () => ToggleRadioOrIntercomMic(uid, microphone, args.User)
};
args.Verbs.Add(verb);
}

/// <summary>
/// A mic toggle for both radios and intercoms.
/// </summary>
private void ToggleRadioOrIntercomMic(EntityUid uid, RadioMicrophoneComponent microphone, EntityUid user)
{
if (!_access.IsAllowed(user, uid))
return;
if (microphone.PowerRequired && !this.IsPowered(uid, EntityManager))
return;

ToggleRadioMicrophone(uid, user, false, microphone);
if (TryComp<IntercomComponent>(uid, out var intercom))
{
intercom.MicrophoneEnabled = microphone.Enabled;
Dirty<IntercomComponent>((uid, intercom));
}
}
// Frontier End


// Frontier: init intercom with map
private void OnMapInit(EntityUid uid, IntercomComponent ent, MapInitEvent args)
{
Expand Down
1 change: 0 additions & 1 deletion Content.Server/Shipyard/Systems/ShipyardSystem.Consoles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using Content.Server.Radio.EntitySystems;
using Content.Server._NF.Bank;
using Content.Server.Shipyard.Components;
using Content.Shared._NF.GameRule;
using Content.Shared.Bank.Components;
using Content.Shared.Shipyard.Events;
using Content.Shared.Shipyard.BUI;
Expand Down
36 changes: 34 additions & 2 deletions Content.Server/Stack/StackSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ namespace Content.Server.Stack
public sealed class StackSystem : SharedStackSystem
{
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly SharedUserInterfaceSystem _ui = default!; // Cherry-picked from space-station-14#32938 courtesy of Ilya246

public static readonly int[] DefaultSplitAmounts = { 1, 5, 10, 20, 50, 100, 500, 1000, 5000, 10000 };

Expand Down Expand Up @@ -170,16 +171,33 @@ private void OnStackAlternativeInteract(EntityUid uid, StackComponent stack, Get
if (!args.CanAccess || !args.CanInteract || args.Hands == null || stack.Count == 1)
return;

// Frontier: cherry-picked from ss14#32938, moved up top
var priority = 1;
if (_ui.HasUi(uid, StackCustomSplitUiKey.Key)) // Frontier: check for interface
{
AlternativeVerb custom = new()
{
Text = Loc.GetString("comp-stack-split-custom"),
Category = VerbCategory.Split,
Act = () =>
{
_ui.OpenUi(uid, StackCustomSplitUiKey.Key, args.User);
},
Priority = priority--
};
args.Verbs.Add(custom);
}
// End Frontier: cherry-picked from ss14#32938, moved up top

AlternativeVerb halve = new()
{
Text = Loc.GetString("comp-stack-split-halve"),
Category = VerbCategory.Split,
Act = () => UserSplit(uid, args.User, stack.Count / 2, stack),
Priority = 1
Priority = priority-- // Frontier: 1<priority--
};
args.Verbs.Add(halve);

var priority = 0;
foreach (var amount in DefaultSplitAmounts)
{
if (amount >= stack.Count)
Expand All @@ -200,6 +218,20 @@ private void OnStackAlternativeInteract(EntityUid uid, StackComponent stack, Get
}
}

// Cherry-picked from ss14#32938 courtesy of Ilya246
protected override void OnCustomSplitMessage(Entity<StackComponent> ent, ref StackCustomSplitAmountMessage message)
{
var (uid, comp) = ent;

// digital ghosts shouldn't be allowed to split stacks
if (!(message.Actor is { Valid: true } user))
return;

var amount = message.Amount;
UserSplit(uid, user, amount, comp);
}
// End cherry-pick from ss14#32938 courtesy of Ilya246

private void UserSplit(EntityUid uid, EntityUid userUid, int amount,
StackComponent? stack = null,
TransformComponent? userTransform = null)
Expand Down
26 changes: 26 additions & 0 deletions Content.Server/_NF/Chemistry/RandomPillSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using Content.Shared.Chemistry.Components;
using Robust.Shared.Random;

namespace Content.Server._NF.Chemistry;

public sealed class RandomPillSystem : EntitySystem
{
[Dependency] private readonly IRobustRandom _random = default!;

public const int MaxPillType = 21;

public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<PillComponent, MapInitEvent>(OnMapInit);
}

private void OnMapInit(Entity<PillComponent> ent, ref MapInitEvent componentInit)
{
if (ent.Comp.Random)
{
ent.Comp.PillType = (uint)_random.Next(MaxPillType);
Dirty(ent);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
using Content.Shared.Procedural;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.List;

namespace Content.Server._NF.GameRule.Components;

[RegisterComponent, Access(typeof(NfAdventureRuleSystem))]
public sealed partial class AdventureRuleComponent : Component
[RegisterComponent, Access(typeof(NFAdventureRuleSystem))]
public sealed partial class NFAdventureRuleComponent : Component
{
public List<EntityUid> NFPlayerMinds = new();
public List<EntityUid> CargoDepots = new();
Expand Down
Loading

0 comments on commit e52035a

Please sign in to comment.