Use IGridAtmosphereComponent interface in AtmosphereSystem

This commit is contained in:
Víctor Aguilera Puerto
2020-08-04 15:42:24 +02:00
parent a8fcaf9bb3
commit 4546fffe70

View File

@@ -1,6 +1,7 @@
#nullable enable #nullable enable
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Content.Server.Atmos;
using Content.Server.GameObjects.Components.Atmos; using Content.Server.GameObjects.Components.Atmos;
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Server.Interfaces.Timing; using Robust.Server.Interfaces.Timing;
@@ -27,14 +28,14 @@ namespace Content.Server.GameObjects.EntitySystems
base.Initialize(); base.Initialize();
_mapManager.TileChanged += OnTileChanged; _mapManager.TileChanged += OnTileChanged;
EntityQuery = new MultipleTypeEntityQuery(new List<Type>(){typeof(GridAtmosphereComponent)}); EntityQuery = new MultipleTypeEntityQuery(new List<Type>(){typeof(IGridAtmosphereComponent)});
} }
public GridAtmosphereComponent? GetGridAtmosphere(GridId gridId) public IGridAtmosphereComponent? GetGridAtmosphere(GridId gridId)
{ {
var grid = _mapManager.GetGrid(gridId); var grid = _mapManager.GetGrid(gridId);
var gridEnt = _entityManager.GetEntity(grid.GridEntityId); var gridEnt = _entityManager.GetEntity(grid.GridEntityId);
return gridEnt.TryGetComponent(out GridAtmosphereComponent atmos) ? atmos : null; return gridEnt.TryGetComponent(out IGridAtmosphereComponent atmos) ? atmos : null;
} }
public override void Update(float frameTime) public override void Update(float frameTime)
@@ -47,7 +48,7 @@ namespace Content.Server.GameObjects.EntitySystems
if (_pauseManager.IsGridPaused(grid.GridIndex)) if (_pauseManager.IsGridPaused(grid.GridIndex))
continue; continue;
gridEnt.GetComponent<GridAtmosphereComponent>().Update(frameTime); gridEnt.GetComponent<IGridAtmosphereComponent>().Update(frameTime);
} }
} }