Skip to content

Commit

Permalink
Listening Post 2.0 (#639)
Browse files Browse the repository at this point in the history
* updates map, lowers server volume

* Delete PLEASEWORKTHISTIMEIBEGYOUS14.yml

* Update DV-pirateradio.yml

* changes fax machine to *not* alert admins; and start with emagged by default instead of using VV

* Revert "changes fax machine to *not* alert admins; and start with emagged by default instead of using VV"

This reverts commit 05bb5f4.

* Revert "Update DV-pirateradio.yml"

This reverts commit e77fb34.

* Revert "Delete PLEASEWORKTHISTIMEIBEGYOUS14.yml"

This reverts commit 2000e2c.

* Revert "updates map, lowers server volume"

This reverts commit d99cab6.

* adds new syndicate fax, maps it in as well as other QOL changes

* adds cybersun pen to Syndicate PDA's

* Update DV-pirateradio.yml

* adds blacklist to CC Fax + quieter server

* Update PirateRadioSpawnRule.cs

* unfinished scuttling system

* Adding colorblind quality of life.

* Tweaks to map and guards, no more self destruct system

* added guard flavor text

* The reasons for these are now gone

* DONE

* Update events.yml

* Update PirateRadioSpawnRule.cs

* Update DV-pirateradio.yml

* fixes crew monitor server not working at *extreme* ranges

* adds delta-v comment where needed

* Small code optimization and tons of documentation

* Update outpost visuals! Guards have a PDA now

* Update DV-pirateradio.yml

* Update DV-pirateradio.yml

* Goodbye crab. Hello Content.Shared migration

* Cleaning up pirateradio spawn

* Update DV-pirateradio.yml

* reverts pen changes to upstream PDA's

* adds new PDA

* adds new PDA to loadouts.

* Update Resources/Prototypes/DeltaV/Entities/Mobs/NPCs/salvage.yml

Co-authored-by: Debug <[email protected]>
Signed-off-by: Danger Revolution! <[email protected]>

* Maintainer requested changes

* Update salvage.yml

* Update syndicateNPCs.yml

* Cleaning up unneeded stuff

* more code cleanup

* Update PirateRadioSpawnRule.cs

* Update computers.yml

* Revert "Update computers.yml"

This reverts commit cbd0c58.

* Last fixes to the math

* Update PirateRadioSpawnRule.cs

* update license.

---------

Signed-off-by: VMSolidus <[email protected]>
Signed-off-by: Danger Revolution! <[email protected]>
Co-authored-by: DangerRevoltion <[email protected]>
Co-authored-by: VMSolidus <[email protected]>
Co-authored-by: Debug <[email protected]>
  • Loading branch information
4 people authored Mar 8, 2024
1 parent 511b995 commit 2a195a6
Show file tree
Hide file tree
Showing 17 changed files with 4,007 additions and 3,774 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
/*
* 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.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;

namespace Content.Server.StationEvents.Components;

Expand All @@ -12,4 +16,21 @@ public sealed partial class PirateRadioSpawnRuleComponent : Component

[DataField("additionalRule")]
public EntityUid? AdditionalRule;

[DataField("debrisCount")]
public int DebrisCount { get; set; }

[DataField("distanceModifier")]
public float DistanceModifier { get; set; }

[DataField("debrisDistanceModifier")]
public float DebrisDistanceModifier { get; set; }

/// <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("sousk")]
public float SOUSK = 123.44f;

}
82 changes: 72 additions & 10 deletions Content.Server/DeltaV/StationEvents/Events/PirateRadioSpawnRule.cs
Original file line number Diff line number Diff line change
@@ -1,32 +1,94 @@
/*
* Delta-V - This file is licensed under AGPLv3
* Copyright (c) 2024 Delta-V Contributors
* See AGPLv3.txt for details.
*/

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 Robust.Shared.Utility;
using Content.Server.GameTicking;
using Content.Server.GameTicking.Rules;
using Content.Server.GameTicking.Rules.Components;
using Content.Server.StationEvents.Components;
using Content.Server.RoundEnd;
using Content.Server.Station.Components;
using Content.Shared.Salvage;
using Content.Shared.Random.Helpers;
using System.Linq;
using Content.Shared.CCVar;

namespace Content.Server.StationEvents.Events;

public sealed class PirateRadioSpawnRule : StationEventSystem<PirateRadioSpawnRuleComponent>
{
[Dependency] private readonly IEntityManager _entities = default!;
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly MapLoaderSystem _map = default!;
[Dependency] private readonly GameTicker _gameTicker = default!;
[Dependency] private readonly TraitorRuleSystem _TraitorRuleSystem = default!;
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IConfigurationManager _confMan = default!;

protected override void Started(EntityUid uid, PirateRadioSpawnRuleComponent component, GameRuleComponent gameRule, GameRuleStartedEvent args)
{
//Start of Syndicate Listening Outpost spawning system
base.Started(uid, component, gameRule, args);

var shuttleMap = _mapManager.CreateMap();
var options = new MapLoadOptions
var xformQuery = GetEntityQuery<TransformComponent>();
var aabbs = EntityQuery<StationDataComponent>().SelectMany(x =>
x.Grids.Select(x =>
xformQuery.GetComponent(x).WorldMatrix.TransformBox(_mapManager.GetGridComp(x).LocalAABB)))
.ToArray();
if (aabbs.Length < 1) return;
var aabb = aabbs[0];

for (var i = 1; i < aabbs.Length; i++)
{
aabb.Union(aabbs[i]);
}
var distanceFactorCoefficient = component.SOUSK / aabb.Width;
var distanceModifier = Math.Clamp(component.DistanceModifier, 1, 25);
var distanceModifierNormalized = distanceModifier * distanceFactorCoefficient;
var a = MathF.Max(aabb.Height / 2f, aabb.Width / 2f) * distanceModifierNormalized;
var randomoffset = _random.NextVector2(a, a * 2.5f);
var outpostOptions = new MapLoadOptions
{
LoadMap = true,
Offset = aabb.Center + randomoffset,
LoadMap = false,
};
if (!_map.TryLoad(GameTicker.DefaultMap, component.PirateRadioShuttlePath, out var outpostids, outpostOptions)) return;
//End of Syndicate Listening Outpost spawning system

//Start of Debris Field Generation
var debrisSpawner = _confMan.GetCVar<bool>(CCVars.WorldgenEnabled);
if (debrisSpawner == true) return;
var debrisCount = Math.Clamp(component.DebrisCount, 0, 6);
if (debrisCount == 0) return;
var debrisDistanceModifier = Math.Clamp(component.DebrisDistanceModifier, 3, 10);
foreach (var id in outpostids)
{
if (!TryComp<MapGridComponent>(id, out var grid)) return;
var outpostaabb = _entities.GetComponent<TransformComponent>(id).WorldMatrix.TransformBox(grid.LocalAABB);
var b = MathF.Max(outpostaabb.Height / 2f, aabb.Width / 2f) * debrisDistanceModifier;
var k = 1;
while (k < debrisCount + 1)
{
var debrisRandomOffset = _random.NextVector2(b, b * 2.5f);
var randomer = _random.NextVector2(b, b * 5f); //Second random vector to ensure the outpost isn't perfectly centered in the debris field
var debrisOptions = new MapLoadOptions
{
Offset = outpostaabb.Center + debrisRandomOffset + randomer,
LoadMap = false,
};

_map.TryLoad(shuttleMap, component.PirateRadioShuttlePath, out _, options);
var salvageProto = _random.Pick(_prototypeManager.EnumeratePrototypes<SalvageMapPrototype>().ToList());
_map.TryLoad(GameTicker.DefaultMap, salvageProto.MapPath.ToString(), out _, debrisOptions);
k++;
}
}
//End of Debris Field generation
}

protected override void Ended(EntityUid uid, PirateRadioSpawnRuleComponent component, GameRuleComponent gameRule, GameRuleEndedEvent args)
Expand All @@ -36,4 +98,4 @@ protected override void Ended(EntityUid uid, PirateRadioSpawnRuleComponent compo
if (component.AdditionalRule != null)
GameTicker.EndGameRule(component.AdditionalRule.Value);
}
}
}
Loading

0 comments on commit 2a195a6

Please sign in to comment.