delete outdated game rules

This commit is contained in:
Ed
2025-09-23 20:37:17 +03:00
parent a9d0551323
commit b028d711fe
14 changed files with 14 additions and 606 deletions

View File

@@ -1,114 +0,0 @@
using System.Linq;
using Content.Server._CP14.GameTicking.Rules.Components;
using Content.Server.Antag;
using Content.Server.Chat.Systems;
using Content.Server.GameTicking.Rules;
using Content.Server.Popups;
using Content.Server.Station.Components;
using Content.Server.Stunnable;
using Content.Shared._CP14.BloodMoon;
using Content.Shared._CP14.DayCycle;
using Content.Shared.Actions;
using Content.Shared.Examine;
using Content.Shared.GameTicking.Components;
using Content.Shared.Mobs;
using Content.Shared.Popups;
using Robust.Server.GameObjects;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Player;
namespace Content.Server._CP14.GameTicking.Rules;
public sealed class CP14BloodMoonCurseRule : GameRuleSystem<CP14BloodMoonCurseRuleComponent>
{
[Dependency] private readonly AntagSelectionSystem _antag = default!;
[Dependency] private readonly StunSystem _stun = default!;
[Dependency] private readonly PopupSystem _popup = default!;
[Dependency] private readonly ChatSystem _chatSystem = default!;
[Dependency] private readonly TransformSystem _transform = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly SharedActionsSystem _action = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<CP14StartDayEvent>(OnStartDay);
SubscribeLocalEvent<CP14BloodMoonCurseRuleComponent, AfterAntagEntitySelectedEvent>(AfterAntagEntitySelected);
SubscribeLocalEvent<CP14BloodMoonCurseComponent, ExaminedEvent>(CurseExamined);
}
private void CurseExamined(Entity<CP14BloodMoonCurseComponent> ent, ref ExaminedEvent args)
{
args.PushMarkup(Loc.GetString("cp14-bloodmoon-curse-examined"));
}
private void AfterAntagEntitySelected(Entity<CP14BloodMoonCurseRuleComponent> ent, ref AfterAntagEntitySelectedEvent args)
{
SpawnAttachedTo(ent.Comp.CurseEffect, Transform(args.EntityUid).Coordinates);
var curseComp = EnsureComp<CP14BloodMoonCurseComponent>(args.EntityUid);
var effect = SpawnAttachedTo(curseComp.CurseEffect, Transform(args.EntityUid).Coordinates);
curseComp.SpawnedEffect = effect;
curseComp.CurseRule = ent;
_transform.SetParent(effect, args.EntityUid);
_action.AddAction(args.EntityUid, ref curseComp.ActionEntity, curseComp.Action);
}
protected override void Started(EntityUid uid,
CP14BloodMoonCurseRuleComponent component,
GameRuleComponent gameRule,
GameRuleStartedEvent args)
{
Filter allPlayersInGame = Filter.Empty().AddWhere(GameTicker.UserHasJoinedGame);
_chatSystem.DispatchFilteredAnnouncement(allPlayersInGame, Loc.GetString(component.StartAnnouncement), colorOverride: component.AnnouncementColor);
_audio.PlayGlobal(component.GlobalSound, allPlayersInGame, true);
}
protected override void Ended(EntityUid uid,
CP14BloodMoonCurseRuleComponent component,
GameRuleComponent gameRule,
GameRuleEndedEvent args)
{
Filter allPlayersInGame = Filter.Empty().AddWhere(GameTicker.UserHasJoinedGame);
_chatSystem.DispatchFilteredAnnouncement(allPlayersInGame, Loc.GetString(component.EndAnnouncement), colorOverride: component.AnnouncementColor);
var aliveAntags = _antag.GetAliveAntags(uid);
foreach (var antag in aliveAntags)
{
SpawnAttachedTo(component.CurseEffect, Transform(antag).Coordinates);
ClearCurse(antag);
}
GameTicker.EndRound();
}
private void OnStartDay(CP14StartDayEvent ev)
{
if (!HasComp<BecomesStationComponent>(ev.Map))
return;
var query = QueryActiveRules();
while (query.MoveNext(out var uid, out _, out var comp, out _))
{
ForceEndSelf(uid);
}
}
private void ClearCurse(Entity<CP14BloodMoonCurseComponent?> ent)
{
if (!Resolve(ent.Owner, ref ent.Comp, false))
return;
_stun.TryUpdateParalyzeDuration(ent, ent.Comp.EndStunDuration);
_popup.PopupEntity(Loc.GetString("cp14-bloodmoon-curse-removed"), ent, PopupType.SmallCaution);
if (TryComp<CP14BloodMoonCurseComponent>(ent, out var curseComp))
{
QueueDel(curseComp.SpawnedEffect);
RemCompDeferred<CP14BloodMoonCurseComponent>(ent);
}
_action.RemoveAction(ent.Comp.ActionEntity);
}
}

View File

@@ -1,54 +0,0 @@
using Content.Server._CP14.GameTicking.Rules.Components;
using Content.Server.Chat.Systems;
using Content.Server.GameTicking.Rules;
using Content.Server.Station.Components;
using Content.Server.StationEvents.Events;
using Content.Shared._CP14.DayCycle;
using Content.Shared.GameTicking.Components;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Player;
namespace Content.Server._CP14.GameTicking.Rules;
public sealed class CP14BloodMoonRule : GameRuleSystem<CP14BloodMoonRuleComponent>
{
[Dependency] private readonly ChatSystem _chatSystem = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<CP14StartNightEvent>(OnStartNight);
}
protected override void Started(EntityUid uid,
CP14BloodMoonRuleComponent component,
GameRuleComponent gameRule,
GameRuleStartedEvent args)
{
base.Started(uid, component, gameRule, args);
Filter allPlayersInGame = Filter.Empty().AddWhere(GameTicker.UserHasJoinedGame);
_chatSystem.DispatchFilteredAnnouncement(
allPlayersInGame,
message: Loc.GetString(component.StartAnnouncement),
colorOverride: component.AnnouncementColor);
_audio.PlayGlobal(component.AnnounceSound, allPlayersInGame, true);
}
private void OnStartNight(CP14StartNightEvent ev)
{
if (!HasComp<BecomesStationComponent>(ev.Map))
return;
var query = QueryActiveRules();
while (query.MoveNext(out var uid, out _, out var comp, out _))
{
var ruleEnt = GameTicker.AddGameRule(comp.CurseRule);
GameTicker.StartGameRule(ruleEnt);
ForceEndSelf(uid);
}
}
}

View File

@@ -1,112 +0,0 @@
using System.Linq;
using Content.Server._CP14.GameTicking.Rules.Components;
using Content.Server.GameTicking.Rules;
using Content.Server.Shuttles.Events;
using Content.Server.Station.Components;
using Content.Server.Station.Systems;
using Content.Shared.GameTicking.Components;
using Content.Shared.Station.Components;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
using Robust.Shared.Timing;
namespace Content.Server._CP14.GameTicking.Rules;
public sealed class CP14CrashingShipRule : GameRuleSystem<CP14CrashingShipRuleComponent>
{
[Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly ILogManager _logManager = default!;
[Dependency] private readonly StationSystem _station = default!;
[Dependency] private readonly IRobustRandom _random = default!;
private ISawmill _sawmill = default!;
public override void Initialize()
{
base.Initialize();
_sawmill = _logManager.GetSawmill("cp14_crashing_ship_rule");
SubscribeLocalEvent<CP14CrashingShipComponent, FTLCompletedEvent>(OnFTLCompleted);
}
public override void Update(float frameTime)
{
base.Update(frameTime);
UpdateExplosions(frameTime);
}
protected override void Started(EntityUid uid,
CP14CrashingShipRuleComponent component,
GameRuleComponent gameRule,
GameRuleStartedEvent args)
{
base.Started(uid, component, gameRule, args);
var station = _station.GetStations().First();
var largestStationGrid = _station.GetLargestGrid(station);
if (largestStationGrid is null)
{
_sawmill.Error($"Station {station} does not have a grid.");
return;
}
component.StartExplosionTime += _timing.CurTime;
component.Ship = largestStationGrid.Value;
}
private void OnFTLCompleted(Entity<CP14CrashingShipComponent> ent, ref FTLCompletedEvent args)
{
SpawnRandomExplosion(ent, ent.Comp.FinalExplosionProto, 10);
RemCompDeferred<CP14CrashingShipComponent>(ent);
}
private void UpdateExplosions(float frameTime)
{
var ruleQuery = EntityQueryEnumerator<CP14CrashingShipRuleComponent>();
while (ruleQuery.MoveNext(out var uid, out var rule))
{
if (!rule.PendingExplosions)
continue;
if (_timing.CurTime < rule.StartExplosionTime)
continue;
if (rule.Ship is null)
continue;
AddComp<CP14CrashingShipComponent>(rule.Ship.Value);
rule.PendingExplosions = false;
}
var query = EntityQueryEnumerator<CP14CrashingShipComponent>();
while (query.MoveNext(out var uid, out var ship))
{
if (_timing.CurTime < ship.NextExplosionTime)
continue;
ship.NextExplosionTime = _timing.CurTime + TimeSpan.FromSeconds(_random.Next(2, 10));
SpawnRandomExplosion((uid, ship), ship.ExplosionProto, 1);
}
}
private void SpawnRandomExplosion(Entity<CP14CrashingShipComponent> grid, EntProtoId explosionProto, int count)
{
var station = _station.GetOwningStation(grid);
if (station is null)
return;
TryFindRandomTileOnStation((station.Value, Comp<StationDataComponent>(station.Value)),
out var tile,
out var targetGrid,
out var targetCoords);
for (var i = 0; i < count; i++)
{
Spawn(explosionProto, targetCoords);
}
}
}

View File

@@ -1,54 +0,0 @@
using System.Linq;
using System.Numerics;
using Content.Server._CP14.GameTicking.Rules.Components;
using Content.Server._CP14.Procedural;
using Content.Server.GameTicking.Rules;
using Content.Server.Shuttles.Components;
using Content.Server.Shuttles.Systems;
using Content.Server.Station.Systems;
using Content.Shared.GameTicking.Components;
using Content.Shared.Station.Components;
using Robust.Shared.Map;
namespace Content.Server._CP14.GameTicking.Rules;
public sealed class CP14ExpeditionToWindlandsRule : GameRuleSystem<CP14ExpeditionToWindlandsRuleComponent>
{
[Dependency] private readonly ShuttleSystem _shuttles = default!;
[Dependency] private readonly StationSystem _station = default!;
[Dependency] private readonly ILogManager _logManager = default!;
[Dependency] private readonly SharedMapSystem _mapSystem = default!;
[Dependency] private readonly CP14LocationGenerationSystem _generation = default!;
private ISawmill _sawmill = default!;
public override void Initialize()
{
base.Initialize();
_sawmill = _logManager.GetSawmill("cp14_expedition_to_windlands_rule");
}
protected override void Started(EntityUid uid,
CP14ExpeditionToWindlandsRuleComponent component,
GameRuleComponent gameRule,
GameRuleStartedEvent args)
{
base.Started(uid, component, gameRule, args);
var station = _station.GetStations().First();
var largestStationGrid = _station.GetLargestGrid(station);
if (largestStationGrid is null)
{
_sawmill.Error($"Station {station} does not have a grid.");
return;
}
EnsureComp<ShuttleComponent>(largestStationGrid.Value, out var shuttleComp);
var windlands = _mapSystem.CreateMap(out var mapId, runMapInit: true);
_generation.GenerateLocation(windlands, mapId, component.Location, component.Modifiers);
_shuttles.FTLToCoordinates(largestStationGrid.Value, shuttleComp, new EntityCoordinates(windlands, Vector2.Zero), 0f, 0f, component.FloatingTime);
}
}

View File

@@ -1,58 +0,0 @@
using Content.Server._CP14.GameTicking.Rules.Components;
using Content.Server._CP14.WeatherControl;
using Content.Server.GameTicking.Rules;
using Content.Server.Station.Components;
using Content.Server.Station.Systems;
using Content.Server.StationEvents.Events;
using Content.Server.Weather;
using Content.Shared.GameTicking.Components;
using Content.Shared.Station.Components;
using Robust.Shared.Map.Components;
using Robust.Shared.Prototypes;
using Robust.Shared.Timing;
namespace Content.Server._CP14.GameTicking.Rules;
public sealed class CP14WeatherRule : StationEventSystem<CP14WeatherRuleComponent>
{
[Dependency] private readonly WeatherSystem _weather = default!;
[Dependency] private readonly StationSystem _station = default!;
[Dependency] private readonly IPrototypeManager _proto = default!;
[Dependency] private readonly IGameTiming _timing = default!;
protected override void Started(EntityUid uid, CP14WeatherRuleComponent component, GameRuleComponent gameRule, GameRuleStartedEvent args)
{
base.Started(uid, component, gameRule, args);
var query = EntityQueryEnumerator<MapComponent, BecomesStationComponent>();
while (query.MoveNext(out var mapUid, out var map, out var station))
{
if (!_proto.TryIndex(component.Weather, out var indexedWeather))
continue;
if (TryComp<CP14WeatherControllerComponent>(mapUid, out var controller))
{
controller.Enabled = false;
}
_weather.SetWeather(map.MapId, indexedWeather, null);
}
}
protected override void Ended(EntityUid uid, CP14WeatherRuleComponent component, GameRuleComponent gameRule, GameRuleEndedEvent args)
{
base.Ended(uid, component, gameRule, args);
var query = EntityQueryEnumerator<MapComponent, BecomesStationComponent>();
while (query.MoveNext(out var mapUid, out var map, out var station))
{
if (TryComp<CP14WeatherControllerComponent>(mapUid, out var controller))
{
controller.NextWeatherTime = _timing.CurTime;
controller.Enabled = true;
}
_weather.SetWeather(map.MapId, null, null);
}
}
}

View File

@@ -1,26 +0,0 @@
using Robust.Shared.Audio;
using Robust.Shared.Prototypes;
namespace Content.Server._CP14.GameTicking.Rules.Components;
[RegisterComponent, Access(typeof(CP14BloodMoonCurseRule))]
public sealed partial class CP14BloodMoonCurseRuleComponent : Component
{
[DataField]
public LocId StartAnnouncement = "cp14-bloodmoon-start";
[DataField]
public LocId EndAnnouncement = "cp14-bloodmoon-end";
[DataField]
public Color? AnnouncementColor;
[DataField]
public EntProtoId CurseEffect = "CP14ImpactEffectMagicSplitting";
[DataField]
public SoundSpecifier GlobalSound = new SoundPathSpecifier("/Audio/_CP14/Ambience/blood_moon_raise.ogg")
{
Params = AudioParams.Default.WithVolume(-2f)
};
}

View File

@@ -1,20 +0,0 @@
using Robust.Shared.Audio;
using Robust.Shared.Prototypes;
namespace Content.Server._CP14.GameTicking.Rules.Components;
[RegisterComponent, Access(typeof(CP14BloodMoonRule))]
public sealed partial class CP14BloodMoonRuleComponent : Component
{
[DataField]
public EntProtoId CurseRule = "CP14BloodMoonCurseRule";
[DataField]
public LocId StartAnnouncement = "cp14-bloodmoon-raising";
[DataField]
public Color? AnnouncementColor = Color.FromHex("#e32759");
[DataField]
public SoundSpecifier? AnnounceSound;
}

View File

@@ -1,19 +0,0 @@
using Robust.Shared.Prototypes;
namespace Content.Server._CP14.GameTicking.Rules.Components;
/// <summary>
///When attached to shuttle, start firebombing it until FTL ends.
/// </summary>
[RegisterComponent, Access(typeof(CP14CrashingShipRule))]
public sealed partial class CP14CrashingShipComponent : Component
{
[DataField]
public TimeSpan NextExplosionTime = TimeSpan.Zero;
[DataField]
public EntProtoId ExplosionProto = "CP14ShipExplosion";
[DataField]
public EntProtoId FinalExplosionProto = "CP14ShipExplosionBig";
}

View File

@@ -1,17 +0,0 @@
namespace Content.Server._CP14.GameTicking.Rules.Components;
/// <summary>
/// A rule that assigns common goals to different roles. Common objectives are generated once at the beginning of a round and are shared between players.
/// </summary>
[RegisterComponent, Access(typeof(CP14CrashingShipRule))]
public sealed partial class CP14CrashingShipRuleComponent : Component
{
[DataField]
public EntityUid? Ship;
[DataField]
public bool PendingExplosions = true;
[DataField]
public TimeSpan StartExplosionTime = TimeSpan.FromMinutes(1);
}

View File

@@ -1,20 +0,0 @@
using Content.Shared._CP14.Procedural.Prototypes;
using Robust.Shared.Prototypes;
namespace Content.Server._CP14.GameTicking.Rules.Components;
/// <summary>
/// A rule that assigns common goals to different roles. Common objectives are generated once at the beginning of a round and are shared between players.
/// </summary>
[RegisterComponent, Access(typeof(CP14ExpeditionToWindlandsRule))]
public sealed partial class CP14ExpeditionToWindlandsRuleComponent : Component
{
[DataField]
public ProtoId<CP14ProceduralLocationPrototype> Location = "T1GrasslandIsland";
[DataField]
public List<ProtoId<CP14ProceduralModifierPrototype>> Modifiers = [];
[DataField]
public float FloatingTime = 120;
}

View File

@@ -1,11 +0,0 @@
using Content.Shared.Weather;
using Robust.Shared.Prototypes;
namespace Content.Server._CP14.GameTicking.Rules.Components;
[RegisterComponent]
public sealed partial class CP14WeatherRuleComponent : Component
{
[DataField(required: true)]
public ProtoId<WeatherPrototype> Weather = default!;
}

View File

@@ -17,25 +17,3 @@
delay:
min: 40
max: 60
- type: entityTable
id: CP14BasicCalmEventsTable
table: !type:AllSelector
children:
- id: CP14Storm
- type: entity
parent: CP14BaseStationEventLongDelay
id: CP14Storm
components:
- type: StationEvent
startAnnouncement: cp14-event-announcement-storm
startAudio:
collection: CP14LightningFar
earliestStart: 45
minimumPlayers: 10
duration: 180
maxDuration: 600
- type: CP14WeatherRule
weather: CP14Storm

View File

@@ -1,34 +0,0 @@
- type: entity
id: CP14BloodMoonRule
parent: CP14BaseGameRule
components:
- type: CP14BloodMoonRule
curseRule: CP14BloodMoonCurseRule
announceSound:
path: /Audio/_CP14/Announce/darkness_boom.ogg
- type: GameRule
delay:
min: 30
max: 60
- type: entity
id: CP14BloodMoonCurseRule
parent: CP14BaseGameRule
components:
- type: CP14BloodMoonCurseRule
announcementColor: "#e32759"
- type: AntagSelection
definitions:
- prefRoles: [ CP14BloodMoonCursed ]
max: 15
playerRatio: 2
multiAntagSetting: NotExclusive
lateJoinAdditional: true
allowNonHumans: true
mindRoles:
- CP14MindRoleBloodMoonCursed
briefing:
text: cp14-roles-antag-blood-moon-cursed-briefing
color: "#630f24"
sound: "/Audio/_CP14/Announce/darkness_boom_2.ogg"

View File

@@ -6,51 +6,20 @@
- type: GameRule
cP14Allowed: true
- type: entity
id: CP14RoundObjectivesRule
parent: CP14BaseGameRule
components:
- type: CP14PersonalObjectivesRule
roleObjectives:
CP14Adventurer:
- CP14PersonalCurrencyCollectObjectiveGroup
CP14Alchemist:
- CP14PersonalCurrencyCollectObjectiveGroup
CP14Apprentice:
- CP14PersonalCurrencyCollectObjectiveGroup
CP14Blacksmith:
- CP14PersonalCurrencyCollectObjectiveGroup
CP14Innkeeper:
- CP14PersonalCurrencyCollectObjectiveGroup
# crashing
#- type: entity
# id: CP14CrashToWindlandsRule
# parent: CP14BaseGameRule
# components:
# - type: CP14CrashingShipRule
# - type: CP14ExpeditionToWindlandsRule
# modifiers:
# - WeatherInfinityStorm
# - MapLightCycleDefault
# - Ruins
# - Geodes
# event schedulers
- type: entity
id: CP14BasicStationEventScheduler
parent: CP14BaseGameRule
components:
- type: BasicStationEventScheduler
scheduledGameRules: !type:NestedSelector
tableId: CP14BasicGameRulesTable
- type: entityTable
id: CP14BasicGameRulesTable
table: !type:AllSelector
children:
- !type:NestedSelector
tableId: CP14BasicCalmEventsTable
#- type: entity
# id: CP14BasicStationEventScheduler
# parent: CP14BaseGameRule
# components:
# - type: BasicStationEventScheduler
# scheduledGameRules: !type:NestedSelector
# tableId: CP14BasicGameRulesTable
#
#- type: entityTable
# id: CP14BasicGameRulesTable
# table: !type:AllSelector
# children:
# - !type:NestedSelector
# tableId: CP14BasicCalmEventsTable