diff --git a/Content.Server/Corvax/Inflation/InflationCargoCrateComponent.cs b/Content.Server/Corvax/Inflation/InflationCargoCrateComponent.cs new file mode 100644 index 00000000000..608cfa9dc11 --- /dev/null +++ b/Content.Server/Corvax/Inflation/InflationCargoCrateComponent.cs @@ -0,0 +1,7 @@ +[RegisterComponent] +[AutoGenerateComponentState] +public sealed partial class InflationCargoCrateComponent : Component +{ + [DataField("isInflated"), ViewVariables(VVAccess.ReadWrite)] + public bool IsInflated = false; +} diff --git a/Content.Server/Corvax/Inflation/InflationCargoCrateSystem.cs b/Content.Server/Corvax/Inflation/InflationCargoCrateSystem.cs new file mode 100644 index 00000000000..0e0cc4cedb9 --- /dev/null +++ b/Content.Server/Corvax/Inflation/InflationCargoCrateSystem.cs @@ -0,0 +1,69 @@ +using Robust.Shared.Timing; +using Content.Server.Chat.Systems; +using Content.Shared._NF.Trade.Components; +using Content.Shared.Cargo.Components; + +namespace Content.Server.Corvax.Inflation; + +public sealed class InflationCargoCrateSystem : EntitySystem +{ + [Dependency] private readonly IGameTiming _gameTiming = default!; + [Dependency] private readonly IEntityManager _entManager = default!; + + private TimeSpan? Timer = TimeSpan.FromMinutes(5); + private TimeSpan? NextTimeToCheck = TimeSpan.FromSeconds(5); + + StaticPriceComponent? staticPriceComponent = null; + public override void Update(float frameTime) + { + base.Update(frameTime); + + int numberCrates = 0; + + double modifier = 0; + + if (NextTimeToCheck < _gameTiming.CurTime) + { + numberCrates = _entManager.Count(); + + var query = EntityQueryEnumerator(); + while (query.MoveNext(out var uid, out var inflationCargoCrateComponent)) + { + var xformQuery = GetEntityQuery(); + if (!xformQuery.TryGetComponent(uid, out var xform)) + { + return; + } + + if (numberCrates >= 1 && numberCrates <= 19) + modifier = 1; + else if (numberCrates >= 20 && numberCrates <= 39) + modifier = 0.9; + else if (numberCrates >= 40 && numberCrates <= 69) + modifier = 0.85; + else if (numberCrates >= 70) + modifier = 0.82; + + foreach (var iterator in _entManager.EntityQuery(true)) + { + + if (TryComp(uid, out inflationCargoCrateComponent)) + { + if (inflationCargoCrateComponent.IsInflated) + continue; + + if (TryComp(uid, out staticPriceComponent)) + { + staticPriceComponent.Price *= modifier; + inflationCargoCrateComponent.IsInflated = true; + } + + if (iterator.Owner == uid) + continue; + } + } + } + NextTimeToCheck = NextTimeToCheck + Timer; + } + } +} diff --git a/Resources/Prototypes/_NF/Catalog/Cargo/cargo_trade.yml b/Resources/Prototypes/_NF/Catalog/Cargo/cargo_trade.yml index d8985d039b8..ea900a8177f 100644 --- a/Resources/Prototypes/_NF/Catalog/Cargo/cargo_trade.yml +++ b/Resources/Prototypes/_NF/Catalog/Cargo/cargo_trade.yml @@ -4,7 +4,7 @@ sprite: _NF/Structures/Storage/Crates/tradedark.rsi state: icon product: CrateTradeSecureNormalFilled - cost: 1000 + cost: 15000 category: cargoproduct-category-name-cargo group: market @@ -14,6 +14,6 @@ sprite: _NF/Structures/Storage/Crates/tradelight.rsi state: icon product: CrateTradeSecureHighFilled - cost: 2000 + cost: 30000 category: cargoproduct-category-name-cargo group: market diff --git a/Resources/Prototypes/_NF/Catalog/Fills/Crates/trade.yml b/Resources/Prototypes/_NF/Catalog/Fills/Crates/trade.yml index 674c1ca9392..d0fd2d01bbf 100644 --- a/Resources/Prototypes/_NF/Catalog/Fills/Crates/trade.yml +++ b/Resources/Prototypes/_NF/Catalog/Fills/Crates/trade.yml @@ -3,12 +3,18 @@ parent: CrateTradeBaseSecureNormal name: cargo trading crate description: Contains goods made in the Frontier sector, ready to be sold on a cargo depot for higher value. MAKE SURE THE CRATE IS INTACT. + components: + - type: InflationCargoCrate + isInflated: false - type: entity id: CrateTradeSecureHighFilled parent: CrateTradeBaseSecureHigh name: high value cargo trading crate description: Contains high value goods made in the Frontier sector, ready to be sold on a cargo depot for higher value. MAKE SURE THE CRATE IS INTACT. + components: + - type: InflationCargoCrate + isInflated: false - type: entity id: CrateTradeContrabandSecureNormalFilled @@ -17,7 +23,7 @@ - type: entity id: CrateTradeContrabandSecureDonkFilled parent: CrateTradeContrabandSecureDonk - + - type: entity id: CrateTradeContrabandSecureCyberSunFilled parent: CrateTradeContrabandSecureCyberSun diff --git a/Resources/Prototypes/_NF/Entities/Structures/Storage/Crates/crates.yml b/Resources/Prototypes/_NF/Entities/Structures/Storage/Crates/crates.yml index 1600d76bf9c..a9e9dcfab24 100644 --- a/Resources/Prototypes/_NF/Entities/Structures/Storage/Crates/crates.yml +++ b/Resources/Prototypes/_NF/Entities/Structures/Storage/Crates/crates.yml @@ -49,7 +49,7 @@ layer: - MachineLayer - type: StaticPrice - price: 1000 + price: 15500 - type: entity parent: CrateTradeBaseSecure @@ -75,7 +75,7 @@ layer: - MachineLayer - type: StaticPrice - price: 2000 + price: 31000 - type: entity parent: CrateTradeBaseSecure