Skip to content

Commit

Permalink
balance changes to wave defense and remcomp timedstoragefill
Browse files Browse the repository at this point in the history
  • Loading branch information
Cheackraze authored and Partmedia committed Jun 25, 2023
1 parent dfbaa87 commit 4a8d954
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public sealed class WaveDefenseRuleConfiguration : GameRuleConfiguration
public float DifficultyMod = 0.65f;

[DataField("waveTime")]
public int WaveTime = 300;
public int WaveTime = 240;

[DataField("greetingSound", customTypeSerializer: typeof(SoundSpecifierTypeSerializer))]
public SoundSpecifier? GreetSound = new SoundPathSpecifier("/Audio/Misc/nukeops.ogg");
Expand Down
20 changes: 12 additions & 8 deletions Content.Server/GameTicking/Rules/WaveDefenseRuleSystem.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
using Content.Server.Cargo.Systems;
using Content.Server.Chat.Managers;
using Content.Server.GameTicking.Rules.Components;
using Content.Server.GameTicking.Rules.Configurations;
using Content.Server.Objectives.Interfaces;
using Content.Server.Players;
using Content.Server.RoundEnd;
using Content.Server.Spawners.Components;
using Content.Server.Traitor;
using Content.Shared.Mobs;
using Robust.Server.Player;
using Robust.Shared.Configuration;
using Robust.Shared.Map;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
Expand All @@ -19,7 +15,8 @@
using Content.Shared.Administration;
using Content.Shared.Mobs.Components;
using System.Linq;
using Content.Shared.GameTicking;
using Content.Server.Cargo.Components;
using Content.Server.Station.Systems;

namespace Content.Server.GameTicking.Rules;

Expand All @@ -33,6 +30,8 @@ public sealed class WaveDefenseRuleSystem : GameRuleSystem
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly RoundEndSystem _roundEndSystem = default!;
[Dependency] private readonly IPrototypeManager _protoManager = default!;
[Dependency] private readonly CargoSystem _cargo = default!;
[Dependency] private readonly StationSystem _station = default!;

public override string Prototype => "WaveDefense";

Expand Down Expand Up @@ -190,7 +189,7 @@ private List<string> PickMonsters(int wave)
//Todo: fine tune this, i just slapped an integer here wcgw.
//Ideally, we would have no numbers hard coded at all and should rely solely on the RuleConfig, so go there to change the actual difficulty
//or make a new rule config. Same goes with timer
var wavePool = wave * _waveDefenseRuleConfig.DifficultyMod * (Defenders.Count * 2);
var wavePool = wave * _waveDefenseRuleConfig.DifficultyMod * (Defenders.Count * 3);
var waveTemplate = _random.Pick(mobList).Value.Item1;
var spawnList = new List<string>();

Expand Down Expand Up @@ -222,7 +221,12 @@ private void OnMobDied(EntityUid mobUid, WaveMobComponent component, MobStateCha
KillCount++;
HighScore += component.Difficulty * 10;
RemCompDeferred<WaveMobComponent>(mobUid);
}
var station = _station.GetOwningStation(mobUid);
if (TryComp<StationBankAccountComponent>(station, out var stationBank))
{
_cargo.UpdateBankAccount(stationBank, (int)(component.Difficulty * 100));
}
}
}

private void OnPlayerDied(EntityUid mobUid, WaveDefenderComponent component, MobStateChangedEvent args)
Expand Down
21 changes: 16 additions & 5 deletions Content.Server/Spawners/EntitySystems/TimedStorageFillSystem.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
using Content.Server.Spawners.Components;
using Content.Server.Storage.EntitySystems;
using Content.Server.Storage.Components;
using Content.Shared.Storage;
using Robust.Shared.Random;
using Content.Server.Spawners.Components;

namespace Content.Server.Storage.EntitySystems;
namespace Content.Server.Spawners.EntitySystems;

public sealed partial class TimedStorageFillSystem : EntitySystem
public sealed class TimedStorageFillSystem : EntitySystem
{
[Dependency] private readonly IRobustRandom _robustRandom = default!;
[Dependency] private readonly EntityStorageSystem _entityStorage = default!;
Expand All @@ -15,10 +16,11 @@ public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<TimedStorageFillComponent, ComponentStartup>(OnStartup);
SubscribeLocalEvent<TimedStorageFillComponent, AnchorStateChangedEvent>(OnUnanchor);
}

private void OnStartup(EntityUid uid, TimedStorageFillComponent component, ComponentStartup args)
{
{
FillStorage(uid, component);
component.NextRefillTime = _robustRandom.NextFloat(component.MinimumSeconds, component.MaximumSeconds);
}
Expand All @@ -41,7 +43,8 @@ public override void Update(float frameTime)

private void FillStorage(EntityUid uid, TimedStorageFillComponent component)
{
if (component.Contents.Count == 0) return;
if (component.Contents.Count == 0)
return;

TryComp<ServerStorageComponent>(uid, out var serverStorageComp);
TryComp<EntityStorageComponent>(uid, out var entityStorageComp);
Expand Down Expand Up @@ -73,4 +76,12 @@ private void FillStorage(EntityUid uid, TimedStorageFillComponent component)
EntityManager.DeleteEntity(ent);
}
}

private void OnUnanchor(EntityUid uid, TimedStorageFillComponent component, ref AnchorStateChangedEvent args)
{
if (!args.Anchored)
{
RemCompDeferred<TimedStorageFillComponent>(uid);
}
}
}

0 comments on commit 4a8d954

Please sign in to comment.