Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gamemode: Planetary Warfare #13

Merged
merged 3 commits into from
Jan 12, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Content.Server/_WH14K/Altar/AltarComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@


namespace Content.Server._WH14K.Altar;

[RegisterComponent]
public sealed partial class AltarComponent : Component
{
// TODO: Это бред полнейший, нужно переделать как-нибудь
mam0nt222 marked this conversation as resolved.
Show resolved Hide resolved
[DataField]
public bool Exploded = false;
}
18 changes: 18 additions & 0 deletions Content.Server/_WH14K/Altar/AltarSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using Content.Server._WH14K.GameTicking.Rules;

namespace Content.Server._WH14K.Altar;

public sealed partial class AltarSystem : EntitySystem
{
[Dependency] private readonly PlanetaryWarfareRuleSystem _pw = default!;
public override void Initialize()
{
base.Initialize();
}

public void AltarExploded(AltarComponent component)
{
component.Exploded = true;
_pw.CheckRoundShouldEnd();
}
mam0nt222 marked this conversation as resolved.
Show resolved Hide resolved
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@


namespace Content.Server._WH14K.GameTicking.Rules;

[RegisterComponent]
public sealed partial class IGCommandComponent : Component
mam0nt222 marked this conversation as resolved.
Show resolved Hide resolved
{

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@


mam0nt222 marked this conversation as resolved.
Show resolved Hide resolved
namespace Content.Server._WH14K.GameTicking.Rules;

[RegisterComponent, Access(typeof(PlanetaryWarfareRuleSystem))]
public sealed partial class PlanetaryWarfareRuleComponent : Component
{
[DataField]
public WinTypePW WinTypePW = WinTypePW.Neutral;
}

public enum WinTypePW : byte
{
AllCommandDead,
WarpShtormSummoned,
Neutral,
AllAltarExploded
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
using Content.Server.Antag;
using Content.Server.Communications;
using Content.Server.GameTicking;
using Content.Server.GameTicking.Rules;
using Content.Server.RoundEnd;
using Content.Server.GameTicking.Rules.Components;
using Content.Server.Popups;
using Content.Server._WH14K.WarpShtorm;
using Content.Server._WH14K.Altar;
using Content.Shared.Mobs;
using Content.Shared.Mobs.Components;
using Content.Shared.GameTicking.Components;
using Robust.Shared.Utility;
using Robust.Shared.Map.Components;
using Content.Shared.Mind;
using Robust.Server.Player;

namespace Content.Server._WH14K.GameTicking.Rules;

public sealed partial class PlanetaryWarfareRuleSystem : GameRuleSystem<PlanetaryWarfareRuleComponent>
{
[Dependency] private readonly RoundEndSystem _roundEndSystem = default!;
[Dependency] private readonly IPlayerManager _player = default!;
public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<IGCommandComponent, ComponentRemove>(OnComponentRemove);
SubscribeLocalEvent<IGCommandComponent, MobStateChangedEvent>(OnMobStateChanged);
}

protected override void AppendRoundEndText(EntityUid uid, PlanetaryWarfareRuleComponent component, GameRuleComponent gameRule, ref RoundEndTextAppendEvent args)
{
if (component.WinTypePW == WinTypePW.WarpShtormSummoned || component.WinTypePW == WinTypePW.AllCommandDead)
args.AddLine(Loc.GetString("pw-chaos-win"));

else if (component.WinTypePW == WinTypePW.AllAltarExploded)
args.AddLine(Loc.GetString("pw-ig-win"));

if (component.WinTypePW == WinTypePW.AllCommandDead)
args.AddLine(Loc.GetString("pw-all-command-dead-desc"));

else if (component.WinTypePW == WinTypePW.AllAltarExploded)
args.AddLine(Loc.GetString("pw-all-altars-exploded-desc"));

else if (component.WinTypePW == WinTypePW.WarpShtormSummoned)
args.AddLine(Loc.GetString("pw-all-warp-shtorm-summoned-desc"));
mam0nt222 marked this conversation as resolved.
Show resolved Hide resolved

var IG = EntityQuery<IGCommandComponent, MindComponent>(true);
mam0nt222 marked this conversation as resolved.
Show resolved Hide resolved
foreach (var i in IG)
mam0nt222 marked this conversation as resolved.
Show resolved Hide resolved
{
if (i.Item2 == null || i.Item2.CharacterName == null || i.Item2.OriginalOwnerUserId == null )
mam0nt222 marked this conversation as resolved.
Show resolved Hide resolved
return;

_player.TryGetPlayerData(i.Item2.OriginalOwnerUserId.Value, out var data);

if (data == null)
return;
args.AddLine(Loc.GetString("ig-command-list-start"));

args.AddLine(Loc.GetString("ig-command-list-name-user", ("name", i.Item2.CharacterName), ("user", data.UserName)));
}
}

private void OnComponentRemove(EntityUid uid, IGCommandComponent component, ComponentRemove args)
{
CheckRoundShouldEnd();
}

private void OnMobStateChanged(EntityUid uid, IGCommandComponent component, MobStateChangedEvent ev)
{
if (ev.NewMobState == MobState.Dead)
CheckRoundShouldEnd();
}

public void CheckRoundShouldEnd()
{
var query = QueryActiveRules();
while (query.MoveNext(out var uid, out _, out var pw, out _))
{
AllCommandDead((uid, pw));
AllAltarExploded((uid, pw));
OnWarpShtormSummoned((uid, pw));
mam0nt222 marked this conversation as resolved.
Show resolved Hide resolved
}
}

private void AllCommandDead(Entity<PlanetaryWarfareRuleComponent> ent)
{
var IG = EntityQuery<IGCommandComponent, MobStateComponent>(true);

foreach (var i in IG)
mam0nt222 marked this conversation as resolved.
Show resolved Hide resolved
{
if (i.Item2.CurrentState == MobState.Alive)
{
return;
}
}

ent.Comp.WinTypePW = WinTypePW.AllCommandDead;
_roundEndSystem.EndRound();
}

private void AllAltarExploded(Entity<PlanetaryWarfareRuleComponent> ent)
{
var Altar = EntityQuery<AltarComponent>(true);
mam0nt222 marked this conversation as resolved.
Show resolved Hide resolved

foreach (var a in Altar)
mam0nt222 marked this conversation as resolved.
Show resolved Hide resolved
{
if (!a.Exploded)
{
return;
}
}

ent.Comp.WinTypePW = WinTypePW.AllAltarExploded;
_roundEndSystem.EndRound();
}

private void OnWarpShtormSummoned(Entity<PlanetaryWarfareRuleComponent> ent)
mam0nt222 marked this conversation as resolved.
Show resolved Hide resolved
{
var WarpShtorm = EntityQuery<WarpShtormComponent>();
mam0nt222 marked this conversation as resolved.
Show resolved Hide resolved
foreach (var ws in WarpShtorm)
mam0nt222 marked this conversation as resolved.
Show resolved Hide resolved
{
var mapQuery = EntityQueryEnumerator<MapLightComponent>();
while (mapQuery.MoveNext(out var uid, out var map))
{
map.AmbientLightColor = Color.FromHex("#e82a2a");
Dirty(uid, map);
}

ent.Comp.WinTypePW = WinTypePW.WarpShtormSummoned;
_roundEndSystem.EndRound();
}
}
}
8 changes: 8 additions & 0 deletions Content.Server/_WH14K/WarpShtorm/WarpShtormComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@


namespace Content.Server._WH14K.WarpShtorm;

[RegisterComponent]
public sealed partial class WarpShtormComponent : Component
mam0nt222 marked this conversation as resolved.
Show resolved Hide resolved
{
}
17 changes: 17 additions & 0 deletions Content.Server/_WH14K/WarpShtorm/WarpShtormSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using Content.Server._WH14K.GameTicking.Rules;

namespace Content.Server._WH14K.WarpShtorm;

public sealed partial class WarpShtormSystem : EntitySystem
mam0nt222 marked this conversation as resolved.
Show resolved Hide resolved
{
[Dependency] private readonly PlanetaryWarfareRuleSystem _pw = default!;
public override void Initialize()
{
base.Initialize();
}

private void Summon()
{
_pw.CheckRoundShouldEnd();
}
}
11 changes: 11 additions & 0 deletions Resources/Locale/en-US/_WH14K/pw.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
pw-title = Планетарное Сражение
pw-description = режим

pw-ig-win = [color=gold][font size=16][bold]Победа Империума[/bold][/font][/color]
pw-chaos-win = [color=#9B2D30][font size=16][bold]Победа Хаоса[/bold][/font][/color]

pw-all-command-dead-desc = Хаос смог захватить крейсер Имперской Гвардии, что вкупе с орудиями планетарной обороны позволит еретикам укрепить свое влияние в секторе.
pw-all-altars-exploded-desc = Силы Империума сумели уничтожить все алтари Темных Богов, предотвратив Варп-Шторм. Это спасло миллиарды жизней, но это только одна из тысяч планет под угрозой.
pw-all-warp-shtorm-summoned-desc = Катастрофа космического масштаба, разразившаяся в центре этой планеты, погубила триллионы жизней

ig-command-list-start = Командирами Империума были:
5 changes: 5 additions & 0 deletions Resources/Prototypes/_WH14K/GameRules/roundstart.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
- type: entity
parent: BaseGameRule
id: PlanetaryWarfareRule
components:
- type: PlanetaryWarfareRule
7 changes: 7 additions & 0 deletions Resources/Prototypes/_WH14K/game_presets.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
- type: gamePreset
id: PlanetaryWarfare
name: pw-title
showInVote: true
description: pw-description
rules:
- PlanetaryWarfareRule