Skip to content

Commit

Permalink
Merge branch 'new-frontiers-14:master' into NSF-Blade
Browse files Browse the repository at this point in the history
  • Loading branch information
UncaughtEx authored Jun 16, 2024
2 parents 01749d8 + 16ada9e commit aab3914
Show file tree
Hide file tree
Showing 684 changed files with 44,152 additions and 7,723 deletions.
5 changes: 1 addition & 4 deletions Content.Client/Paper/UI/PaperWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -253,10 +253,7 @@ public void Populate(SharedPaperComponent.PaperBoundUserInterfaceState state)
StampDisplay.RemoveStamps();
foreach(var stamper in state.StampedBy)
{
if (stamper.StampedBorderless)
StampDisplay.AddStamp(new StampWidget(true) { StampInfo = stamper });
else
StampDisplay.AddStamp(new StampWidget { StampInfo = stamper });
StampDisplay.AddStamp(new StampWidget { StampInfo = stamper });
}
}

Expand Down
20 changes: 2 additions & 18 deletions Content.Client/Paper/UI/StampWidget.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ public float Orientation

public StampDisplayInfo StampInfo {
set {
StampedByLabel.Text = Loc.GetString(value.StampedName);
StampedByLabel.Text = value.Type is StampType.Signature ? value.StampedName : Loc.GetString(value.StampedName);
StampedByLabel.FontColorOverride = value.StampedColor;
ModulateSelfOverride = value.StampedColor;
PanelOverride = value.Type is StampType.Signature ? null : _borderTexture;
}
}

Expand All @@ -45,23 +46,6 @@ public StampWidget()
_stampShader = prototypes.Index<ShaderPrototype>("PaperStamp").InstanceUnique();
}

public StampWidget(bool borderless)
{
RobustXamlLoader.Load(this);
var resCache = IoCManager.Resolve<IResourceCache>();
var borderImage = resCache.GetResource<TextureResource>(
"/Textures/Interface/Paper/paper_stamp_noborder.svg.96dpi.png");
_borderTexture = new StyleBoxTexture
{
Texture = borderImage,
};
_borderTexture.SetPatchMargin(StyleBoxTexture.Margin.All, 7.0f);
PanelOverride = _borderTexture;

var prototypes = IoCManager.Resolve<IPrototypeManager>();
_stampShader = prototypes.Index<ShaderPrototype>("PaperStamp").InstanceUnique();
}

protected override void Draw(DrawingHandleScreen handle)
{
_stampShader?.SetParameter("objCoord", GlobalPosition * UIScale * new Vector2(1, -1));
Expand Down
19 changes: 15 additions & 4 deletions Content.Client/Preferences/UI/LoadoutContainer.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,28 @@ public LoadoutContainer(ProtoId<LoadoutPrototype> proto, bool disabled, Formatte

if (_protoManager.TryIndex(proto, out var loadProto))
{
var ent = _entManager.System<LoadoutSystem>().GetFirstOrNull(loadProto);
// Frontier: overrideable prototype fields (description, name, icon [via entity])
Price.Text = "$" + loadProto.Price;
if (ent != null)

bool hasDescription = !string.IsNullOrEmpty(loadProto.Description);
bool hasEntity = !string.IsNullOrEmpty(loadProto.PreviewEntity?.Id);

EntProtoId? ent = null;
if (!hasEntity || !hasDescription) {
ent = _entManager.System<LoadoutSystem>().GetFirstOrNull(loadProto);
}
var finalEnt = hasEntity ? loadProto.PreviewEntity : ent;
if (finalEnt != null)
{
_entity = _entManager.SpawnEntity(ent, MapCoordinates.Nullspace);
_entity = _entManager.SpawnEntity(finalEnt, MapCoordinates.Nullspace);
Sprite.SetEntity(_entity);

var spriteTooltip = new Tooltip();
spriteTooltip.SetMessage(FormattedMessage.FromUnformatted(_entManager.GetComponent<MetaDataComponent>(_entity.Value).EntityDescription));
var description = hasDescription ? loadProto.Description : _entManager.GetComponent<MetaDataComponent>(_entity.Value).EntityDescription;
spriteTooltip.SetMessage(FormattedMessage.FromUnformatted(description));
Sprite.TooltipSupplier = _ => spriteTooltip;
}
// End Frontier
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public void RefreshLoadouts(RoleLoadout loadout, ICommonSession session, IDepend
var enabled = loadout.IsValid(session, loadoutProto, collection, out var reason);
var loadoutContainer = new LoadoutContainer(loadoutProto, !enabled, reason);
loadoutContainer.Select.Pressed = pressed;
loadoutContainer.Text = loadoutSystem.GetName(loadProto);
loadoutContainer.Text = string.IsNullOrEmpty(loadProto.Name) ? loadoutSystem.GetName(loadProto) : loadProto.Name; // Frontier: allow overriding loadout names

loadoutContainer.Select.OnPressed += args =>
{
Expand Down
21 changes: 13 additions & 8 deletions Content.Client/Stack/StackSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
namespace Content.Client.Stack
{
[UsedImplicitly]
public sealed class StackSystem : SharedStackSystem
public sealed partial class StackSystem : SharedStackSystem // Frontier: add partial to class definition
{
[Dependency] private readonly AppearanceSystem _appearanceSystem = default!;
[Dependency] private readonly ItemCounterSystem _counterSystem = default!;
Expand Down Expand Up @@ -56,20 +56,25 @@ private void OnAppearanceChange(EntityUid uid, StackComponent comp, ref Appearan
if (args.Sprite == null || comp.LayerStates.Count < 1)
return;

StackLayerData data = new StackLayerData(); // Frontier: use structure to store StackLayerData

// Skip processing if no actual
if (!_appearanceSystem.TryGetData<int>(uid, StackVisuals.Actual, out var actual, args.Component))
if (!_appearanceSystem.TryGetData<int>(uid, StackVisuals.Actual, out data.Actual, args.Component))
return;

if (!_appearanceSystem.TryGetData<int>(uid, StackVisuals.MaxCount, out var maxCount, args.Component))
maxCount = comp.LayerStates.Count;
if (!_appearanceSystem.TryGetData<int>(uid, StackVisuals.MaxCount, out data.MaxCount, args.Component))
data.MaxCount = comp.LayerStates.Count;

if (!_appearanceSystem.TryGetData<bool>(uid, StackVisuals.Hide, out data.Hidden, args.Component))
data.Hidden = false;

if (!_appearanceSystem.TryGetData<bool>(uid, StackVisuals.Hide, out var hidden, args.Component))
hidden = false;
if (comp.LayerFunction != StackLayerFunction.None) // Frontier: use stack layer function to modify appearance if provided.
ApplyLayerFunction(uid, comp, ref data); // Frontier: definition in _NF/Stack/StackSystem.Layers.cs

if (comp.IsComposite)
_counterSystem.ProcessCompositeSprite(uid, actual, maxCount, comp.LayerStates, hidden, sprite: args.Sprite);
_counterSystem.ProcessCompositeSprite(uid, data.Actual, data.MaxCount, comp.LayerStates, data.Hidden, sprite: args.Sprite);
else
_counterSystem.ProcessOpaqueSprite(uid, comp.BaseLayer, actual, maxCount, comp.LayerStates, hidden, sprite: args.Sprite);
_counterSystem.ProcessOpaqueSprite(uid, comp.BaseLayer, data.Actual, data.MaxCount, comp.LayerStates, data.Hidden, sprite: args.Sprite);
}
}
}
56 changes: 56 additions & 0 deletions Content.Client/_NF/Stack/StackSystem.Layers.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
using Content.Shared.Stacks.Components;
using Content.Shared.Stacks;

namespace Content.Client.Stack
{
/// <summary>
/// Data used to determine which layers of a stack's sprite are visible.
/// </summary>
public struct StackLayerData
{
public int Actual;
public int MaxCount;
public bool Hidden;
}

public sealed partial class StackSystem : SharedStackSystem
{
// Modifies a given stack component to adjust the layers to display.
private bool ApplyLayerFunction(EntityUid uid, StackComponent comp, ref StackLayerData data)
{
switch (comp.LayerFunction)
{
case StackLayerFunction.Threshold:
if (TryComp<StackLayerThresholdComponent>(uid, out var threshold))
{
ApplyThreshold(threshold, ref data);
return true;
}
break;
}
// No function applied.
return false;
}

/// <summary>
/// Sets Actual to the number of thresholds that Actual exceeds from the beginning of the list.
/// Sets MaxCount to the total number of thresholds plus one (for values under thresholds).
/// </summary>
private static void ApplyThreshold(StackLayerThresholdComponent comp, ref StackLayerData data)
{
// We must stop before we run out of thresholds or layers, whichever's smaller.
data.MaxCount = Math.Min(comp.Thresholds.Count + 1, data.MaxCount);
int newActual = 0;
foreach (var threshold in comp.Thresholds)
{
//If our value exceeds threshold, the next layer should be displayed.
//Note: we must ensure actual <= MaxCount.
if (data.Actual >= threshold && newActual < data.MaxCount)
newActual++;
else
break;
}
data.Actual = newActual;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,11 @@ public sealed partial class GasPressurePumpComponent : Component
[ViewVariables(VVAccess.ReadWrite)]
[DataField("maxTargetPressure")]
public float MaxTargetPressure = Atmospherics.MaxOutputPressure;

/// <summary>
/// Frontier - Start the pump with the map.
/// </summary>
[DataField]
public bool StartOnMapInit { get; set; } = false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,11 @@ public sealed partial class GasVolumePumpComponent : Component

[DataField("lastMolesTransferred")]
public float LastMolesTransferred;

/// <summary>
/// Frontier - Start the pump with the map.
/// </summary>
[DataField]
public bool StartOnMapInit { get; set; } = false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ public override void Initialize()
// Bound UI subscriptions
SubscribeLocalEvent<GasPressurePumpComponent, GasPressurePumpChangeOutputPressureMessage>(OnOutputPressureChangeMessage);
SubscribeLocalEvent<GasPressurePumpComponent, GasPressurePumpToggleStatusMessage>(OnToggleStatusMessage);

SubscribeLocalEvent<GasPressurePumpComponent, MapInitEvent>(OnMapInit); // Frontier
}

private void OnInit(EntityUid uid, GasPressurePumpComponent pump, ComponentInit args)
Expand Down Expand Up @@ -153,5 +155,17 @@ private void UpdateAppearance(EntityUid uid, GasPressurePumpComponent? pump = nu

_appearance.SetData(uid, PumpVisuals.Enabled, pump.Enabled, appearance);
}

private void OnMapInit(EntityUid uid, GasPressurePumpComponent pump, MapInitEvent args) // Frontier - Init on map
{
if (pump.StartOnMapInit)
{
pump.Enabled = true;
UpdateAppearance(uid, pump);

DirtyUI(uid, pump);
_userInterfaceSystem.CloseUi(uid, GasPressurePumpUiKey.Key);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ public override void Initialize()
SubscribeLocalEvent<GasVolumePumpComponent, GasVolumePumpToggleStatusMessage>(OnToggleStatusMessage);

SubscribeLocalEvent<GasVolumePumpComponent, DeviceNetworkPacketEvent>(OnPacketRecv);

SubscribeLocalEvent<GasVolumePumpComponent, MapInitEvent>(OnMapInit); // Frontier
}

private void OnInit(EntityUid uid, GasVolumePumpComponent pump, ComponentInit args)
Expand Down Expand Up @@ -206,5 +208,17 @@ private void OnPacketRecv(EntityUid uid, GasVolumePumpComponent component, Devic
return;
}
}

private void OnMapInit(EntityUid uid, GasVolumePumpComponent pump, MapInitEvent args) // Frontier - Init on map
{
if (pump.StartOnMapInit)
{
pump.Enabled = true;
UpdateAppearance(uid, pump);

DirtyUI(uid, pump);
_userInterfaceSystem.CloseUi(uid, GasVolumePumpUiKey.Key);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,11 @@ public sealed partial class GasMixerComponent : Component
[ViewVariables(VVAccess.ReadWrite)]
[DataField("inletTwoConcentration")]
public float InletTwoConcentration = 0.5f;

/// <summary>
/// Frontier - Start the pump with the map.
/// </summary>
[DataField]
public bool StartOnMapInit { get; set; } = false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ public override void Initialize()
SubscribeLocalEvent<GasMixerComponent, GasMixerToggleStatusMessage>(OnToggleStatusMessage);

SubscribeLocalEvent<GasMixerComponent, AtmosDeviceDisabledEvent>(OnMixerLeaveAtmosphere);

SubscribeLocalEvent<GasMixerComponent, MapInitEvent>(OnMapInit); // Frontier
}

private void OnInit(EntityUid uid, GasMixerComponent mixer, ComponentInit args)
Expand Down Expand Up @@ -232,5 +234,17 @@ private void OnMixerAnalyzed(EntityUid uid, GasMixerComponent component, GasAnal

args.DeviceFlipped = inletOne != null && inletTwo != null && inletOne.CurrentPipeDirection.ToDirection() == inletTwo.CurrentPipeDirection.ToDirection().GetClockwise90Degrees();
}

private void OnMapInit(EntityUid uid, GasMixerComponent mixer, MapInitEvent args) // Frontier - Init on map
{
if (mixer.StartOnMapInit)
{
mixer.Enabled = true;
DirtyUI(uid, mixer);

UpdateAppearance(uid, mixer);
_userInterfaceSystem.CloseUi(uid, GasFilterUiKey.Key);
}
}
}
}
38 changes: 35 additions & 3 deletions Content.Server/Bible/BibleSystem.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
using Content.Server.Bible.Components;
using Content.Server.Chemistry.EntitySystems;
using Content.Server.Ghost.Roles.Components;
using Content.Server.Ghost.Roles.Events;
using Content.Server.Popups;
using Content.Shared.ActionBlocker;
using Content.Shared.Actions;
using Content.Shared.Bible;
using Content.Shared.Chemistry.Components;
using Content.Shared.Chemistry.Reaction;
using Content.Shared.Damage;
using Content.Shared.IdentityManagement;
using Content.Shared.Interaction;
Expand Down Expand Up @@ -38,7 +41,8 @@ public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<BibleComponent, AfterInteractEvent>(OnAfterInteract);
SubscribeLocalEvent<BibleComponent, MixingAttemptEvent>(OnMixingAttempt); // Frontier: restrict solution blessing to bible users
SubscribeLocalEvent<BibleComponent, AfterInteractEvent>(OnAfterInteract, before: [typeof(ReactionMixerSystem)]); // Frontier: add before parameter
SubscribeLocalEvent<SummonableComponent, GetVerbsEvent<AlternativeVerb>>(AddSummonVerb);
SubscribeLocalEvent<SummonableComponent, GetItemActionsEvent>(GetSummonAction);
SubscribeLocalEvent<SummonableComponent, SummonActionEvent>(OnSummon);
Expand Down Expand Up @@ -91,6 +95,19 @@ public override void Update(float frameTime)
}
}

// Frontier: only bible users can bless water/blood
private void OnMixingAttempt(EntityUid uid, BibleComponent component, ref MixingAttemptEvent args)
{
// Block water/blood blessing attempts by non-bible users
if (component.BlockMix)
{
_popupSystem.PopupEntity(Loc.GetString("bible-bless-solution-failed"), component.LastInteractingUser, component.LastInteractingUser, PopupType.Small);
args.Cancelled = true;
return;
}
}
// End Frontier

private void OnAfterInteract(EntityUid uid, BibleComponent component, AfterInteractEvent args)
{
if (!args.CanReach)
Expand All @@ -99,12 +116,24 @@ private void OnAfterInteract(EntityUid uid, BibleComponent component, AfterInter
if (!TryComp(uid, out UseDelayComponent? useDelay) || _delay.IsDelayed((uid, useDelay)))
return;

if (args.Target == null || args.Target == args.User || !_mobStateSystem.IsAlive(args.Target.Value))
// Frontier: only bible users can bless water/blood
if (args.Target == null)
{
return;
}

if (!HasComp<BibleUserComponent>(args.User))
// In case the user is trying to mix something, store who's using it and whether or not they're a bible user.
component.LastInteractingUser = args.User;
var hasBibleUserComponent = HasComp<BibleUserComponent>(args.User);
component.BlockMix = !hasBibleUserComponent;

if (args.Target == args.User || !_mobStateSystem.IsAlive(args.Target.Value))
{
return;
}
// End Frontier

if (!hasBibleUserComponent) // Frontier: cache bible component lookup
{
_popupSystem.PopupEntity(Loc.GetString("bible-sizzle"), args.User, args.User);

Expand Down Expand Up @@ -226,7 +255,10 @@ private void AttemptSummon(Entity<SummonableComponent> ent, EntityUid user, Tran
if (component.AlreadySummoned || component.SpecialItemPrototype == null)
return;
if (component.RequiresBibleUser && !HasComp<BibleUserComponent>(user))
{
_popupSystem.PopupEntity(Loc.GetString("bible-summon-request-failed"), user, user, PopupType.Small); // Frontier: better summon feedback
return;
}
if (!Resolve(user, ref position))
return;
if (component.Deleted || Deleted(uid))
Expand Down
Loading

0 comments on commit aab3914

Please sign in to comment.