forked from space-wizards/space-station-14
-
Notifications
You must be signed in to change notification settings - Fork 156
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
107 additions
and
5 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
Content.Server/SS220/StationEvents/Components/RegalRatRuleComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using Content.Server.SS220.StationEvents.Events; | ||
using Content.Server.SS220.StationEvents.Components; | ||
using Content.Server.StationEvents.Events; | ||
using Content.Shared.Storage; | ||
|
||
namespace Content.Server.SS220.StationEvents.Components; | ||
|
||
[RegisterComponent, Access(typeof(RegalRatRule))] | ||
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(); | ||
} |
11 changes: 11 additions & 0 deletions
11
Content.Server/SS220/StationEvents/Components/RegalRatSpawnLocationComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using Content.Server.SS220.StationEvents.Events; | ||
using Content.Server.SS220.StationEvents.Components; | ||
using Content.Server.StationEvents.Events; | ||
|
||
namespace Content.Server.SS220.StationEvents.Components; | ||
|
||
[RegisterComponent, Access(typeof(RegalRatSpawnLocation))] | ||
public sealed partial class RegalRatSpawnLocationComponent : Component | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
using Content.Server.Station.Components; | ||
using Content.Server.SS220.StationEvents.Events; | ||
using Content.Server.StationEvents.Events; | ||
using Content.Shared.GameTicking.Components; | ||
using Content.Shared.Station.Components; | ||
using Content.Shared.Storage; | ||
using Robust.Shared.Map; | ||
using Robust.Shared.Random; | ||
|
||
namespace Content.Server.SS220.StationEvents.Events; | ||
|
||
public sealed class RegalRatRule : StationEventSystem<RegalRatRuleComponent> | ||
{ | ||
/* | ||
* DO NOT COPY PASTE THIS TO MAKE YOUR MOB EVENT. | ||
* USE THE PROTOTYPE. | ||
*/ | ||
|
||
protected override void Started(EntityUid uid, RegalRatRuleComponent component, GameRuleComponent gameRule, GameRuleStartedEvent args) | ||
{ | ||
base.Started(uid, component, gameRule, args); | ||
|
||
if (!TryGetRandomStation(out var station)) | ||
{ | ||
return; | ||
} | ||
|
||
var locations = EntityQueryEnumerator<RegalRatSpawnLocationComponent, TransformComponent>(); | ||
var validLocations = new List<EntityCoordinates>(); | ||
while (locations.MoveNext(out _, out _, out var transform)) | ||
{ | ||
if (CompOrNull<StationMemberComponent>(transform.GridUid)?.Station == station && | ||
HasComp<BecomesStationComponent>(transform.GridUid)) | ||
{ | ||
validLocations.Add(transform.Coordinates); | ||
foreach (var spawn in EntitySpawnCollection.GetSpawns(component.Entries, RobustRandom)) | ||
{ | ||
Spawn(spawn, transform.Coordinates); | ||
} | ||
} | ||
} | ||
|
||
if (component.SpecialEntries.Count == 0 || validLocations.Count == 0) | ||
{ | ||
return; | ||
} | ||
|
||
// guaranteed spawn | ||
var specialEntry = RobustRandom.Pick(component.SpecialEntries); | ||
var specialSpawn = RobustRandom.Pick(validLocations); | ||
Spawn(specialEntry.PrototypeId, specialSpawn); | ||
|
||
foreach (var location in validLocations) | ||
{ | ||
foreach (var spawn in EntitySpawnCollection.GetSpawns(component.SpecialEntries, RobustRandom)) | ||
{ | ||
Spawn(spawn, location); | ||
} | ||
} | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
Content.Server/SS220/StationEvents/Events/RegalRatSpawnLocation.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using Content.Server.SS220.StationEvents.Events; | ||
using Content.Server.SS220.StationEvents.Components; | ||
using Content.Server.StationEvents.Events; | ||
|
||
namespace Content.Server.SS220.StationEvents.Events; | ||
public sealed partial class RegalRatSpawnLocation : StationEventSystem<RegalRatSpawnLocationComponent> | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters