Skip to content

Commit

Permalink
RatKingGameRuleFix
Browse files Browse the repository at this point in the history
  • Loading branch information
Kiiwwwie committed Jan 24, 2025
1 parent cb212f1 commit 55beadb
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ public sealed partial class RegalRatRuleComponent : Component
[DataField("entries")]
public List<EntitySpawnEntry> Entries = new();

/// <summary>
/// At least one special entry is guaranteed to spawn
/// </summary>
[DataField("specialEntries")]
public List<EntitySpawnEntry> SpecialEntries = new();
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@ namespace Content.Server.SS220.StationEvents.Components;
[RegisterComponent, Access(typeof(RegalRatSpawnLocation))]
public sealed partial class RegalRatSpawnLocationComponent : Component
{

}
29 changes: 22 additions & 7 deletions Content.Server/SS220/StationEvents/Events/RegalRatRule.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Content.Server.Station.Components;
using Content.Server.SS220.StationEvents.Events;
using Content.Server.SS220.StationEvents.Components;
using Content.Server.StationEvents.Components;
using Content.Server.StationEvents.Events;
using Content.Shared.GameTicking.Components;
using Content.Shared.Station.Components;
Expand All @@ -12,6 +13,7 @@ namespace Content.Server.SS220.StationEvents.Events;

public sealed class RegalRatRule : StationEventSystem<RegalRatRuleComponent>
{

protected override void Started(EntityUid uid, RegalRatRuleComponent component, GameRuleComponent gameRule, GameRuleStartedEvent args)
{
base.Started(uid, component, gameRule, args);
Expand All @@ -21,32 +23,45 @@ protected override void Started(EntityUid uid, RegalRatRuleComponent component,
return;
}

var locations = EntityQueryEnumerator<RegalRatSpawnLocationComponent, TransformComponent>();
var validLocations = new List<EntityCoordinates>();
while (locations.MoveNext(out _, out _, out var transform))
var kingRatLocations = EntityQueryEnumerator<RegalRatSpawnLocationComponent, TransformComponent>();
var mouseLocations = EntityQueryEnumerator<VentCritterSpawnLocationComponent, TransformComponent>();

var kingRatValidLocations = new List<EntityCoordinates>();
var mouseVaidLocations = new List<EntityCoordinates>();

while (mouseLocations.MoveNext(out _, out _, out var transform))
{
if (CompOrNull<StationMemberComponent>(transform.GridUid)?.Station == station &&
HasComp<BecomesStationComponent>(transform.GridUid))
{
validLocations.Add(transform.Coordinates);
mouseVaidLocations.Add(transform.Coordinates);
foreach (var spawn in EntitySpawnCollection.GetSpawns(component.Entries, RobustRandom))
{
Spawn(spawn, transform.Coordinates);
}
}
}

if (component.SpecialEntries.Count == 0 || validLocations.Count == 0)
while (kingRatLocations.MoveNext(out _, out _, out var transform))
{
if (CompOrNull<StationMemberComponent>(transform.GridUid)?.Station == station &&
HasComp<BecomesStationComponent>(transform.GridUid))
{
kingRatValidLocations.Add(transform.Coordinates);
}
}

if (component.SpecialEntries.Count == 0 || kingRatValidLocations.Count == 0)
{
return;
}

// guaranteed spawn
var specialEntry = RobustRandom.Pick(component.SpecialEntries);
var specialSpawn = RobustRandom.Pick(validLocations);
var specialSpawn = RobustRandom.Pick(kingRatValidLocations);
Spawn(specialEntry.PrototypeId, specialSpawn);

foreach (var location in validLocations)
foreach (var location in kingRatValidLocations)
{
foreach (var spawn in EntitySpawnCollection.GetSpawns(component.SpecialEntries, RobustRandom))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@
namespace Content.Server.SS220.StationEvents.Events;
public sealed partial class RegalRatSpawnLocation : StationEventSystem<RegalRatSpawnLocationComponent>
{

}
1 change: 1 addition & 0 deletions Content.Shared/RatKing/SharedRatKingSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ private void OnGetVerb(EntityUid uid, RatKingRummageableComponent component, Get
//SS220 RatKing Changes start here
private void OnRummageAction(Entity<RatKingComponent> entity, ref RatKingRummageActionEvent args)
{

if (args.Handled || !TryComp<RatKingRummageableComponent>(args.Target, out var rumComp) || rumComp.Looted)
return;

Expand Down
8 changes: 3 additions & 5 deletions Resources/Prototypes/GameRules/events.yml
Original file line number Diff line number Diff line change
Expand Up @@ -326,11 +326,9 @@
parent: BaseStationEventShortDelay
components:
- type: StationEvent
#SS220 audio muted and no announcment, because Central command do not check piles of trash
#startAnnouncement: station-event-vent-creatures-start-announcement
#startAudio:
# path: /Audio/Announcements/attention.ogg
#SS220 changes end here
startAnnouncement: station-event-vent-creatures-start-announcement
startAudio:
path: /Audio/Announcements/attention.ogg
earliestStart: 15
weight: 6
duration: 50
Expand Down

0 comments on commit 55beadb

Please sign in to comment.