Skip to content

Commit

Permalink
Merge branch 'master' into Arsenal-Tech-Overhaul
Browse files Browse the repository at this point in the history
  • Loading branch information
Stop-Signs authored Nov 5, 2024
2 parents a23c926 + 7199491 commit 47cf29c
Show file tree
Hide file tree
Showing 83 changed files with 931 additions and 56 deletions.
8 changes: 8 additions & 0 deletions Content.Client/DeltaV/Addictions/AddictionSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using Content.Shared.DeltaV.Addictions;

namespace Content.Client.DeltaV.Addictions;

public sealed class AddictionSystem : SharedAddictionSystem
{
protected override void UpdateTime(EntityUid uid) {}
}
13 changes: 5 additions & 8 deletions Content.Server/Cargo/Systems/CargoSystem.Orders.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,11 @@ private void UpdateConsole(float frameTime)
{
_timer -= Delay;

foreach (var account in EntityQuery<StationBankAccountComponent>())
var stationQuery = EntityQueryEnumerator<StationBankAccountComponent>();
while (stationQuery.MoveNext(out var uid, out var bank))
{
account.Balance += account.IncreasePerSecond * Delay;
var balanceToAdd = bank.IncreasePerSecond * Delay;
UpdateBankAccount(uid, bank, balanceToAdd);
}

var query = EntityQueryEnumerator<CargoOrderConsoleComponent>();
Expand Down Expand Up @@ -213,7 +215,7 @@ private void OnApproveOrderMessage(EntityUid uid, CargoOrderConsoleComponent com
$"{ToPrettyString(player):user} approved order [orderId:{order.OrderId}, quantity:{order.OrderQuantity}, product:{order.ProductId}, requester:{order.Requester}, reason:{order.Reason}] with balance at {bank.Balance}");

orderDatabase.Orders.Remove(order);
DeductFunds(bank, cost);
UpdateBankAccount(station.Value, bank, -cost);
UpdateOrders(station.Value);
}

Expand Down Expand Up @@ -538,11 +540,6 @@ private bool FulfillOrder(CargoOrderData order, EntityCoordinates spawn, string?

}

private void DeductFunds(StationBankAccountComponent component, int amount)
{
component.Balance = Math.Max(0, component.Balance - amount);
}

#region Station

private bool TryGetOrderDatabase([NotNullWhen(true)] EntityUid? stationUid, [MaybeNullWhen(false)] out StationCargoOrderDatabaseComponent dbComp)
Expand Down
89 changes: 89 additions & 0 deletions Content.Server/DeltaV/Addictions/AddictionSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
using Content.Shared.Dataset;
using Content.Shared.DeltaV.Addictions;
using Content.Shared.Popups;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
using Robust.Shared.Timing;

namespace Content.Server.DeltaV.Addictions;

public sealed class AddictionSystem : SharedAddictionSystem
{
[Dependency] private readonly SharedPopupSystem _popup = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly IGameTiming _timing = default!;

// Define the numbers, we're not making another DeepFryerSystem.cs
// Minimum time between popups
private const int MinEffectInterval = 10;

// Maximum time between popups
private const int MaxEffectInterval = 41;

// The time to add after the last metabolism cycle
private const int SuppressionDuration = 10;

public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<AddictedComponent, ComponentStartup>(OnInit);
}

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

var curTime = _timing.CurTime;
var query = EntityQueryEnumerator<AddictedComponent>();

while (query.MoveNext(out var uid, out var component))
{
// If it's suppressed, check if it's still supposed to be
if (component.Suppressed)
{
UpdateSuppressed(component);
continue;
}

if (curTime < component.NextEffectTime)
continue;

DoAddictionEffect(uid);
component.NextEffectTime = curTime + TimeSpan.FromSeconds(_random.Next(MinEffectInterval, MaxEffectInterval));
}
}

// Make sure we don't get a popup on the first update
private void OnInit(Entity<AddictedComponent> ent, ref ComponentStartup args)
{
var curTime = _timing.CurTime;
ent.Comp.NextEffectTime = curTime + TimeSpan.FromSeconds(_random.Next(MinEffectInterval, MaxEffectInterval));
}

private void UpdateSuppressed(AddictedComponent component)
{
component.Suppressed = (_timing.CurTime < component.SuppressionEndTime);
}

private string GetRandomPopup()
{
return Loc.GetString(_random.Pick(_prototypeManager.Index<LocalizedDatasetPrototype>("AddictionEffects").Values));
}

private void DoAddictionEffect(EntityUid uid)
{
_popup.PopupEntity(GetRandomPopup(), uid, uid);
}

// Called each time a reagent with the Addicted effect gets metabolized
protected override void UpdateTime(EntityUid uid)
{
if (!TryComp<AddictedComponent>(uid, out var component))
return;

component.LastMetabolismTime = _timing.CurTime;
component.SuppressionEndTime = _timing.CurTime + TimeSpan.FromSeconds(SuppressionDuration);
UpdateSuppressed(component);
}
}
29 changes: 29 additions & 0 deletions Content.Server/DeltaV/EntityEffects/Effects/Addicted.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using Content.Shared.DeltaV.Addictions;
using Content.Shared.EntityEffects;
using Robust.Shared.Prototypes;

namespace Content.Server.EntityEffects.Effects;

public sealed partial class Addicted : EntityEffect
{
/// <summary>
/// How long should each metabolism cycle make the effect last for.
/// </summary>
[DataField]
public float AddictionTime = 3f;

protected override string? ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys)
=> Loc.GetString("reagent-effect-guidebook-addicted", ("chance", Probability));

public override void Effect(EntityEffectBaseArgs args)
{
var addictionTime = AddictionTime;

if (args is EntityEffectReagentArgs reagentArgs) {
addictionTime *= reagentArgs.Scale.Float();
}

var addictionSystem = args.EntityManager.System<SharedAddictionSystem>();
addictionSystem.TryApplyAddiction(args.TargetEntity, addictionTime);
}
}
37 changes: 37 additions & 0 deletions Content.Shared/DeltaV/Addictions/AddictedComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using Robust.Shared.GameStates;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
using Robust.Shared.Timing;

namespace Content.Shared.DeltaV.Addictions;

[RegisterComponent, NetworkedComponent, Access(typeof(SharedAddictionSystem))]
[AutoGenerateComponentState, AutoGenerateComponentPause]
public sealed partial class AddictedComponent : Component
{
/// <summary>
/// Whether to suppress pop-ups.
/// </summary>
[DataField, AutoNetworkedField]
public bool Suppressed;

/// <summary>
/// The <see cref="IGameTiming.CurTime"/> timestamp of last StatusEffect trigger.
/// </summary>
[DataField(serverOnly: true, customTypeSerializer: typeof(TimeOffsetSerializer))]
[AutoPausedField]
public TimeSpan? LastMetabolismTime;

/// <summary>
/// The <see cref="IGameTiming.CurTime"/> timestamp of the next popup.
/// </summary>
[DataField(serverOnly: true, customTypeSerializer: typeof(TimeOffsetSerializer))]
[AutoPausedField]
public TimeSpan? NextEffectTime;

/// <summary>
/// The <see cref="IGameTiming.CurTime"/> timestamp of the when the suppression ends
/// </summary>
[DataField(serverOnly: true, customTypeSerializer: typeof(TimeOffsetSerializer))]
[AutoPausedField]
public TimeSpan? SuppressionEndTime;
}
30 changes: 30 additions & 0 deletions Content.Shared/DeltaV/Addictions/SharedAddictionSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using Content.Shared.StatusEffect;
using Robust.Shared.Prototypes;

namespace Content.Shared.DeltaV.Addictions;

public abstract class SharedAddictionSystem : EntitySystem
{
[Dependency] private readonly StatusEffectsSystem _statusEffects = default!;

public ProtoId<StatusEffectPrototype> StatusEffectKey = "Addicted";

protected abstract void UpdateTime(EntityUid uid);

public virtual void TryApplyAddiction(EntityUid uid, float addictionTime, StatusEffectsComponent? status = null)
{
if (!Resolve(uid, ref status, false))
return;

UpdateTime(uid);

if (!_statusEffects.HasStatusEffect(uid, StatusEffectKey, status))
{
_statusEffects.TryAddStatusEffect<AddictedComponent>(uid, StatusEffectKey, TimeSpan.FromSeconds(addictionTime), true, status);
}
else
{
_statusEffects.TryAddTime(uid, StatusEffectKey, TimeSpan.FromSeconds(addictionTime), status);
}
}
}
54 changes: 29 additions & 25 deletions Resources/Changelog/DeltaVChangelog.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,4 @@
Entries:
- author: Colin-Tel
changes:
- message: Adjusted Asterisk and Shoukou's min/max population to 0/60.
type: Tweak
id: 145
time: '2023-11-19T06:10:32.0000000+00:00'
- author: IamVelcroboy
changes:
- message: Salvage has been rebased. New but strangely familiar space debris will
be pulled in by the salvage magnet. Caution is recommended.
type: Add
id: 146
time: '2023-11-22T16:13:12.0000000+00:00'
- author: tryded
changes:
- message: Added double bladed energy swords to Nuclear Operative Uplinks
type: Add
id: 147
time: '2023-11-25T14:38:20.0000000+00:00'
- author: TJohnson
changes:
- message: Seclites now robust as advertised in item description.
type: Tweak
id: 148
time: '2023-11-26T00:36:54.0000000+00:00'
- author: Colin-Tel
changes:
- message: Asterisk Station is now protected by additional meteor netting and is
Expand Down Expand Up @@ -3702,3 +3677,32 @@
id: 644
time: '2024-11-04T02:03:38.0000000+00:00'
url: https://github.com/DeltaV-Station/Delta-v/pull/2108
- author: Radezolid
changes:
- message: Added prescription security glasses and prescription corpsman glasses!
type: Add
id: 645
time: '2024-11-04T07:39:15.0000000+00:00'
url: https://github.com/DeltaV-Station/Delta-v/pull/2083
- author: clinux
changes:
- message: Removed the ability to upgrade reinforced windows to into shuttle windows
type: Remove
id: 646
time: '2024-11-04T19:41:43.0000000+00:00'
url: https://github.com/DeltaV-Station/Delta-v/pull/2118
- author: Unkn0wnGh0st333
changes:
- message: Added Robotics Airlocks, one step closer to the Roboticist Job.
type: Add
id: 647
time: '2024-11-04T19:54:28.0000000+00:00'
url: https://github.com/DeltaV-Station/Delta-v/pull/2121
- author: Radezolid
changes:
- message: Re-added the fire-fighting door remote to atmospheric technicians lockers,
but it only has maintenance access now.
type: Add
id: 648
time: '2024-11-04T23:49:18.0000000+00:00'
url: https://github.com/DeltaV-Station/Delta-v/pull/2007
5 changes: 5 additions & 0 deletions Resources/Locale/en-US/deltav/guidebook/chemistry/effects.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
reagent-effect-guidebook-addicted =
{ $chance ->
[1] Causes
*[other] cause
} an addiction.
2 changes: 2 additions & 0 deletions Resources/Prototypes/Catalog/Fills/Lockers/engineer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
- id: GasAnalyzer
- id: MedkitOxygenFilled
- id: HolofanProjector
- id: DoorRemoteFirefight # DeltaV - Re-added fire-fighting remote.
- id: RCD
- id: RCDAmmo
- id: LunchboxEngineeringFilledRandom # Delta-V Lunchboxes!
Expand All @@ -112,6 +113,7 @@
- id: GasAnalyzer
- id: MedkitOxygenFilled
- id: HolofanProjector
- id: DoorRemoteFirefight # DeltaV - Re-added fire-fighting remote.
- id: RCD
- id: RCDAmmo
- id: LunchboxEngineeringFilledRandom # Delta-V Lunchboxes!
Expand Down
5 changes: 5 additions & 0 deletions Resources/Prototypes/DeltaV/Access/engineering.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
- type: accessGroup
id: FireFight
tags:
- Engineering
- Atmospherics
5 changes: 5 additions & 0 deletions Resources/Prototypes/DeltaV/Datasets/addictions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
- type: localizedDataset
id: AddictionEffects
values:
prefix: reagent-effect-medaddiction-
count: 8
41 changes: 41 additions & 0 deletions Resources/Prototypes/DeltaV/Entities/Clothing/Eyes/glasses.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
node: glassesCorps
- type: Tag
tags:
- GlassesCorpsman # Added for prescription glasses.
- HamsterWearable
- WhitelistChameleon
- SecDogWearable
Expand All @@ -42,3 +43,43 @@
- type: IdentityBlocker
coverage: EYES

- type: entity
parent: ClothingEyesBase
id: ClothingEyesPrescriptionBaseSecGlasses
abstract: true
components:
- type: FlashImmunity
- type: EyeProtection
protectionTime: 5
- type: VisionCorrection
correctionPower: 1.50 # Being flash proof comes at the cost of less range of vision
- type: IdentityBlocker
coverage: EYES

- type: entity
parent: [ClothingEyesPrescriptionBaseSecGlasses, ShowSecurityIcons, BaseRestrictedContraband]
id: ClothingEyesPrescriptionSecurityGlasses
name: prescription security glasses
description: A pair of security glasses with what appears to be a... prescription lens glued on top?
components:
- type: Construction
graph: PrescriptionSecGlasses
node: prescsecglasses
- type: Sprite
sprite: DeltaV/Clothing/Eyes/Glasses/prescsecglasses.rsi
- type: Clothing
sprite: DeltaV/Clothing/Eyes/Glasses/prescsecglasses.rsi

- type: entity
parent: [ClothingEyesPrescriptionBaseSecGlasses, ShowMedicalIcons, BaseRestrictedContraband]
id: ClothingEyesPrescriptionCorpsmanGlasses
name: prescription corpsman glasses
description: A pair of corpsman glasses with what appears to be a... prescription lens glued on top?
components:
- type: Construction
graph: PrescriptionCorpsmanGlasses
node: presccorpsglasses
- type: Sprite
sprite: DeltaV/Clothing/Eyes/Glasses/presccorpsglasses.rsi
- type: Clothing
sprite: DeltaV/Clothing/Eyes/Glasses/presccorpsglasses.rsi
Loading

0 comments on commit 47cf29c

Please sign in to comment.