Skip to content

Commit

Permalink
feat: atmos ai module
Browse files Browse the repository at this point in the history
  • Loading branch information
Doctor-Cpu authored Jan 7, 2025
1 parent 651b127 commit 6cdd02c
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 3 deletions.
3 changes: 3 additions & 0 deletions Content.Server/Store/Systems/StoreSystem.Ui.cs
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,9 @@ private void OnBuyRequest(EntityUid uid, StoreComponent component, StoreBuyListi
RaiseLocalEvent(buyer, listing.ProductEvent);
}

if (listing.Components != null)
EntityManager.AddComponents(buyer, listing.Components, listing.ReplaceComponents);

if (listing.DisableRefund)
{
component.RefundAllowed = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ private void OnMessageAttempt(BoundUserInterfaceMessageAttempt ev)

if (TryComp(ev.Actor, out StationAiHeldComponent? aiComp) &&
(!TryComp(ev.Target, out StationAiWhitelistComponent? whitelistComponent) ||
_whitelist.IsWhitelistFail(whitelistComponent.Whitelist, ev.Actor) ||
!ValidateAi((ev.Actor, aiComp))))
{
if (whitelistComponent is { Enabled: false })
Expand All @@ -142,9 +143,10 @@ private void OnHeldInteraction(Entity<StationAiHeldComponent> ent, ref Interacti
{
// Cancel if it's not us or something with a whitelist, or whitelist is disabled.
args.Cancelled = (!TryComp(args.Target, out StationAiWhitelistComponent? whitelistComponent)
|| !whitelistComponent.Enabled)
&& ent.Owner != args.Target
&& args.Target != null;
|| !whitelistComponent.Enabled
|| _whitelist.IsWhitelistFail(whitelistComponent.Whitelist, ent.Owner))
&& ent.Owner != args.Target
&& args.Target != null;
if (whitelistComponent is { Enabled: false })
{
ShowDeviceNotRespondingPopup(ent.Owner);
Expand Down
2 changes: 2 additions & 0 deletions Content.Shared/Silicons/StationAi/SharedStationAiSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
using Content.Shared.Power.EntitySystems;
using Content.Shared.StationAi;
using Content.Shared.Verbs;
using Content.Shared.Whitelist;
using Robust.Shared.Audio;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Containers;
Expand Down Expand Up @@ -57,6 +58,7 @@ public abstract partial class SharedStationAiSystem : EntitySystem
[Dependency] private readonly SharedTransformSystem _xforms = default!;
[Dependency] private readonly SharedUserInterfaceSystem _uiSystem = default!;
[Dependency] private readonly StationAiVisionSystem _vision = default!;
[Dependency] private readonly EntityWhitelistSystem _whitelist = default!;

// StationAiHeld is added to anything inside of an AI core.
// StationAiHolder indicates it can hold an AI positronic brain (e.g. holocard / core).
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
using Robust.Shared.GameStates;

namespace Content.Shared.Silicons.StationAi;

[RegisterComponent, NetworkedComponent]
public sealed partial class StationAiAtmosInteractComponent : Component;
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Content.Shared.Whitelist;
using Robust.Shared.GameStates;

namespace Content.Shared.Silicons.StationAi;
Expand All @@ -10,4 +11,7 @@ public sealed partial class StationAiWhitelistComponent : Component
{
[DataField, AutoNetworkedField]
public bool Enabled = true;

[DataField, AutoNetworkedField]
public EntityWhitelist? Whitelist;
}
18 changes: 18 additions & 0 deletions Content.Shared/Store/ListingPrototype.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public ListingData(ListingData other) : this(
other.ProductActionEntity,
other.ProductEvent,
other.RaiseProductEventOnUser,
other.Components,
other.ReplaceComponents,
other.PurchaseAmount,
other.ID,
other.Categories,
Expand All @@ -59,6 +61,8 @@ public ListingData(
EntityUid? productActionEntity,
object? productEvent,
bool raiseProductEventOnUser,
ComponentRegistry? components,
bool replaceComponents,
int purchaseAmount,
string id,
HashSet<ProtoId<StoreCategoryPrototype>> categories,
Expand All @@ -80,6 +84,8 @@ bool disableRefund
ProductActionEntity = productActionEntity;
ProductEvent = productEvent;
RaiseProductEventOnUser = raiseProductEventOnUser;
Components = components;
ReplaceComponents = replaceComponents;
PurchaseAmount = purchaseAmount;
ID = id;
Categories = categories.ToHashSet();
Expand Down Expand Up @@ -179,6 +185,16 @@ bool disableRefund
[DataField]
public bool RaiseProductEventOnUser;

/// <summary>
/// Components to add the the purchaser
/// </summary>
[DataField]
[NonSerialized]
public ComponentRegistry? Components;

[DataField]
public bool ReplaceComponents = false;

/// <summary>
/// used internally for tracking how many times an item was purchased.
/// </summary>
Expand Down Expand Up @@ -291,6 +307,8 @@ public ListingDataWithCostModifiers(ListingData listingData)
listingData.ProductActionEntity,
listingData.ProductEvent,
listingData.RaiseProductEventOnUser,
listingData.Components,
listingData.ReplaceComponents,
listingData.PurchaseAmount,
listingData.ID,
listingData.Categories,
Expand Down
3 changes: 3 additions & 0 deletions Resources/Locale/en-US/store/station-ai-catalog.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ ai-power-overload-desc = Overload a machine causing it to explode.
ai-power-blackout-name = Blackout
ai-power-blackout-desc = Overload the stations APCs for a 30% chance to blow up the bulbs.
ai-power-atmos-name = Atmospherics Upgrade
ai-power-atmos-desc = Allows you to interact with atmospherics valves and mixers.
17 changes: 17 additions & 0 deletions Resources/Prototypes/Catalog/station_ai_catalog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,20 @@
Power: 15
categories:
- AiUtility

- type: listing
id: AiAtmos
name: ai-power-atmos-name
description: ai-power-atmos-desc
icon:
sprite: Structures/Piping/Atmospherics/vent.rsi
state: vent_out
components:
- type: StationAiAtmosInteract
cost:
Power: 50
categories:
- AiUpgrade
conditions:
- !type:ListingLimitedStockCondition
stock: 1
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@
- type: AtmosUnsafeUnanchor
- type: AtmosPipeColor
- type: AtmosMonitoringConsoleDevice
- type: StationAiWhitelist
whitelist:
components:
- StationAiAtmosInteract
- type: Tag
tags:
- Pipe
Expand Down

0 comments on commit 6cdd02c

Please sign in to comment.