Skip to content

Commit

Permalink
Low pop food events (new-frontiers-14#1708)
Browse files Browse the repository at this point in the history
* Events Fixups

* McCrate

* McEvent

* McEvent

* Update Resources/Textures/_NF/Structures/Storage/Crates/mccargo.rsi/meta.json

Co-authored-by: Whatstone <[email protected]>

* Update Content.Server/StationEvents/Components/BluespaceCargoRuleComponent.cs

Co-authored-by: Whatstone <[email protected]>

* Update Content.Server/StationEvents/Events/BluespaceCargoRule.cs

Co-authored-by: Whatstone <[email protected]>

* Update Resources/Prototypes/_NF/Events/events_nf.yml

Co-authored-by: Whatstone <[email protected]>

* Update Resources/Prototypes/_NF/Events/events_nf.yml

Co-authored-by: Whatstone <[email protected]>

* Update Resources/Prototypes/_NF/Entities/Objects/Consumable/Food/Containers/box.yml

Co-authored-by: Whatstone <[email protected]>

* Move

* Fixup

* Update box.yml

* Update box.yml

* Update box.yml

* Update events_nf.yml

* McCargoCrate maxOccurrences set to 4

---------

Co-authored-by: Whatstone <[email protected]>
Co-authored-by: ErhardSteinhauer <[email protected]>
Co-authored-by: Whatstone <[email protected]>
  • Loading branch information
4 people authored Jul 20, 2024
1 parent 4710c9e commit 98818de
Show file tree
Hide file tree
Showing 22 changed files with 1,079 additions and 165 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,18 @@ namespace Content.Server.StationEvents.Components;
[RegisterComponent, Access(typeof(BluespaceCargoRule))]
public sealed partial class BluespaceCargoRuleComponent : Component
{
[DataField("cargoSpawnerPrototype", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
public string CargoSpawnerPrototype = "RandomCargoSpawner";
[DataField(customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
public string SpawnerPrototype = "RandomCargoSpawner";

[DataField("cargoGenericSpawnerPrototype", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
public string CargoGenericSpawnerPrototype = "RandomCargoGenericSpawner";
[DataField]
public bool RequireSafeAtmosphere = false;

[DataField("cargoFlashPrototype", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
public string CargoFlashPrototype = "EffectFlashBluespace";
[DataField(customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
public string FlashPrototype = "EffectFlashBluespace";

[DataField]
public int MinimumSpawns = 1;

[DataField]
public int MaximumSpawns = 3;
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,9 @@ public sealed partial class StationEventComponent : Component
public int MinimumPlayers;

/// <summary>
/// How many players need to be present on station for the event to not run
/// </summary>
/// <remarks>
/// To avoid running safe events with high-pop
/// Frontier - How many players need to be present on station for the event to not run, to avoid running safe events with high-pop
/// </remarks>
[DataField("maximumPlayers")]
[DataField]
public int MaximumPlayers = 999;

/// <summary>
Expand Down
26 changes: 9 additions & 17 deletions Content.Server/StationEvents/Events/BluespaceCargoRule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ public sealed class BluespaceCargoRule : StationEventSystem<BluespaceCargoRuleCo
protected override void Added(EntityUid uid, BluespaceCargoRuleComponent component, GameRuleComponent gameRule, GameRuleAddedEvent args)
{
base.Added(uid, component, gameRule, args);

var str = Loc.GetString("bluespace-cargo-event-announcement");
ChatSystem.DispatchGlobalAnnouncement(str, colorOverride: Color.FromHex("#18abf5"));
}

protected override void Started(EntityUid uid, BluespaceCargoRuleComponent component, GameRuleComponent gameRule, GameRuleStartedEvent args)
Expand All @@ -41,21 +38,20 @@ protected override void Started(EntityUid uid, BluespaceCargoRuleComponent compo
if (grid is null)
return;

var amountToSpawn = Math.Max(1, (int) MathF.Round(5 / 1.5f));
var amountToSpawn = _random.Next(component.MinimumSpawns, component.MaximumSpawns + 1); // +1 required: [min, max)
for (var i = 0; i < amountToSpawn; i++)
{
SpawnOnRandomGridLocation(grid.Value, component.CargoSpawnerPrototype, component.CargoGenericSpawnerPrototype, component.CargoFlashPrototype);
SpawnOnRandomGridLocation(grid.Value, component.SpawnerPrototype, component.FlashPrototype, component.RequireSafeAtmosphere);
}
}

public void SpawnOnRandomGridLocation(EntityUid grid, string toSpawn, string toSpawnGeneric, string toSpawnFlash)
public void SpawnOnRandomGridLocation(EntityUid grid, string toSpawn, string toSpawnFlash, bool safeAtmosphere)
{
if (!TryComp<MapGridComponent>(grid, out var gridComp))
return;

var xform = Transform(grid);

var toSpawnCrate = toSpawn;
var targetCoords = xform.Coordinates;
var gridBounds = gridComp.LocalAABB.Scale(_configuration.GetCVar(CCVars.CargoGenerationGridBoundsScale));

Expand All @@ -73,15 +69,6 @@ public void SpawnOnRandomGridLocation(EntityUid grid, string toSpawn, string toS
continue;
}

if (_atmosphere.IsTileMixtureProbablySafe(grid, grid, tile))
{
toSpawnCrate = toSpawn;
}
else
{
toSpawnCrate = toSpawnGeneric; // Dont let an animal die!
}

// don't spawn inside of solid objects
var physQuery = GetEntityQuery<PhysicsComponent>();
var valid = true;
Expand All @@ -100,11 +87,16 @@ public void SpawnOnRandomGridLocation(EntityUid grid, string toSpawn, string toS
if (!valid)
continue;

if (safeAtmosphere && !_atmosphere.IsTileMixtureProbablySafe(grid, grid, tile))
{
continue;
}

targetCoords = gridComp.GridTileToLocal(tile);
break;
}

Spawn(toSpawnCrate, targetCoords);
Spawn(toSpawn, targetCoords);
Spawn(toSpawnFlash, targetCoords);

Sawmill.Info($"Spawning random cargo at {targetCoords}");
Expand Down
103 changes: 0 additions & 103 deletions Content.Server/StationEvents/Events/BluespaceSyndicateCargoRule.cs

This file was deleted.

Loading

0 comments on commit 98818de

Please sign in to comment.