Skip to content

Commit

Permalink
Merge pull request impstation#345 from formlessnameless/dev
Browse files Browse the repository at this point in the history
Upstream merge
  • Loading branch information
formlessnameless authored Sep 25, 2024
2 parents 8518f49 + aa86ead commit dbbb088
Show file tree
Hide file tree
Showing 16 changed files with 192 additions and 62 deletions.
27 changes: 27 additions & 0 deletions Content.Client/Actions/ActionsSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,29 @@ public override void Initialize()
SubscribeLocalEvent<EntityWorldTargetActionComponent, ComponentHandleState>(OnEntityWorldTargetHandleState);
}

public override void FrameUpdate(float frameTime)
{
base.FrameUpdate(frameTime);

var worldActionQuery = EntityQueryEnumerator<WorldTargetActionComponent>();
while (worldActionQuery.MoveNext(out var uid, out var action))
{
UpdateAction(uid, action);
}

var instantActionQuery = EntityQueryEnumerator<InstantActionComponent>();
while (instantActionQuery.MoveNext(out var uid, out var action))
{
UpdateAction(uid, action);
}

var entityActionQuery = EntityQueryEnumerator<EntityTargetActionComponent>();
while (entityActionQuery.MoveNext(out var uid, out var action))
{
UpdateAction(uid, action);
}
}

private void OnInstantHandleState(EntityUid uid, InstantActionComponent component, ref ComponentHandleState args)
{
if (args.Current is not InstantActionComponentState state)
Expand Down Expand Up @@ -95,6 +118,8 @@ private void BaseHandleState<T>(EntityUid uid, BaseActionComponent component, Ba
component.Icon = state.Icon;
component.IconOn = state.IconOn;
component.IconColor = state.IconColor;
component.OriginalIconColor = state.OriginalIconColor;
component.DisabledIconColor = state.DisabledIconColor;
component.Keywords.Clear();
component.Keywords.UnionWith(state.Keywords);
component.Enabled = state.Enabled;
Expand Down Expand Up @@ -125,6 +150,8 @@ public override void UpdateAction(EntityUid? actionId, BaseActionComponent? acti
if (!ResolveActionData(actionId, ref action))
return;

action.IconColor = action.Charges < 1 ? action.DisabledIconColor : action.OriginalIconColor;

base.UpdateAction(actionId, action);
if (_playerManager.LocalEntity != action.AttachedEntity)
return;
Expand Down
2 changes: 1 addition & 1 deletion Content.Server/Access/Systems/AgentIDCardSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public override void Initialize()

private void OnAfterInteract(EntityUid uid, AgentIDCardComponent component, AfterInteractEvent args)
{
if (!TryComp<AccessComponent>(args.Target, out var targetAccess) || !HasComp<IdCardComponent>(args.Target) || args.Target == null)
if (args.Target == null || !args.CanReach || !TryComp<AccessComponent>(args.Target, out var targetAccess) || !HasComp<IdCardComponent>(args.Target))
return;

if (!TryComp<AccessComponent>(uid, out var access) || !HasComp<IdCardComponent>(uid))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,20 @@ namespace Content.Server.VendingMachines;
[DataDefinition]
public sealed partial class VendingMachineContrabandWireAction : BaseToggleWireAction
{
private VendingMachineSystem _vendingMachineSystem = default!;

public override Color Color { get; set; } = Color.Green;
public override string Name { get; set; } = "wire-name-vending-contraband";
public override object? StatusKey { get; } = ContrabandWireKey.StatusKey;
public override object? TimeoutKey { get; } = ContrabandWireKey.TimeoutKey;

public override void Initialize()
{
base.Initialize();

_vendingMachineSystem = EntityManager.System<VendingMachineSystem>();
}

public override StatusLightState? GetLightState(Wire wire)
{
if (EntityManager.TryGetComponent(wire.Owner, out VendingMachineComponent? vending))
Expand All @@ -28,7 +37,7 @@ public override void ToggleValue(EntityUid owner, bool setting)
{
if (EntityManager.TryGetComponent(owner, out VendingMachineComponent? vending))
{
vending.Contraband = !setting;
_vendingMachineSystem.SetContraband(owner, !vending.Contraband, vending);
}
}

Expand Down
12 changes: 12 additions & 0 deletions Content.Server/VendingMachines/VendingMachineSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,18 @@ public void SetShooting(EntityUid uid, bool canShoot, VendingMachineComponent? c
component.CanShoot = canShoot;
}

/// <summary>
/// Sets the <see cref="VendingMachineComponent.Contraband"/> property of the vending machine.
/// </summary>
public void SetContraband(EntityUid uid, bool contraband, VendingMachineComponent? component = null)
{
if (!Resolve(uid, ref component))
return;

component.Contraband = contraband;
Dirty(uid, component);
}

public void Deny(EntityUid uid, VendingMachineComponent? vendComponent = null)
{
if (!Resolve(uid, ref vendComponent))
Expand Down
14 changes: 14 additions & 0 deletions Content.Shared/Actions/BaseActionComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,16 @@ public abstract partial class BaseActionComponent : Component
/// </remarks>
[DataField("iconColor")] public Color IconColor = Color.White;

/// <summary>
/// The original <see cref="IconColor"/> this action was.
/// </summary>
[DataField] public Color OriginalIconColor;

/// <summary>
/// The color the action should turn to when disabled
/// </summary>
[DataField] public Color DisabledIconColor = Color.DimGray;

/// <summary>
/// Keywords that can be used to search for this action in the action menu.
/// </summary>
Expand Down Expand Up @@ -179,6 +189,8 @@ public abstract class BaseActionComponentState : ComponentState
public SpriteSpecifier? Icon;
public SpriteSpecifier? IconOn;
public Color IconColor;
public Color OriginalIconColor;
public Color DisabledIconColor;
public HashSet<string> Keywords;
public bool Enabled;
public bool Toggled;
Expand Down Expand Up @@ -209,6 +221,8 @@ protected BaseActionComponentState(BaseActionComponent component, IEntityManager
Icon = component.Icon;
IconOn = component.IconOn;
IconColor = component.IconColor;
OriginalIconColor = component.OriginalIconColor;
DisabledIconColor = component.DisabledIconColor;
Keywords = component.Keywords;
Enabled = component.Enabled;
Toggled = component.Toggled;
Expand Down
64 changes: 58 additions & 6 deletions Content.Shared/Actions/SharedActionsSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,42 @@ public override void Initialize()
SubscribeAllEvent<RequestPerformActionEvent>(OnActionRequest);
}

public override void Update(float frameTime)
{
base.Update(frameTime);

var worldActionQuery = EntityQueryEnumerator<WorldTargetActionComponent>();
while (worldActionQuery.MoveNext(out var uid, out var action))
{
if (IsCooldownActive(action) || !ShouldResetCharges(action))
continue;

ResetCharges(uid, dirty: true);
}

var instantActionQuery = EntityQueryEnumerator<InstantActionComponent>();
while (instantActionQuery.MoveNext(out var uid, out var action))
{
if (IsCooldownActive(action) || !ShouldResetCharges(action))
continue;

ResetCharges(uid, dirty: true);
}

var entityActionQuery = EntityQueryEnumerator<EntityTargetActionComponent>();
while (entityActionQuery.MoveNext(out var uid, out var action))
{
if (IsCooldownActive(action) || !ShouldResetCharges(action))
continue;

ResetCharges(uid, dirty: true);
}
}

private void OnActionMapInit(EntityUid uid, BaseActionComponent component, MapInitEvent args)
{
component.OriginalIconColor = component.IconColor;

if (component.Charges == null)
return;

Expand Down Expand Up @@ -326,14 +360,18 @@ public void RemoveCharges(EntityUid? actionId, int? removeCharges)
Dirty(actionId.Value, action);
}

public void ResetCharges(EntityUid? actionId)
public void ResetCharges(EntityUid? actionId, bool update = false, bool dirty = false)
{
if (!TryGetActionData(actionId, out var action))
return;

action.Charges = action.MaxCharges;
UpdateAction(actionId, action);
Dirty(actionId.Value, action);

if (update)
UpdateAction(actionId, action);

if (dirty)
Dirty(actionId.Value, action);
}

private void OnActionsGetState(EntityUid uid, ActionsComponent component, ref ComponentGetState args)
Expand Down Expand Up @@ -386,13 +424,12 @@ private void OnActionRequest(RequestPerformActionEvent ev, EntitySessionEventArg
return;

var curTime = GameTiming.CurTime;
// TODO: Check for charge recovery timer
if (action.Cooldown.HasValue && action.Cooldown.Value.End > curTime)
if (IsCooldownActive(action, curTime))
return;

// TODO: Replace with individual charge recovery when we have the visuals to aid it
if (action is { Charges: < 1, RenewCharges: true })
ResetCharges(actionEnt);
ResetCharges(actionEnt, true, true);

BaseActionEvent? performEvent = null;

Expand Down Expand Up @@ -1072,4 +1109,19 @@ public void SetEntityIcon(EntityUid uid, EntityUid? icon, BaseActionComponent? a
action.EntityIcon = icon;
Dirty(uid, action);
}

/// <summary>
/// Checks if the action has a cooldown and if it's still active
/// </summary>
protected bool IsCooldownActive(BaseActionComponent action, TimeSpan? curTime = null)
{
curTime ??= GameTiming.CurTime;
// TODO: Check for charge recovery timer
return action.Cooldown.HasValue && action.Cooldown.Value.End > curTime;
}

protected bool ShouldResetCharges(BaseActionComponent action)
{
return action is { Charges: < 1, RenewCharges: true };
}
}
1 change: 1 addition & 0 deletions Content.Shared/VendingMachines/VendingMachineComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public sealed partial class VendingMachineComponent : Component
[DataField, AutoNetworkedField]
public Dictionary<string, VendingMachineInventoryEntry> ContrabandInventory = new();

[DataField, AutoNetworkedField]
public bool Contraband;

public bool Ejecting;
Expand Down
73 changes: 36 additions & 37 deletions Resources/Changelog/Changelog.yml
Original file line number Diff line number Diff line change
@@ -1,41 +1,4 @@
Entries:
- author: deepdarkdepths
changes:
- message: Removed the description about geras in the Slime guidebook section.
type: Remove
id: 6935
time: '2024-07-19T09:04:43.0000000+00:00'
url: https://github.com/space-wizards/space-station-14/pull/30140
- author: Blackern5000
changes:
- message: Nuclear operatives are now able to purchase durable armor which is NOT
space-proof.
type: Add
id: 6936
time: '2024-07-19T09:38:26.0000000+00:00'
url: https://github.com/space-wizards/space-station-14/pull/29845
- author: Plykiya, slarticodefast
changes:
- message: Explosive pens now correctly embed into their target.
type: Fix
id: 6937
time: '2024-07-19T09:42:58.0000000+00:00'
url: https://github.com/space-wizards/space-station-14/pull/30112
- author: ThatOneEnby1337
changes:
- message: News Reporters are now able to use markup tags in their reports without
bricking the PDAs of readers
type: Fix
id: 6938
time: '2024-07-19T14:18:39.0000000+00:00'
url: https://github.com/space-wizards/space-station-14/pull/30169
- author: themias
changes:
- message: Mailing units are functional again
type: Fix
id: 6939
time: '2024-07-20T02:31:26.0000000+00:00'
url: https://github.com/space-wizards/space-station-14/pull/30174
- author: Ghagliiarghii
changes:
- message: Nuclear Operatives' Reinforcements now have a PDA!
Expand Down Expand Up @@ -3928,3 +3891,39 @@
id: 7434
time: '2024-09-24T21:58:46.0000000+00:00'
url: https://github.com/space-wizards/space-station-14/pull/32343
- author: goet
changes:
- message: Vending machines can be hacked again.
type: Fix
id: 7435
time: '2024-09-25T05:21:24.0000000+00:00'
url: https://github.com/space-wizards/space-station-14/pull/32431
- author: themias
changes:
- message: Agent ID card can now only copy access within interaction range.
type: Fix
id: 7436
time: '2024-09-25T15:41:34.0000000+00:00'
url: https://github.com/space-wizards/space-station-14/pull/32445
- author: Myra
changes:
- message: Silicon with no laws will not have binary channel access.
type: Remove
id: 7437
time: '2024-09-25T16:49:43.0000000+00:00'
url: https://github.com/space-wizards/space-station-14/pull/32385
- author: august-sun
changes:
- message: Rolling pins are now craftable.
type: Tweak
id: 7438
time: '2024-09-25T17:27:30.0000000+00:00'
url: https://github.com/space-wizards/space-station-14/pull/32285
- author: BramvanZijp
changes:
- message: Fixed an issue that caused Doctors Delight to metabolize twice the normal
speed, which also halved its effectiveness.
type: Fix
id: 7439
time: '2024-09-25T17:39:49.0000000+00:00'
url: https://github.com/space-wizards/space-station-14/pull/32297
5 changes: 0 additions & 5 deletions Resources/Prototypes/Entities/Mobs/NPCs/silicon.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,8 @@
factions:
- SimpleNeutral
- type: IntrinsicRadioReceiver
- type: IntrinsicRadioTransmitter
channels:
- Binary
- type: ActiveRadio
channels:
- Binary
- Common
- type: HealthExaminable
examinableTypes:
Expand Down Expand Up @@ -418,6 +414,5 @@
- Bot
- type: ActiveRadio
channels:
- Binary
- Common
- Supply
4 changes: 0 additions & 4 deletions Resources/Prototypes/Entities/Objects/Fun/pai.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,8 @@
stopSearchVerbPopup: pai-system-stopped-searching
- type: Examiner
- type: IntrinsicRadioReceiver
- type: IntrinsicRadioTransmitter
channels:
- Binary
- type: ActiveRadio
channels:
- Binary
- Common
- type: DoAfter
- type: Actions
Expand Down
3 changes: 3 additions & 0 deletions Resources/Prototypes/Entities/Objects/Tools/tools.yml
Original file line number Diff line number Diff line change
Expand Up @@ -514,3 +514,6 @@
- type: Tag
tags:
- RollingPin
- type: Construction
graph: WoodenRollingPin
node: rollingpin
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,8 @@
speechVerb: Robotic
speechSounds: Vending
- type: IntrinsicRadioReceiver
- type: IntrinsicRadioTransmitter
channels:
- Binary
- type: ActiveRadio
channels:
- Binary
- Common
- type: DoAfter
- type: Electrified
Expand Down
2 changes: 0 additions & 2 deletions Resources/Prototypes/Reagents/Consumable/Drink/alcohol.yml
Original file line number Diff line number Diff line change
Expand Up @@ -875,8 +875,6 @@
- !type:AdjustReagent
reagent: Ethanol
amount: 0.05
Medicine:
effects:
- !type:HealthChange
damage:
groups:
Expand Down
Loading

0 comments on commit dbbb088

Please sign in to comment.