-
Notifications
You must be signed in to change notification settings - Fork 267
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* rename pirate radio map to listening post, change spawner prototype * refactor pirate radio spawn rule into DebrisSpawner and LoadFarGrid * remove obsolete yml * -m make listening post rule use new stuff and antag selection * other changes * fixes * more * fixy * fix nan * final fix * what --------- Co-authored-by: deltanedas <@deltanedas:kde.org>
- Loading branch information
1 parent
b00856c
commit 5e812e0
Showing
15 changed files
with
281 additions
and
204 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
Content.Server/DeltaV/StationEvents/Components/DebrisSpawnerRuleComponent.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,30 @@ | ||
/* | ||
* Delta-V - This file is licensed under AGPLv3 | ||
* Copyright (c) 2024 Delta-V Contributors | ||
* See AGPLv3.txt for details. | ||
*/ | ||
|
||
using Content.Server.StationEvents.Events; | ||
|
||
namespace Content.Server.StationEvents.Components; | ||
|
||
/// <summary> | ||
/// Spawns random debris in space around a loaded grid. | ||
/// Requires <see cref="LoadFarGridRuleComponent"/>. | ||
/// </summary> | ||
[RegisterComponent, Access(typeof(DebrisSpawnerRule))] | ||
public sealed partial class DebrisSpawnerRuleComponent : Component | ||
{ | ||
/// <summary> | ||
/// How many debris grids to spawn. | ||
/// </summary> | ||
[DataField(required: true)] | ||
public int Count; | ||
|
||
/// <summary> | ||
/// Modifier for debris distance. | ||
/// Should be between 3 and 10 generally. | ||
/// </summary> | ||
[DataField(required: true)] | ||
public float DistanceModifier; | ||
} |
37 changes: 37 additions & 0 deletions
37
Content.Server/DeltaV/StationEvents/Components/LoadFarGridRuleComponent.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,37 @@ | ||
/* | ||
* Delta-V - This file is licensed under AGPLv3 | ||
* Copyright (c) 2024 Delta-V Contributors | ||
* See AGPLv3.txt for details. | ||
*/ | ||
|
||
using Content.Server.StationEvents.Events; | ||
using Robust.Shared.Utility; | ||
|
||
namespace Content.Server.StationEvents.Components; | ||
|
||
/// <summary> | ||
/// Loads a grid far away from a random station. | ||
/// Requires <see cref="RuleGridsComponent"/>. | ||
/// </summary> | ||
[RegisterComponent, Access(typeof(LoadFarGridRule))] | ||
public sealed partial class LoadFarGridRuleComponent : Component | ||
{ | ||
/// <summary> | ||
/// Path to the grid to spawn. | ||
/// </summary> | ||
[DataField(required: true)] | ||
public ResPath Path = new(); | ||
|
||
/// <summary> | ||
/// Roughly how many AABBs away | ||
/// </summary> | ||
[DataField(required: true)] | ||
public float DistanceModifier; | ||
|
||
/// <summary> | ||
/// "Stations of Unusual Size Constant", derived from the AABB.Width of Shoukou. | ||
/// This Constant is used to check the size of a station relative to the reference point | ||
/// </summary> | ||
[DataField] | ||
public float Sousk = 123.44f; | ||
} |
37 changes: 0 additions & 37 deletions
37
Content.Server/DeltaV/StationEvents/Components/PirateRadioSpawnRuleComponent.cs
This file was deleted.
Oops, something went wrong.
71 changes: 71 additions & 0 deletions
71
Content.Server/DeltaV/StationEvents/Events/DebrisSpawnerRule.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,71 @@ | ||
/* | ||
* Delta-V - This file is licensed under AGPLv3 | ||
* Copyright (c) 2024 Delta-V Contributors | ||
* See AGPLv3.txt for details. | ||
*/ | ||
|
||
using Content.Server.GameTicking.Rules; | ||
using Content.Server.Station.Components; | ||
using Content.Server.StationEvents.Components; | ||
using Content.Shared.CCVar; | ||
using Content.Shared.Salvage; | ||
using Robust.Server.GameObjects; | ||
using Robust.Server.Maps; | ||
using Robust.Shared.Configuration; | ||
using Robust.Shared.Map; | ||
using Robust.Shared.Map.Components; | ||
using Robust.Shared.Prototypes; | ||
using Robust.Shared.Random; | ||
using System.Linq; | ||
|
||
namespace Content.Server.StationEvents.Events; | ||
|
||
public sealed class DebrisSpawnerRule : StationEventSystem<DebrisSpawnerRuleComponent> | ||
{ | ||
[Dependency] private readonly IConfigurationManager _config = default!; | ||
[Dependency] private readonly IPrototypeManager _proto = default!; | ||
[Dependency] private readonly MapLoaderSystem _mapLoader = default!; | ||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
|
||
SubscribeLocalEvent<DebrisSpawnerRuleComponent, RuleLoadedGridsEvent>(OnLoadedGrids); | ||
} | ||
|
||
private void OnLoadedGrids(Entity<DebrisSpawnerRuleComponent> ent, ref RuleLoadedGridsEvent args) | ||
{ | ||
if (_config.GetCVar<bool>(CCVars.WorldgenEnabled)) | ||
return; | ||
|
||
// get world AABBs of every grid that was loaded, probably just 1 anyway | ||
var boxes = new List<Box2>(args.Grids.Count); | ||
foreach (var gridId in args.Grids) | ||
{ | ||
var grid = Comp<MapGridComponent>(gridId); | ||
var aabb = Transform(gridId).WorldMatrix.TransformBox(grid.LocalAABB); | ||
boxes.Add(aabb); | ||
} | ||
|
||
// fetch all the salvage maps that can be picked | ||
var salvageMaps = _proto.EnumeratePrototypes<SalvageMapPrototype>().ToList(); | ||
|
||
// spawn them! | ||
for (var i = 0; i < ent.Comp.Count; i++) | ||
{ | ||
var aabb = RobustRandom.Pick(boxes); | ||
var dist = MathF.Max(aabb.Height / 2f, aabb.Width / 2f) * ent.Comp.DistanceModifier; | ||
|
||
var offset = RobustRandom.NextVector2(dist, dist * 2.5f); | ||
var randomer = RobustRandom.NextVector2(dist, dist * 5f); //Second random vector to ensure the outpost isn't perfectly centered in the debris field | ||
var options = new MapLoadOptions | ||
{ | ||
Offset = aabb.Center + offset + randomer, | ||
LoadMap = false, | ||
}; | ||
|
||
var salvage = RobustRandom.PickAndTake(salvageMaps); | ||
_mapLoader.Load(args.Map, salvage.MapPath.ToString(), options); | ||
} | ||
} | ||
} |
78 changes: 78 additions & 0 deletions
78
Content.Server/DeltaV/StationEvents/Events/LoadFarGridRule.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,78 @@ | ||
/* | ||
* Delta-V - This file is licensed under AGPLv3 | ||
* Copyright (c) 2024 Delta-V Contributors | ||
* See AGPLv3.txt for details. | ||
*/ | ||
|
||
using Content.Server.GameTicking.Components; | ||
using Content.Server.GameTicking.Rules; | ||
using Content.Server.Station.Components; | ||
using Content.Server.StationEvents.Components; | ||
using Robust.Server.GameObjects; | ||
using Robust.Server.Maps; | ||
using Robust.Shared.Map; | ||
using Robust.Shared.Map.Components; | ||
using Robust.Shared.Random; | ||
|
||
namespace Content.Server.StationEvents.Events; | ||
|
||
public sealed class LoadFarGridRule : StationEventSystem<LoadFarGridRuleComponent> | ||
{ | ||
[Dependency] private readonly MapLoaderSystem _mapLoader = default!; | ||
|
||
protected override void Added(EntityUid uid, LoadFarGridRuleComponent comp, GameRuleComponent rule, GameRuleAddedEvent args) | ||
{ | ||
base.Added(uid, comp, rule, args); | ||
|
||
if (!TryGetRandomStation(out var station) || !TryComp<StationDataComponent>(station, out var data)) | ||
{ | ||
Log.Error($"{ToPrettyString(uid):rule} failed to find a station!"); | ||
ForceEndSelf(uid, rule); | ||
return; | ||
} | ||
|
||
if (data.Grids.Count < 1) | ||
{ | ||
Log.Error($"{ToPrettyString(uid):rule} picked station {station} which had no grids!"); | ||
ForceEndSelf(uid, rule); | ||
return; | ||
} | ||
|
||
// get an AABB that contains all the station's grids | ||
var aabb = new Box2(); | ||
var map = MapId.Nullspace; | ||
foreach (var gridId in data.Grids) | ||
{ | ||
// use the first grid's map id | ||
if (map == MapId.Nullspace) | ||
map = Transform(gridId).MapID; | ||
|
||
var grid = Comp<MapGridComponent>(gridId); | ||
var gridAabb = Transform(gridId).WorldMatrix.TransformBox(grid.LocalAABB); | ||
aabb = aabb.Union(gridAabb); | ||
} | ||
|
||
var scale = comp.Sousk / aabb.Width; | ||
var modifier = comp.DistanceModifier * scale; | ||
var dist = MathF.Max(aabb.Height / 2f, aabb.Width / 2f) * modifier; | ||
var offset = RobustRandom.NextVector2(dist, dist * 2.5f); | ||
var options = new MapLoadOptions | ||
{ | ||
Offset = aabb.Center + offset, | ||
LoadMap = false | ||
}; | ||
|
||
var path = comp.Path.ToString(); | ||
Log.Debug($"Loading far grid {path} at {options.Offset}"); | ||
if (!_mapLoader.TryLoad(map, path, out var grids, options)) | ||
{ | ||
Log.Error($"{ToPrettyString(uid):rule} failed to load grid {path}!"); | ||
ForceEndSelf(uid, rule); | ||
return; | ||
} | ||
|
||
// let other systems do stuff | ||
var ev = new RuleLoadedGridsEvent(map, grids); | ||
RaiseLocalEvent(uid, ref ev); | ||
} | ||
} |
99 changes: 0 additions & 99 deletions
99
Content.Server/DeltaV/StationEvents/Events/PirateRadioSpawnRule.cs
This file was deleted.
Oops, something went wrong.
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.Shared.Roles; | ||
|
||
namespace Content.Server.Roles; | ||
|
||
/// <summary> | ||
/// DeltaV - listening post ops have their own role | ||
/// </summary> | ||
[RegisterComponent, ExclusiveAntagonist] | ||
public sealed partial class ListeningPostRoleComponent : AntagonistRoleComponent; |
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
1 change: 1 addition & 0 deletions
1
Resources/Locale/en-US/deltav/game-ticking/game-rules/rule-listening-post.ftl
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 @@ | ||
listening-post-round-end-agent-name = Listening Post Operative |
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
Oops, something went wrong.