Skip to content

Commit

Permalink
Merge branch 'master' into floof-station-contributions
Browse files Browse the repository at this point in the history
  • Loading branch information
fenndragon authored Sep 24, 2024
2 parents 3824ed6 + 08248ff commit 8cfea29
Show file tree
Hide file tree
Showing 13 changed files with 374 additions and 75 deletions.
95 changes: 53 additions & 42 deletions Content.Client/ShortConstruction/UI/ShortConstructionMenuBUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using Robust.Client.UserInterface.Controls;
using Robust.Shared.Enums;
using Robust.Shared.Prototypes;
using Robust.Shared.Utility;

// ReSharper disable InconsistentNaming

Expand All @@ -30,7 +31,6 @@ public sealed class ShortConstructionMenuBUI : BoundUserInterface
private readonly SpriteSystem _spriteSystem;

private RadialMenu? _menu;

public ShortConstructionMenuBUI(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
_construction = _entManager.System<ConstructionSystem>();
Expand All @@ -39,8 +39,17 @@ public ShortConstructionMenuBUI(EntityUid owner, Enum uiKey) : base(owner, uiKey

protected override void Open()
{
_menu = FormMenu();
_menu.OnClose += Close;
_menu = new RadialMenu
{
HorizontalExpand = true,
VerticalExpand = true,
BackButtonStyleClass = "RadialMenuBackButton",
CloseButtonStyleClass = "RadialMenuCloseButton"
};

if (_entManager.TryGetComponent<ShortConstructionComponent>(Owner, out var crafting))
CreateMenu(crafting.Entries);

_menu.OpenCenteredAt(_inputManager.MouseScreenPosition.Position / _displayManager.ScreenSize);
}

Expand All @@ -51,56 +60,58 @@ protected override void Dispose(bool disposing)
_menu?.Dispose();
}

private RadialMenu FormMenu()
private void CreateMenu(List<ShortConstructionEntry> entries, string? parentCategory = null)
{
var menu = new RadialMenu
{
HorizontalExpand = true,
VerticalExpand = true,
BackButtonStyleClass = "RadialMenuBackButton",
CloseButtonStyleClass = "RadialMenuCloseButton"
};

if (!_entManager.TryGetComponent<ShortConstructionComponent>(Owner, out var crafting))
return menu;
if (_menu == null)
return;

var mainContainer = new RadialContainer
var container = new RadialContainer
{
Radius = 36f / MathF.Sin(MathF.PI / 2f / crafting.Prototypes.Count)
Name = parentCategory ?? "Main",
Radius = 48f + 24f * MathF.Log(entries.Count),
};

foreach (var protoId in crafting.Prototypes)
{
if (!_protoManager.TryIndex(protoId, out var proto))
continue;
_menu.AddChild(container);

var button = new RadialMenuTextureButton
foreach (var entry in entries)
{
if (entry.Category != null)
{
ToolTip = Loc.GetString(proto.Name),
StyleClasses = { "RadialMenuButton" },
SetSize = new Vector2(48f, 48f)
};

var texture = new TextureRect
var button = CreateButton(entry.Category.Name, entry.Category.Icon);
button.TargetLayer = entry.Category.Name;
CreateMenu(entry.Category.Entries, entry.Category.Name);
container.AddChild(button);
}
else if (entry.Prototype != null
&& _protoManager.TryIndex(entry.Prototype, out var proto))
{
VerticalAlignment = Control.VAlignment.Center,
HorizontalAlignment = Control.HAlignment.Center,
Texture = _spriteSystem.Frame0(proto.Icon),
TextureScale = new Vector2(1.5f, 1.5f)
};
var button = CreateButton(proto.Name, proto.Icon);
button.OnButtonUp += _ => ConstructItem(proto);
container.AddChild(button);
}
}

button.AddChild(texture);
}

button.OnButtonUp += _ =>
{
ConstructItem(proto);
};
private RadialMenuTextureButton CreateButton(string name, SpriteSpecifier icon)
{
var button = new RadialMenuTextureButton
{
ToolTip = Loc.GetString(name),
StyleClasses = { "RadialMenuButton" },
SetSize = new Vector2(64f, 64f),
};

mainContainer.AddChild(button);
}
var texture = new TextureRect
{
VerticalAlignment = Control.VAlignment.Center,
HorizontalAlignment = Control.HAlignment.Center,
Texture = _spriteSystem.Frame0(icon),
TextureScale = new Vector2(2f, 2f)
};

menu.AddChild(mainContainer);
return menu;
button.AddChild(texture);
return button;
}

/// <summary>
Expand All @@ -121,6 +132,6 @@ private void ConstructItem(ConstructionPrototype prototype)
}, new ConstructionPlacementHijack(_construction, prototype));

// Should only close the menu if we're placing a construction hijack.
_menu!.Close();
// Theres not much point to closing it though. _menu!.Close();
}
}
32 changes: 22 additions & 10 deletions Content.Server/Abilities/Psionics/Abilities/HealOtherPowerSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ private void OnPowerUsed(EntityUid uid, PsionicComponent component, PsionicHealO
else ActivatePower(uid, component, args);

if (args.PopupText is not null
&& _glimmer.Glimmer > args.GlimmerObviousPopupThreshold * component.CurrentDampening)
&& _glimmer.Glimmer > args.GlimmerPopupThreshold * component.CurrentDampening)
_popupSystem.PopupEntity(Loc.GetString(args.PopupText, ("entity", uid)), uid,
Filter.Pvs(uid).RemoveWhereAttachedEntity(entity => !_examine.InRangeUnOccluded(uid, entity, ExamineRange, null)),
true,
args.PopupType);

if (args.PlaySound
&& _glimmer.Glimmer > args.GlimmerObviousSoundThreshold * component.CurrentDampening)
&& _glimmer.Glimmer > args.GlimmerSoundThreshold * component.CurrentDampening)
_audioSystem.PlayPvs(args.SoundUse, uid, args.AudioParams);

// Sanitize the Glimmer inputs because otherwise the game will crash if someone makes MaxGlimmer lower than MinGlimmer.
Expand All @@ -76,13 +76,16 @@ private void OnPowerUsed(EntityUid uid, PsionicComponent component, PsionicHealO
private void AttemptDoAfter(EntityUid uid, PsionicComponent component, PsionicHealOtherPowerActionEvent args)
{
var ev = new PsionicHealOtherDoAfterEvent(_gameTiming.CurTime);
ev.HealingAmount = args.HealingAmount;
ev.RotReduction = args.RotReduction;
if (args.HealingAmount is not null)
ev.HealingAmount = args.HealingAmount;
if (args.RotReduction is not null)
ev.RotReduction = args.RotReduction.Value;
ev.DoRevive = args.DoRevive;
var doAfterArgs = new DoAfterArgs(EntityManager, uid, args.UseDelay, ev, uid, target: args.Target)
{
BreakOnUserMove = args.BreakOnUserMove,
BreakOnTargetMove = args.BreakOnTargetMove,
Hidden = _glimmer.Glimmer > args.GlimmerDoAfterVisibilityThreshold * component.CurrentDampening,
};

if (!_doAfterSystem.TryStartDoAfter(doAfterArgs, out var doAfterId))
Expand All @@ -104,23 +107,28 @@ private void OnDispelled(EntityUid uid, PsionicComponent component, DispelledEve
private void OnDoAfter(EntityUid uid, PsionicComponent component, PsionicHealOtherDoAfterEvent args)
{
// It's entirely possible for the caster to stop being Psionic(due to mindbreaking) mid cast
if (component is null)
if (component is null
|| args.Cancelled)
return;
component.DoAfter = null;

// The target can also cease existing mid-cast
if (args.Target is null)
return;

_rotting.ReduceAccumulator(args.Target.Value, TimeSpan.FromSeconds(args.RotReduction * component.CurrentAmplification));
if (args.RotReduction is not null)
_rotting.ReduceAccumulator(args.Target.Value, TimeSpan.FromSeconds(args.RotReduction.Value * component.CurrentAmplification));

if (!TryComp<DamageableComponent>(args.Target.Value, out var damageableComponent))
return;

_damageable.TryChangeDamage(args.Target.Value, args.HealingAmount * component.CurrentAmplification, true, false, damageableComponent, uid);
if (args.HealingAmount is not null)
_damageable.TryChangeDamage(args.Target.Value, args.HealingAmount * component.CurrentAmplification, true, false, damageableComponent, uid);

if (!args.DoRevive
|| !TryComp<MobStateComponent>(args.Target, out var mob)
|| _rotting.IsRotten(args.Target.Value)
|| !TryComp<MobStateComponent>(args.Target.Value, out var mob)
|| !_mobState.IsDead(args.Target.Value, mob)
|| !_mobThreshold.TryGetThresholdForState(args.Target.Value, MobState.Dead, out var threshold)
|| damageableComponent.TotalDamage > threshold)
return;
Expand All @@ -134,15 +142,19 @@ private void ActivatePower(EntityUid uid, PsionicComponent component, PsionicHea
if (component is null)
return;

_rotting.ReduceAccumulator(args.Target, TimeSpan.FromSeconds(args.RotReduction * component.CurrentAmplification));
if (args.RotReduction is not null)
_rotting.ReduceAccumulator(args.Target, TimeSpan.FromSeconds(args.RotReduction.Value * component.CurrentAmplification));

if (!TryComp<DamageableComponent>(args.Target, out var damageableComponent))
return;

_damageable.TryChangeDamage(args.Target, args.HealingAmount * component.CurrentAmplification, true, false, damageableComponent, uid);
if (args.HealingAmount is not null)
_damageable.TryChangeDamage(args.Target, args.HealingAmount * component.CurrentAmplification, true, false, damageableComponent, uid);

if (!args.DoRevive
|| _rotting.IsRotten(args.Target)
|| !TryComp<MobStateComponent>(args.Target, out var mob)
|| !_mobState.IsDead(args.Target, mob)
|| !_mobThreshold.TryGetThresholdForState(args.Target, MobState.Dead, out var threshold)
|| damageableComponent.TotalDamage > threshold)
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Content.Shared.Actions.Events;
public sealed partial class PsionicHealOtherPowerActionEvent : EntityTargetActionEvent
{
[DataField]
public DamageSpecifier HealingAmount = default!;
public DamageSpecifier? HealingAmount = default!;

[DataField]
public string PowerName;
Expand All @@ -19,7 +19,7 @@ public sealed partial class PsionicHealOtherPowerActionEvent : EntityTargetActio
public string? PopupText;

[DataField]
public float RotReduction;
public float? RotReduction;

[DataField]
public bool DoRevive;
Expand All @@ -40,10 +40,13 @@ public sealed partial class PsionicHealOtherPowerActionEvent : EntityTargetActio
public int MaxGlimmer = 12;

[DataField]
public int GlimmerObviousSoundThreshold;
public int GlimmerSoundThreshold;

[DataField]
public int GlimmerObviousPopupThreshold;
public int GlimmerPopupThreshold;

[DataField]
public int GlimmerDoAfterVisibilityThreshold;

[DataField]
public PopupType PopupType = PopupType.Medium;
Expand Down
4 changes: 2 additions & 2 deletions Content.Shared/Psionics/Events.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ public sealed partial class PsionicHealOtherDoAfterEvent : DoAfterEvent
public TimeSpan StartedAt;

[DataField]
public DamageSpecifier HealingAmount = default!;
public DamageSpecifier? HealingAmount = default!;

[DataField]
public float RotReduction;
public float? RotReduction;

[DataField]
public bool DoRevive;
Expand Down
26 changes: 25 additions & 1 deletion Content.Shared/ShortConstruction/ShortConstructionComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,38 @@
using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
using Robust.Shared.Utility;

namespace Content.Shared.ShortConstruction;

[RegisterComponent, NetworkedComponent]
public sealed partial class ShortConstructionComponent : Component
{
[DataField(required: true)]
public List<ProtoId<ConstructionPrototype>> Prototypes = new();
public List<ShortConstructionEntry> Entries = new();
}

[DataDefinition]
public sealed partial class ShortConstructionEntry
{
[DataField]
public ProtoId<ConstructionPrototype>? Prototype { get; set; }

[DataField]
public ShortConstructionCategory? Category { get; set; }
}

[DataDefinition]
public sealed partial class ShortConstructionCategory
{
[DataField]
public string Name { get; set; } = string.Empty;

[DataField]
public SpriteSpecifier Icon { get; set; } = default!;

[DataField]
public List<ShortConstructionEntry> Entries { get; set; } = new();
}

[NetSerializable, Serializable]
Expand Down
29 changes: 29 additions & 0 deletions Resources/Changelog/Changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6627,3 +6627,32 @@ Entries:
id: 6385
time: '2024-09-21T23:22:43.0000000+00:00'
url: https://github.com/Simple-Station/Einstein-Engines/pull/943
- author: VMSolidus
changes:
- type: Fix
message: >-
Fixed a bug where Breath of Life and Healing Word would set living
people to crit, which would knock them down.
- type: Fix
message: >-
Fixed a bug where Breath of Life could revive people who were rotten(It
will still heal them and reduce the rot timer as intended, but will not
revive unless said rot timer reduction brings them below the 10 minute
threshold).
- type: Add
message: >-
The Do-After bar for Breath of Life and Healing Word is now hidden if
glimmer is low enough. The threshold for which scales with your
Dampening stat. More Dampening = stealthier casting.
id: 6386
time: '2024-09-24T00:56:34.0000000+00:00'
url: https://github.com/Simple-Station/Einstein-Engines/pull/949
- author: Mocho
changes:
- type: Add
message: >-
Added a lot of recipes to the quick construction menus. Give it a shot
by pressing Z with different construction materials in your hand!
id: 6387
time: '2024-09-24T00:56:45.0000000+00:00'
url: https://github.com/Simple-Station/Einstein-Engines/pull/945
10 changes: 6 additions & 4 deletions Resources/Prototypes/Actions/psionics.yml
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,9 @@
playSound: true
minGlimmer: 2
maxGlimmer: 4
glimmerObviousSoundThreshold: 100
glimmerObviousPopupThreshold: 200
glimmerSoundThreshold: 100
glimmerPopupThreshold: 200
glimmerDoAfterVisibilityThreshold: 70

- type: entity
id: ActionRevivify
Expand Down Expand Up @@ -217,5 +218,6 @@
playSound: true
minGlimmer: 10 # These also get multiplied by caster stats. So,
maxGlimmer: 15 # keeping in mind the ~3.5x multiplier, this spikes glimmer by as much as 60 points.
glimmerObviousSoundThreshold: 50
glimmerObviousPopupThreshold: 100
glimmerSoundThreshold: 50
glimmerPopupThreshold: 100
glimmerDoAfterVisibilityThreshold: 35
Loading

0 comments on commit 8cfea29

Please sign in to comment.