Skip to content

Commit

Permalink
Merge branch 'master' into NF-Dispatch-2
Browse files Browse the repository at this point in the history
  • Loading branch information
dustylens authored Jan 20, 2025
2 parents d25ad52 + 80c1f3f commit 08dac79
Show file tree
Hide file tree
Showing 31 changed files with 1,674 additions and 1,138 deletions.
2 changes: 2 additions & 0 deletions Content.Server/Chemistry/EntitySystems/ChemMasterSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public sealed class ChemMasterSystem : EntitySystem
{
[Dependency] private readonly PopupSystem _popupSystem = default!;
[Dependency] private readonly AudioSystem _audioSystem = default!;
[Dependency] private readonly SharedAppearanceSystem _appearanceSystem = default!; // Frontier
[Dependency] private readonly SharedSolutionContainerSystem _solutionContainerSystem = default!;
[Dependency] private readonly ItemSlotsSystem _itemSlotsSystem = default!;
[Dependency] private readonly UserInterfaceSystem _userInterfaceSystem = default!;
Expand Down Expand Up @@ -70,6 +71,7 @@ private void UpdateUiState(Entity<ChemMasterComponent> ent, bool updateLabel = f
if (!_solutionContainerSystem.TryGetSolution(owner, SharedChemMaster.BufferSolutionName, out _, out var bufferSolution))
return;
var inputContainer = _itemSlotsSystem.GetItemOrNull(owner, SharedChemMaster.InputSlotName);
_appearanceSystem.SetData(owner, ChemMasterVisualState.BeakerInserted, inputContainer.HasValue); // Frontier
var outputContainer = _itemSlotsSystem.GetItemOrNull(owner, SharedChemMaster.OutputSlotName);

var bufferReagents = bufferSolution.Contents;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,9 @@ public sealed partial class AddAccentClothingComponent : Component
/// Is that clothing is worn and affecting someones accent?
/// </summary>
public bool IsActive = false;

/// <summary>
/// Who is currently wearing the item?
/// </summary>
public EntityUid Wearer; // Frontier
}
52 changes: 52 additions & 0 deletions Content.Server/Speech/EntitySystems/AddAccentClothingSystem.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Content.Server.Speech.Components;
using Content.Shared.Clothing;
using Content.Shared.Verbs; // Frontier

namespace Content.Server.Speech.EntitySystems;

Expand All @@ -12,6 +13,7 @@ public override void Initialize()
base.Initialize();
SubscribeLocalEvent<AddAccentClothingComponent, ClothingGotEquippedEvent>(OnGotEquipped);
SubscribeLocalEvent<AddAccentClothingComponent, ClothingGotUnequippedEvent>(OnGotUnequipped);
SubscribeLocalEvent<AddAccentClothingComponent, GetVerbsEvent<AlternativeVerb>>(OnGetAltVerbs); // Frontier
}

private void OnGotEquipped(EntityUid uid, AddAccentClothingComponent component, ref ClothingGotEquippedEvent args)
Expand All @@ -30,10 +32,12 @@ private void OnGotEquipped(EntityUid uid, AddAccentClothingComponent component,
rep.Accent = component.ReplacementPrototype!;

component.IsActive = true;
component.Wearer = args.Wearer; // Frontier
}

private void OnGotUnequipped(EntityUid uid, AddAccentClothingComponent component, ref ClothingGotUnequippedEvent args)
{
component.Wearer = EntityUid.Invalid; // Frontier: prevent alt verb
if (!component.IsActive)
return;

Expand All @@ -46,4 +50,52 @@ private void OnGotUnequipped(EntityUid uid, AddAccentClothingComponent component

component.IsActive = false;
}

// Frontier: togglable accents
/// <summary>
/// Adds an alt verb allowing for the accent to be toggled easily.
/// </summary>
private void OnGetAltVerbs(EntityUid uid, AddAccentClothingComponent component, GetVerbsEvent<AlternativeVerb> args)
{
if (!args.CanInteract || args.User != component.Wearer) //only the wearer can toggle the effect
return;

AlternativeVerb verb = new()
{
Text = Loc.GetString("accent-clothing-component-toggle"),
Act = () => ToggleAccent(uid, component)
};
args.Verbs.Add(verb);
}

private void ToggleAccent(EntityUid uid, AddAccentClothingComponent component)
{
if (component.IsActive)
{
// try to remove the accent if it's enabled
var componentType = _componentFactory.GetRegistration(component.Accent).Type;
RemComp(component.Wearer, componentType);
component.IsActive = false;
// we don't wipe out wearer in this case
}
else
{
// try to add the accent as if we are equipping this item again
// does the user already has this accent?
var componentType = _componentFactory.GetRegistration(component.Accent).Type;
if (HasComp(component.Wearer, componentType))
return;

// add accent to the user
var accentComponent = (Component)_componentFactory.GetComponent(componentType);
AddComp(component.Wearer, accentComponent);

// snowflake case for replacement accent
if (accentComponent is ReplacementAccentComponent rep)
rep.Accent = component.ReplacementPrototype!;

component.IsActive = true;
}
}
// End Frontier: togglable accents
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace Content.Server._NF.Speech.Components;

/// <summary>
/// Applies accent to user while they wear entity as a clothing.
/// Applies accent to user while they hold the entity.
/// </summary>
[RegisterComponent]
public sealed partial class AddAccentPickupComponent : Component
Expand All @@ -23,7 +23,12 @@ public sealed partial class AddAccentPickupComponent : Component
public string? ReplacementPrototype;

/// <summary>
/// Is that clothing is worn and affecting someones accent?
/// Is the entity held and affecting someones accent?
/// </summary>
public bool IsActive = false;

/// <summary>
/// Who is currently holding the item?
/// </summary>
public EntityUid Holder; // Frontier
}
60 changes: 53 additions & 7 deletions Content.Server/_NF/Speech/EntitySystems/AddAccentPickupSystem.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
using Content.Server._NF.Speech.Components;
using Content.Server.Speech.Components;
using Content.Shared.Interaction.Events;
using Content.Shared.Item;
using Content.Shared._NF.Item;
using Content.Shared.Verbs;

namespace Content.Server._NF.Speech.EntitySystems;

Expand All @@ -12,40 +13,85 @@ public sealed class AddAccentPickupSystem : EntitySystem
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<AddAccentPickupComponent, GettingPickedUpAttemptEvent>(OnPickup);
SubscribeLocalEvent<AddAccentPickupComponent, PickedUpEvent>(OnPickup);
SubscribeLocalEvent<AddAccentPickupComponent, DroppedEvent>(OnDropped);
SubscribeLocalEvent<AddAccentPickupComponent, GetVerbsEvent<AlternativeVerb>>(OnGetAltVerbs);
}

private void OnPickup(EntityUid uid, AddAccentPickupComponent component, ref GettingPickedUpAttemptEvent args)
private void OnPickup(EntityUid uid, AddAccentPickupComponent component, ref PickedUpEvent args)
{
// does the user already has this accent?
var componentType = _componentFactory.GetRegistration(component.Accent).Type;
if (HasComp(args.User, componentType))
return;

// add accent to the user
var accentComponent = (Component) _componentFactory.GetComponent(componentType);
var accentComponent = (Component)_componentFactory.GetComponent(componentType);
AddComp(args.User, accentComponent);

// snowflake case for replacement accent
if (accentComponent is ReplacementAccentComponent rep)
rep.Accent = component.ReplacementPrototype!;

component.IsActive = true;
component.Holder = args.User;
}

private void OnDropped(EntityUid uid, AddAccentPickupComponent component, DroppedEvent args)
{
component.Holder = EntityUid.Invalid; // prevent alt verb
if (!component.IsActive)
return;

// try to remove accent
var componentType = _componentFactory.GetRegistration(component.Accent).Type;
if (EntityManager.HasComponent(args.User, componentType))
RemComp(args.User, componentType);

component.IsActive = false;
}

/// <summary>
/// Adds an alt verb allowing for the accent to be toggled easily.
/// </summary>
private void OnGetAltVerbs(EntityUid uid, AddAccentPickupComponent component, GetVerbsEvent<AlternativeVerb> args)
{
if (!args.CanInteract || args.User != component.Holder) //only the holder can toggle the effect
return;

AlternativeVerb verb = new()
{
EntityManager.RemoveComponent(args.User, componentType);
Text = Loc.GetString("accent-clothing-component-toggle"),
Act = () => ToggleAccent(uid, component)
};
args.Verbs.Add(verb);
}

private void ToggleAccent(EntityUid uid, AddAccentPickupComponent component)
{
var componentType = _componentFactory.GetRegistration(component.Accent).Type;
if (component.IsActive)
{
// try to remove the accent if it's enabled
RemComp(component.Holder, componentType);
component.IsActive = false;
// we don't wipe out Holder in this case
}
else
{
// try to add the accent as if we are equipping this item again
// does the user already has this accent?
if (HasComp(component.Holder, componentType))
return;

component.IsActive = false;
// add accent to the user
var accentComponent = (Component)_componentFactory.GetComponent(componentType);
AddComp(component.Holder, accentComponent);

// snowflake case for replacement accent
if (accentComponent is ReplacementAccentComponent rep)
rep.Accent = component.ReplacementPrototype!;

component.IsActive = true;
}
}
}
6 changes: 6 additions & 0 deletions Content.Shared/Chemistry/SharedChemMaster.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ public ChemMasterSetPillTypeMessage(uint pillType)
}
}

[Serializable, NetSerializable]
public enum ChemMasterVisualState : byte // Frontier
{
BeakerInserted
}

[Serializable, NetSerializable]
public sealed class ChemMasterReagentAmountButtonMessage : BoundUserInterfaceMessage
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Content.Shared._NF.LoggingExtensions; // Frontier
using Content.Shared._NF.Item; // Frontier
using Content.Shared.Clothing.Components;
using Content.Shared.Database;
using Content.Shared.Hands.Components;
Expand Down Expand Up @@ -235,6 +236,7 @@ public virtual void DoPickup(EntityUid uid, Hand hand, EntityUid entity, HandsCo
Log.Error($"Failed to insert {ToPrettyString(entity)} into users hand container when picking up. User: {ToPrettyString(uid)}. Hand: {hand.Name}.");
return;
}
RaiseLocalEvent(entity, new PickedUpEvent(uid, entity), false); // Frontier

if (log)
{
Expand Down
9 changes: 9 additions & 0 deletions Content.Shared/Storage/EntitySystems/MagnetPickupSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,15 @@ public override void Update(float frameTime)
if (_whitelistSystem.IsWhitelistFail(storage.Whitelist, near))
continue;

// FRONTIER - START
// Makes sure that after the last insertion, there is still bag space.
// Using a cheap 'how many slots left' vs 'how many we need' check, and additional stack check.
// Note: Unfortunately, this is still 'expensive' as it checks the entire bag, however its better than
// to rotate an item n^n times of every item in the bag to find the best fit, for every xy coordinate it has.
if (!_storage.HasSlotSpaceFor(uid, near))
continue;
// FRONTIER - END

if (!_physicsQuery.TryGetComponent(near, out var physics) || physics.BodyStatus != BodyStatus.OnGround)
continue;

Expand Down
16 changes: 16 additions & 0 deletions Content.Shared/Storage/EntitySystems/SharedStorageSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1289,6 +1289,22 @@ public bool HasSpace(Entity<StorageComponent?> uid)
return GetCumulativeItemAreas(uid) < uid.Comp.Grid.GetArea() || HasSpaceInStacks(uid);
}

/// FRONTIER
/// <summary>
/// Returns true if there is enough space to fit an item based on slot counts and item stack size.
/// </summary>
public bool HasSlotSpaceFor(Entity<StorageComponent?> uid, Entity<ItemComponent?> itemEnt)
{
if (!Resolve(uid, ref uid.Comp) || !Resolve(itemEnt, ref itemEnt.Comp))
return false;

// If the amount of spaces that's left in the bag is less than the size of the item, return false.
var itemSpacesNeeded = ItemSystem.GetItemShape((itemEnt, itemEnt.Comp)).GetArea();
var availableSpaces = uid.Comp.Grid.GetArea() - GetCumulativeItemAreas(uid);

return availableSpaces >= itemSpacesNeeded || HasSpaceInStacks(uid);
}

private bool HasSpaceInStacks(Entity<StorageComponent?> uid, string? stackType = null)
{
if (!Resolve(uid, ref uid.Comp))
Expand Down
16 changes: 16 additions & 0 deletions Content.Shared/_NF/Item/PickupEvent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
namespace Content.Shared._NF.Item;

/// <summary>
/// Raised directed at entity being picked after someone picks it up sucessfully.
/// </summary>
public sealed class PickedUpEvent : EntityEventArgs
{
public readonly EntityUid User;
public readonly EntityUid Item;

public PickedUpEvent(EntityUid user, EntityUid item)
{
User = user;
Item = item;
}
}
58 changes: 58 additions & 0 deletions Resources/Changelog/Frontier.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6490,3 +6490,61 @@ Entries:
message: Emergency lights should properly turn off when resetting to green state.
id: 5669
time: '2025-01-19T11:42:46.0000000+00:00'
- author: Alkheemist
changes:
- type: Tweak
message: >-
Clothing and items that apply accents can be toggled with alt click, so
you can dress in style without worrying about intelligibility.
id: 5670
time: '2025-01-19T16:12:47.0000000+00:00'
- author: dvir001
changes:
- type: Tweak
message: Planets gas mixes are more stable and safe.
id: 5671
time: '2025-01-19T21:42:31.0000000+00:00'
- author: Temoffy
changes:
- type: Fix
message: Chemmaster now uses a new sprite when beaker inserted!
id: 5672
time: '2025-01-19T22:47:36.0000000+00:00'
- author: whatston3
changes:
- type: Fix
message: Mercenary web vests no longer trigger the CDET.
id: 5673
time: '2025-01-20T09:18:11.0000000+00:00'
- author: arimah
changes:
- type: Tweak
message: >-
Scrap circuitry has been renamed to fried circuitry. Put it in the
material reclaimer, not the scrap processor!
id: 5674
time: '2025-01-20T12:50:20.0000000+00:00'
- author: MagnusCrowe
changes:
- type: Add
message: Added morgue and crematorium back to the NFSD outpost.
- type: Add
message: Added an ATM and sell only shipyard to NFSD outpost brig.
- type: Fix
message: Medical locked NFSD medbay.
- type: Fix
message: Gave brigmedic medical and chemistry access.
id: 5675
time: '2025-01-20T14:22:00.0000000+00:00'
- author: whatston3
changes:
- type: Add
message: Added a "None" antenna option for Moths.
id: 5676
time: '2025-01-20T15:12:17.0000000+00:00'
- author: whatston3
changes:
- type: Add
message: Gas deposit locators are now printable in the engineering techfab.
id: 5677
time: '2025-01-20T17:34:44.0000000+00:00'
5 changes: 4 additions & 1 deletion Resources/Locale/en-US/_NF/accent/accents.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,7 @@ accent-words-fox-2 = Yap!
accent-words-fox-3 = Ruff!
accent-words-fox-4 = Wraaah!
accent-words-fox-5 = Aaaaagh!
accent-words-fox-6 = Screeee!
accent-words-fox-6 = Screeee!
# Accent Toggle
accent-clothing-component-toggle = Toggle Accent
1 change: 1 addition & 0 deletions Resources/Locale/en-US/_NF/markings/moth_markings.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
marking-MothAntennasNone = None
Loading

0 comments on commit 08dac79

Please sign in to comment.