Base Update() method was removed from components in engine, added some basic ECS systems to update the components. (#79)

This commit is contained in:
Acruid
2018-07-26 14:26:19 -07:00
committed by Pieter-Jan Briers
parent 18ed1041ba
commit 8c874c76dc
12 changed files with 132 additions and 13 deletions

View File

@@ -94,7 +94,12 @@
<Compile Include="GameObjects\EntitySystems\Click\ClickParser.cs" /> <Compile Include="GameObjects\EntitySystems\Click\ClickParser.cs" />
<Compile Include="GameObjects\EntitySystems\Click\ExamineSystem.cs" /> <Compile Include="GameObjects\EntitySystems\Click\ExamineSystem.cs" />
<Compile Include="GameObjects\EntitySystems\Click\InteractionSystem.cs" /> <Compile Include="GameObjects\EntitySystems\Click\InteractionSystem.cs" />
<Compile Include="GameObjects\EntitySystems\DoorSystem.cs" />
<Compile Include="GameObjects\EntitySystems\PowerApcSystem.cs" />
<Compile Include="GameObjects\EntitySystems\PowerSmesSystem.cs" />
<Compile Include="GameObjects\EntitySystems\PowerSystem.cs" /> <Compile Include="GameObjects\EntitySystems\PowerSystem.cs" />
<Compile Include="GameObjects\EntitySystems\WelderSystem.cs" />
<Compile Include="GameObjects\TemperatureSystem.cs" />
<Compile Include="Interfaces\GameObjects\Components\Items\IHandsComponent.cs" /> <Compile Include="Interfaces\GameObjects\Components\Items\IHandsComponent.cs" />
<Compile Include="GameObjects\Components\GUI\ServerHandsComponent.cs" /> <Compile Include="GameObjects\Components\GUI\ServerHandsComponent.cs" />
<Compile Include="GameObjects\Components\GUI\InventoryComponent.cs" /> <Compile Include="GameObjects\Components\GUI\InventoryComponent.cs" />

View File

@@ -96,7 +96,7 @@ namespace Content.Server.GameObjects
} }
private const float AUTO_CLOSE_DELAY = 5; private const float AUTO_CLOSE_DELAY = 5;
public override void Update(float frameTime) public void OnUpdate(float frameTime)
{ {
if (!Opened) if (!Opened)
{ {

View File

@@ -80,7 +80,7 @@ namespace Content.Server.GameObjects.Components.Interactable.Tools
} }
} }
public override void Update(float frameTime) public void OnUpdate(float frameTime)
{ {
if (!Activated) if (!Activated)
{ {

View File

@@ -1,4 +1,4 @@
using Content.Shared.GameObjects.Components.Power; using Content.Shared.GameObjects.Components.Power;
using SS14.Server.GameObjects; using SS14.Server.GameObjects;
using SS14.Shared.GameObjects; using SS14.Shared.GameObjects;
@@ -20,7 +20,7 @@ namespace Content.Server.GameObjects.Components.Power
Appearance = Owner.GetComponent<AppearanceComponent>(); Appearance = Owner.GetComponent<AppearanceComponent>();
} }
public override void Update(float frameTime) public void OnUpdate()
{ {
var newState = CalcChargeState(); var newState = CalcChargeState();
if (newState != LastChargeState) if (newState != LastChargeState)

View File

@@ -28,7 +28,7 @@ namespace Content.Server.GameObjects.Components.Power
Appearance = Owner.GetComponent<AppearanceComponent>(); Appearance = Owner.GetComponent<AppearanceComponent>();
} }
public override void Update(float frameTime) public void OnUpdate()
{ {
var newLevel = CalcChargeLevel(); var newLevel = CalcChargeLevel();
if (newLevel != LastChargeLevel) if (newLevel != LastChargeLevel)

View File

@@ -45,10 +45,8 @@ namespace Content.Server.GameObjects
} }
/// <inheritdoc /> /// <inheritdoc />
public override void Update(float frameTime) public void OnUpdate(float frameTime)
{ {
base.Update(frameTime);
int fireDamage = (int)Math.Floor(Math.Max(0, CurrentTemperature - _fireDamageThreshold) / _fireDamageCoefficient); int fireDamage = (int)Math.Floor(Math.Max(0, CurrentTemperature - _fireDamageThreshold) / _fireDamageCoefficient);
_secondsSinceLastDamageUpdate += frameTime; _secondsSinceLastDamageUpdate += frameTime;

View File

@@ -0,0 +1,22 @@
using SS14.Shared.GameObjects;
using SS14.Shared.GameObjects.System;
namespace Content.Server.GameObjects.EntitySystems
{
class DoorSystem : EntitySystem
{
public override void Initialize()
{
EntityQuery = new TypeEntityQuery(typeof(ServerDoorComponent));
}
public override void Update(float frameTime)
{
foreach (var entity in RelevantEntities)
{
var comp = entity.GetComponent<ServerDoorComponent>();
comp.OnUpdate(frameTime);
}
}
}
}

View File

@@ -0,0 +1,23 @@
using Content.Server.GameObjects.Components.Power;
using SS14.Shared.GameObjects;
using SS14.Shared.GameObjects.System;
namespace Content.Server.GameObjects.EntitySystems
{
class PowerApcSystem : EntitySystem
{
public override void Initialize()
{
EntityQuery = new TypeEntityQuery(typeof(ApcComponent));
}
public override void Update(float frameTime)
{
foreach (var entity in RelevantEntities)
{
var comp = entity.GetComponent<ApcComponent>();
comp.OnUpdate();
}
}
}
}

View File

@@ -0,0 +1,23 @@
using Content.Server.GameObjects.Components.Power;
using SS14.Shared.GameObjects;
using SS14.Shared.GameObjects.System;
namespace Content.Server.GameObjects.EntitySystems
{
internal class PowerSmesSystem : EntitySystem
{
public override void Initialize()
{
EntityQuery = new TypeEntityQuery(typeof(SmesComponent));
}
public override void Update(float frameTime)
{
foreach (var entity in RelevantEntities)
{
var comp = entity.GetComponent<SmesComponent>();
comp.OnUpdate();
}
}
}
}

View File

@@ -2,11 +2,8 @@
using SS14.Shared.GameObjects.System; using SS14.Shared.GameObjects.System;
using SS14.Shared.Interfaces.GameObjects; using SS14.Shared.Interfaces.GameObjects;
using SS14.Shared.IoC; using SS14.Shared.IoC;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using SS14.Shared.GameObjects;
using System.Text;
using System.Threading.Tasks;
namespace Content.Shared.GameObjects.EntitySystems namespace Content.Shared.GameObjects.EntitySystems
{ {
@@ -18,6 +15,11 @@ namespace Content.Shared.GameObjects.EntitySystems
private int _lastUid = 0; private int _lastUid = 0;
public PowerSystem()
{
EntityQuery = new TypeEntityQuery(typeof(PowerDeviceComponent));
}
public override void Initialize() public override void Initialize()
{ {
base.Initialize(); base.Initialize();
@@ -61,8 +63,9 @@ namespace Content.Shared.GameObjects.EntitySystems
} }
// Draw power for devices not connected to anything. // Draw power for devices not connected to anything.
foreach (var device in componentManager.GetComponents<PowerDeviceComponent>()) foreach (var entity in EntityManager.GetEntities(EntityQuery))
{ {
var device = entity.GetComponent<PowerDeviceComponent>();
device.ProcessInternalPower(frametime); device.ProcessInternalPower(frametime);
} }
} }

View File

@@ -0,0 +1,23 @@
using Content.Server.GameObjects.Components.Interactable.Tools;
using SS14.Shared.GameObjects;
using SS14.Shared.GameObjects.System;
namespace Content.Server.GameObjects.EntitySystems
{
class WelderSystem : EntitySystem
{
public override void Initialize()
{
EntityQuery = new TypeEntityQuery(typeof(WelderComponent));
}
public override void Update(float frameTime)
{
foreach (var entity in RelevantEntities)
{
var comp = entity.GetComponent<WelderComponent>();
comp.OnUpdate(frameTime);
}
}
}
}

View File

@@ -0,0 +1,22 @@
using SS14.Shared.GameObjects;
using SS14.Shared.GameObjects.System;
namespace Content.Server.GameObjects
{
class TemperatureSystem : EntitySystem
{
public override void Initialize()
{
EntityQuery = new TypeEntityQuery(typeof(TemperatureComponent));
}
public override void Update(float frameTime)
{
foreach (var entity in RelevantEntities)
{
var comp = entity.GetComponent<TemperatureComponent>();
comp.OnUpdate(frameTime);
}
}
}
}