ECS Arcade Machines (#16791)

This commit is contained in:
TemporalOroboros
2023-06-15 04:25:25 -07:00
committed by GitHub
parent b72ab3b00c
commit bc3f42d822
23 changed files with 2116 additions and 1521 deletions

View File

@@ -1,5 +1,4 @@
using System.Linq;
using Content.Server.Arcade.Components;
using Content.Server.UserInterface;
using Content.Shared.Arcade;
using Robust.Shared.Utility;
@@ -17,25 +16,6 @@ namespace Content.Server.Arcade
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<BlockGameArcadeComponent, AfterActivatableUIOpenEvent>(OnAfterUIOpen);
SubscribeLocalEvent<SpaceVillainArcadeComponent, AfterActivatableUIOpenEvent>(OnAfterUIOpenSV);
SubscribeLocalEvent<BlockGameArcadeComponent, BoundUIClosedEvent>((_,c,args) => c.UnRegisterPlayerSession((IPlayerSession)args.Session));
InitializeBlockGame();
InitializeSpaceVillain();
}
private void OnAfterUIOpen(EntityUid uid, BlockGameArcadeComponent component, AfterActivatableUIOpenEvent args)
{
var actor = Comp<ActorComponent>(args.User);
if (component.UserInterface?.SessionHasOpen(actor.PlayerSession) == true)
{
component.RegisterPlayerSession(actor.PlayerSession);
}
}
private void OnAfterUIOpenSV(EntityUid uid, SpaceVillainArcadeComponent component, AfterActivatableUIOpenEvent args)
{
component.Game ??= new SpaceVillainArcadeComponent.SpaceVillainGame(component);
}
public HighScorePlacement RegisterHighScore(string name, int score)
@@ -87,14 +67,6 @@ namespace Content.Server.Arcade
return placement;
}
public override void Update(float frameTime)
{
foreach (var comp in EntityManager.EntityQuery<BlockGameArcadeComponent>())
{
comp.DoGameTick(frameTime);
}
}
public readonly struct HighScorePlacement
{
public readonly int? GlobalPlacement;