Refactor UpdateKinematics() and fix a lot of Content warnings (#1709)

Most warnings were related to EntityQuery and IPhysicsComponent.
Partially fixes #1650 and fixes #1682
This commit is contained in:
Vince
2020-08-16 05:38:35 +02:00
committed by GitHub
parent 8503ab157a
commit b647ad0f42
29 changed files with 65 additions and 151 deletions

View File

@@ -1,25 +1,16 @@
using Content.Client.GameObjects.Components.Mobs;
using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Systems;
namespace Content.Client.GameObjects.EntitySystems
{
public sealed class CameraRecoilSystem : EntitySystem
{
public override void Initialize()
{
base.Initialize();
EntityQuery = new TypeEntityQuery(typeof(CameraRecoilComponent));
}
public override void FrameUpdate(float frameTime)
{
base.FrameUpdate(frameTime);
foreach (var entity in RelevantEntities)
foreach (var recoil in EntityManager.ComponentManager.EntityQuery<CameraRecoilComponent>())
{
var recoil = entity.GetComponent<CameraRecoilComponent>();
recoil.FrameUpdate(frameTime);
}
}

View File

@@ -1,6 +1,5 @@
using Content.Client.GameObjects.Components.Instruments;
using JetBrains.Annotations;
using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Systems;
using Robust.Shared.Interfaces.Timing;
using Robust.Shared.IoC;
@@ -12,12 +11,6 @@ namespace Content.Client.GameObjects.EntitySystems
{
[Dependency] private readonly IGameTiming _gameTiming = default;
public override void Initialize()
{
base.Initialize();
EntityQuery = new TypeEntityQuery(typeof(InstrumentComponent));
}
public override void Update(float frameTime)
{
base.Update(frameTime);
@@ -27,9 +20,9 @@ namespace Content.Client.GameObjects.EntitySystems
return;
}
foreach (var entity in RelevantEntities)
foreach (var instrumentComponent in EntityManager.ComponentManager.EntityQuery<InstrumentComponent>())
{
entity.GetComponent<InstrumentComponent>().Update(frameTime);
instrumentComponent.Update(frameTime);
}
}
}

View File

@@ -1,5 +1,4 @@
using Content.Client.GameObjects.Components.Markers;
using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Systems;
namespace Content.Client.GameObjects.EntitySystems
@@ -8,13 +7,6 @@ namespace Content.Client.GameObjects.EntitySystems
{
private bool _markersVisible;
public override void Initialize()
{
base.Initialize();
EntityQuery = new TypeEntityQuery<MarkerComponent>();
}
public bool MarkersVisible
{
get => _markersVisible;
@@ -27,9 +19,9 @@ namespace Content.Client.GameObjects.EntitySystems
private void UpdateMarkers()
{
foreach (var entity in RelevantEntities)
foreach (var markerComponent in EntityManager.ComponentManager.EntityQuery<MarkerComponent>())
{
entity.GetComponent<MarkerComponent>().UpdateVisibility();
markerComponent.UpdateVisibility();
}
}
}

View File

@@ -1,6 +1,5 @@
using Content.Client.GameObjects.Components.Mobs;
using JetBrains.Annotations;
using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Systems;
namespace Content.Client.GameObjects.EntitySystems
@@ -8,20 +7,13 @@ namespace Content.Client.GameObjects.EntitySystems
[UsedImplicitly]
public sealed class MeleeLungeSystem : EntitySystem
{
public override void Initialize()
{
base.Initialize();
EntityQuery = new TypeEntityQuery<MeleeLungeComponent>();
}
public override void FrameUpdate(float frameTime)
{
base.FrameUpdate(frameTime);
foreach (var entity in RelevantEntities)
foreach (var meleeLungeComponent in EntityManager.ComponentManager.EntityQuery<MeleeLungeComponent>())
{
entity.GetComponent<MeleeLungeComponent>().Update(frameTime);
meleeLungeComponent.Update(frameTime);
}
}
}

View File

@@ -24,16 +24,15 @@ namespace Content.Client.GameObjects.EntitySystems
public override void Initialize()
{
SubscribeNetworkEvent<PlayMeleeWeaponAnimationMessage>(PlayWeaponArc);
EntityQuery = new TypeEntityQuery(typeof(MeleeWeaponArcAnimationComponent));
}
public override void FrameUpdate(float frameTime)
{
base.FrameUpdate(frameTime);
foreach (var entity in RelevantEntities)
foreach (var arcAnimationComponent in EntityManager.ComponentManager.EntityQuery<MeleeWeaponArcAnimationComponent>())
{
entity.GetComponent<MeleeWeaponArcAnimationComponent>().Update(frameTime);
arcAnimationComponent.Update(frameTime);
}
}

View File

@@ -30,11 +30,10 @@ namespace Content.Client.GameObjects.EntitySystems
return;
}
var physics = playerEnt.GetComponent<IPhysicsComponent>();
playerEnt.TryGetComponent(out ICollidableComponent? collidable);
physics.Predict = true;
var collidable = playerEnt.GetComponent<ICollidableComponent>();
collidable.Predict = true;
UpdateKinematics(playerEnt.Transform, mover, physics, collidable);
UpdateKinematics(playerEnt.Transform, mover, collidable);
}
public override void Update(float frameTime)

View File

@@ -1,5 +1,4 @@
using Content.Client.GameObjects.Components.Mobs;
using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Systems;
using Robust.Shared.Interfaces.Timing;
using Robust.Shared.IoC;
@@ -12,11 +11,6 @@ namespace Content.Client.GameObjects.EntitySystems
[Dependency] private IGameTiming _gameTiming;
#pragma warning restore 649
public StatusEffectsSystem()
{
EntityQuery = new TypeEntityQuery(typeof(ClientStatusEffectsComponent));
}
public override void FrameUpdate(float frameTime)
{
base.FrameUpdate(frameTime);
@@ -24,9 +18,9 @@ namespace Content.Client.GameObjects.EntitySystems
if (!_gameTiming.IsFirstTimePredicted)
return;
foreach (var entity in RelevantEntities)
foreach (var clientStatusEffectsComponent in EntityManager.ComponentManager.EntityQuery<ClientStatusEffectsComponent>())
{
entity.GetComponent<ClientStatusEffectsComponent>().FrameUpdate(frameTime);
clientStatusEffectsComponent.FrameUpdate(frameTime);
}
}
}