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:
@@ -1,25 +1,16 @@
|
|||||||
using Content.Client.GameObjects.Components.Mobs;
|
using Content.Client.GameObjects.Components.Mobs;
|
||||||
using Robust.Shared.GameObjects;
|
|
||||||
using Robust.Shared.GameObjects.Systems;
|
using Robust.Shared.GameObjects.Systems;
|
||||||
|
|
||||||
namespace Content.Client.GameObjects.EntitySystems
|
namespace Content.Client.GameObjects.EntitySystems
|
||||||
{
|
{
|
||||||
public sealed class CameraRecoilSystem : EntitySystem
|
public sealed class CameraRecoilSystem : EntitySystem
|
||||||
{
|
{
|
||||||
public override void Initialize()
|
|
||||||
{
|
|
||||||
base.Initialize();
|
|
||||||
|
|
||||||
EntityQuery = new TypeEntityQuery(typeof(CameraRecoilComponent));
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void FrameUpdate(float frameTime)
|
public override void FrameUpdate(float frameTime)
|
||||||
{
|
{
|
||||||
base.FrameUpdate(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);
|
recoil.FrameUpdate(frameTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
using Content.Client.GameObjects.Components.Instruments;
|
using Content.Client.GameObjects.Components.Instruments;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Robust.Shared.GameObjects;
|
|
||||||
using Robust.Shared.GameObjects.Systems;
|
using Robust.Shared.GameObjects.Systems;
|
||||||
using Robust.Shared.Interfaces.Timing;
|
using Robust.Shared.Interfaces.Timing;
|
||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
@@ -12,12 +11,6 @@ namespace Content.Client.GameObjects.EntitySystems
|
|||||||
{
|
{
|
||||||
[Dependency] private readonly IGameTiming _gameTiming = default;
|
[Dependency] private readonly IGameTiming _gameTiming = default;
|
||||||
|
|
||||||
public override void Initialize()
|
|
||||||
{
|
|
||||||
base.Initialize();
|
|
||||||
EntityQuery = new TypeEntityQuery(typeof(InstrumentComponent));
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Update(float frameTime)
|
public override void Update(float frameTime)
|
||||||
{
|
{
|
||||||
base.Update(frameTime);
|
base.Update(frameTime);
|
||||||
@@ -27,9 +20,9 @@ namespace Content.Client.GameObjects.EntitySystems
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var entity in RelevantEntities)
|
foreach (var instrumentComponent in EntityManager.ComponentManager.EntityQuery<InstrumentComponent>())
|
||||||
{
|
{
|
||||||
entity.GetComponent<InstrumentComponent>().Update(frameTime);
|
instrumentComponent.Update(frameTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using Content.Client.GameObjects.Components.Markers;
|
using Content.Client.GameObjects.Components.Markers;
|
||||||
using Robust.Shared.GameObjects;
|
|
||||||
using Robust.Shared.GameObjects.Systems;
|
using Robust.Shared.GameObjects.Systems;
|
||||||
|
|
||||||
namespace Content.Client.GameObjects.EntitySystems
|
namespace Content.Client.GameObjects.EntitySystems
|
||||||
@@ -8,13 +7,6 @@ namespace Content.Client.GameObjects.EntitySystems
|
|||||||
{
|
{
|
||||||
private bool _markersVisible;
|
private bool _markersVisible;
|
||||||
|
|
||||||
public override void Initialize()
|
|
||||||
{
|
|
||||||
base.Initialize();
|
|
||||||
|
|
||||||
EntityQuery = new TypeEntityQuery<MarkerComponent>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool MarkersVisible
|
public bool MarkersVisible
|
||||||
{
|
{
|
||||||
get => _markersVisible;
|
get => _markersVisible;
|
||||||
@@ -27,9 +19,9 @@ namespace Content.Client.GameObjects.EntitySystems
|
|||||||
|
|
||||||
private void UpdateMarkers()
|
private void UpdateMarkers()
|
||||||
{
|
{
|
||||||
foreach (var entity in RelevantEntities)
|
foreach (var markerComponent in EntityManager.ComponentManager.EntityQuery<MarkerComponent>())
|
||||||
{
|
{
|
||||||
entity.GetComponent<MarkerComponent>().UpdateVisibility();
|
markerComponent.UpdateVisibility();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
using Content.Client.GameObjects.Components.Mobs;
|
using Content.Client.GameObjects.Components.Mobs;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Robust.Shared.GameObjects;
|
|
||||||
using Robust.Shared.GameObjects.Systems;
|
using Robust.Shared.GameObjects.Systems;
|
||||||
|
|
||||||
namespace Content.Client.GameObjects.EntitySystems
|
namespace Content.Client.GameObjects.EntitySystems
|
||||||
@@ -8,20 +7,13 @@ namespace Content.Client.GameObjects.EntitySystems
|
|||||||
[UsedImplicitly]
|
[UsedImplicitly]
|
||||||
public sealed class MeleeLungeSystem : EntitySystem
|
public sealed class MeleeLungeSystem : EntitySystem
|
||||||
{
|
{
|
||||||
public override void Initialize()
|
|
||||||
{
|
|
||||||
base.Initialize();
|
|
||||||
|
|
||||||
EntityQuery = new TypeEntityQuery<MeleeLungeComponent>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void FrameUpdate(float frameTime)
|
public override void FrameUpdate(float frameTime)
|
||||||
{
|
{
|
||||||
base.FrameUpdate(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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,16 +24,15 @@ namespace Content.Client.GameObjects.EntitySystems
|
|||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
SubscribeNetworkEvent<PlayMeleeWeaponAnimationMessage>(PlayWeaponArc);
|
SubscribeNetworkEvent<PlayMeleeWeaponAnimationMessage>(PlayWeaponArc);
|
||||||
EntityQuery = new TypeEntityQuery(typeof(MeleeWeaponArcAnimationComponent));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void FrameUpdate(float frameTime)
|
public override void FrameUpdate(float frameTime)
|
||||||
{
|
{
|
||||||
base.FrameUpdate(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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,11 +30,10 @@ namespace Content.Client.GameObjects.EntitySystems
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var physics = playerEnt.GetComponent<IPhysicsComponent>();
|
var collidable = playerEnt.GetComponent<ICollidableComponent>();
|
||||||
playerEnt.TryGetComponent(out ICollidableComponent? collidable);
|
collidable.Predict = true;
|
||||||
physics.Predict = true;
|
|
||||||
|
|
||||||
UpdateKinematics(playerEnt.Transform, mover, physics, collidable);
|
UpdateKinematics(playerEnt.Transform, mover, collidable);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Update(float frameTime)
|
public override void Update(float frameTime)
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using Content.Client.GameObjects.Components.Mobs;
|
using Content.Client.GameObjects.Components.Mobs;
|
||||||
using Robust.Shared.GameObjects;
|
|
||||||
using Robust.Shared.GameObjects.Systems;
|
using Robust.Shared.GameObjects.Systems;
|
||||||
using Robust.Shared.Interfaces.Timing;
|
using Robust.Shared.Interfaces.Timing;
|
||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
@@ -12,11 +11,6 @@ namespace Content.Client.GameObjects.EntitySystems
|
|||||||
[Dependency] private IGameTiming _gameTiming;
|
[Dependency] private IGameTiming _gameTiming;
|
||||||
#pragma warning restore 649
|
#pragma warning restore 649
|
||||||
|
|
||||||
public StatusEffectsSystem()
|
|
||||||
{
|
|
||||||
EntityQuery = new TypeEntityQuery(typeof(ClientStatusEffectsComponent));
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void FrameUpdate(float frameTime)
|
public override void FrameUpdate(float frameTime)
|
||||||
{
|
{
|
||||||
base.FrameUpdate(frameTime);
|
base.FrameUpdate(frameTime);
|
||||||
@@ -24,9 +18,9 @@ namespace Content.Client.GameObjects.EntitySystems
|
|||||||
if (!_gameTiming.IsFirstTimePredicted)
|
if (!_gameTiming.IsFirstTimePredicted)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
foreach (var entity in RelevantEntities)
|
foreach (var clientStatusEffectsComponent in EntityManager.ComponentManager.EntityQuery<ClientStatusEffectsComponent>())
|
||||||
{
|
{
|
||||||
entity.GetComponent<ClientStatusEffectsComponent>().FrameUpdate(frameTime);
|
clientStatusEffectsComponent.FrameUpdate(frameTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using Content.Client.Sandbox;
|
using Robust.Client.Console;
|
||||||
using Robust.Client.Console;
|
|
||||||
using Robust.Client.Interfaces.Placement;
|
using Robust.Client.Interfaces.Placement;
|
||||||
using Robust.Client.Interfaces.ResourceManagement;
|
using Robust.Client.Interfaces.ResourceManagement;
|
||||||
using Robust.Client.UserInterface.Controls;
|
using Robust.Client.UserInterface.Controls;
|
||||||
@@ -15,16 +14,12 @@ namespace Content.Client.UserInterface
|
|||||||
internal sealed class EscapeMenu : SS14Window
|
internal sealed class EscapeMenu : SS14Window
|
||||||
{
|
{
|
||||||
private readonly IClientConsole _console;
|
private readonly IClientConsole _console;
|
||||||
private readonly ITileDefinitionManager __tileDefinitionManager;
|
private readonly ITileDefinitionManager _tileDefinitionManager;
|
||||||
private readonly IPlacementManager _placementManager;
|
private readonly IPlacementManager _placementManager;
|
||||||
private readonly IPrototypeManager _prototypeManager;
|
private readonly IPrototypeManager _prototypeManager;
|
||||||
private readonly IResourceCache _resourceCache;
|
private readonly IResourceCache _resourceCache;
|
||||||
private readonly IConfigurationManager _configSystem;
|
private readonly IConfigurationManager _configSystem;
|
||||||
private readonly ILocalizationManager _localizationManager;
|
private readonly ILocalizationManager _localizationManager;
|
||||||
#pragma warning disable 649
|
|
||||||
[Dependency] private readonly ISandboxManager _sandboxManager;
|
|
||||||
[Dependency] private readonly IClientConGroupController _conGroupController;
|
|
||||||
#pragma warning restore 649
|
|
||||||
|
|
||||||
private BaseButton DisconnectButton;
|
private BaseButton DisconnectButton;
|
||||||
private BaseButton QuitButton;
|
private BaseButton QuitButton;
|
||||||
@@ -41,7 +36,7 @@ namespace Content.Client.UserInterface
|
|||||||
_configSystem = configSystem;
|
_configSystem = configSystem;
|
||||||
_localizationManager = localizationManager;
|
_localizationManager = localizationManager;
|
||||||
_console = console;
|
_console = console;
|
||||||
__tileDefinitionManager = tileDefinitionManager;
|
_tileDefinitionManager = tileDefinitionManager;
|
||||||
_placementManager = placementManager;
|
_placementManager = placementManager;
|
||||||
_prototypeManager = prototypeManager;
|
_prototypeManager = prototypeManager;
|
||||||
_resourceCache = resourceCache;
|
_resourceCache = resourceCache;
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ namespace Content.Server.GameObjects.Components.Atmos
|
|||||||
[RegisterComponent, Serializable]
|
[RegisterComponent, Serializable]
|
||||||
public class GridAtmosphereComponent : Component, IGridAtmosphereComponent
|
public class GridAtmosphereComponent : Component, IGridAtmosphereComponent
|
||||||
{
|
{
|
||||||
[Robust.Shared.IoC.Dependency] private IGameTiming _gameTiming = default!;
|
|
||||||
[Robust.Shared.IoC.Dependency] private IMapManager _mapManager = default!;
|
[Robust.Shared.IoC.Dependency] private IMapManager _mapManager = default!;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -16,9 +16,7 @@ namespace Content.Server.GameObjects.Components.Chemistry
|
|||||||
[RegisterComponent]
|
[RegisterComponent]
|
||||||
class VaporComponent : Component, ICollideBehavior
|
class VaporComponent : Component, ICollideBehavior
|
||||||
{
|
{
|
||||||
#pragma warning disable 649
|
|
||||||
[Dependency] private readonly IMapManager _mapManager = default!;
|
[Dependency] private readonly IMapManager _mapManager = default!;
|
||||||
#pragma warning enable 649
|
|
||||||
public override string Name => "Vapor";
|
public override string Name => "Vapor";
|
||||||
|
|
||||||
[ViewVariables]
|
[ViewVariables]
|
||||||
|
|||||||
@@ -2,8 +2,6 @@
|
|||||||
using Content.Shared.GameObjects.EntitySystems;
|
using Content.Shared.GameObjects.EntitySystems;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.GameObjects.Systems;
|
using Robust.Shared.GameObjects.Systems;
|
||||||
using Robust.Shared.IoC;
|
|
||||||
using Robust.Shared.Localization;
|
|
||||||
using Robust.Shared.Serialization;
|
using Robust.Shared.Serialization;
|
||||||
using Robust.Shared.Utility;
|
using Robust.Shared.Utility;
|
||||||
using Robust.Shared.ViewVariables;
|
using Robust.Shared.ViewVariables;
|
||||||
@@ -16,9 +14,6 @@ namespace Content.Server.GameObjects.Components.Construction
|
|||||||
[RegisterComponent]
|
[RegisterComponent]
|
||||||
public class ConstructionComponent : Component, IExamine
|
public class ConstructionComponent : Component, IExamine
|
||||||
{
|
{
|
||||||
#pragma warning disable 649
|
|
||||||
[Dependency] private readonly ILocalizationManager _loc;
|
|
||||||
#pragma warning restore 649
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override string Name => "Construction";
|
public override string Name => "Construction";
|
||||||
|
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ namespace Content.Server.GameObjects.Components.Disposal
|
|||||||
collidable.Anchored;
|
collidable.Anchored;
|
||||||
|
|
||||||
[ViewVariables]
|
[ViewVariables]
|
||||||
private State State => _pressure >= 1 ? State.Ready : State.Pressurizing;
|
private PressureState State => _pressure >= 1 ? PressureState.Ready : PressureState.Pressurizing;
|
||||||
|
|
||||||
[ViewVariables]
|
[ViewVariables]
|
||||||
private bool Engaged
|
private bool Engaged
|
||||||
|
|||||||
@@ -668,13 +668,13 @@ namespace Content.Server.GameObjects.Components.GUI
|
|||||||
|
|
||||||
Dirty();
|
Dirty();
|
||||||
|
|
||||||
if (!message.Entity.TryGetComponent(out ICollidableComponent physics))
|
if (!message.Entity.TryGetComponent(out ICollidableComponent collidable))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// set velocity to zero
|
// set velocity to zero
|
||||||
physics.Stop();
|
collidable.Stop();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ using Robust.Shared.GameObjects;
|
|||||||
using Robust.Shared.GameObjects.Components;
|
using Robust.Shared.GameObjects.Components;
|
||||||
using Robust.Shared.Interfaces.GameObjects;
|
using Robust.Shared.Interfaces.GameObjects;
|
||||||
using Robust.Shared.Interfaces.Map;
|
using Robust.Shared.Interfaces.Map;
|
||||||
using Robust.Shared.Interfaces.Random;
|
|
||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
using Robust.Shared.Serialization;
|
using Robust.Shared.Serialization;
|
||||||
|
|
||||||
@@ -29,7 +28,6 @@ namespace Content.Server.GameObjects.Components.Items.Storage
|
|||||||
public override uint? NetID => ContentNetIDs.ITEM;
|
public override uint? NetID => ContentNetIDs.ITEM;
|
||||||
|
|
||||||
#pragma warning disable 649
|
#pragma warning disable 649
|
||||||
[Dependency] private readonly IRobustRandom _robustRandom;
|
|
||||||
[Dependency] private readonly IMapManager _mapManager;
|
[Dependency] private readonly IMapManager _mapManager;
|
||||||
#pragma warning restore 649
|
#pragma warning restore 649
|
||||||
|
|
||||||
@@ -93,7 +91,7 @@ namespace Content.Server.GameObjects.Components.Items.Storage
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Owner.TryGetComponent(out PhysicsComponent physics) &&
|
if (Owner.TryGetComponent(out CollidableComponent physics) &&
|
||||||
physics.Anchored)
|
physics.Anchored)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -42,9 +42,9 @@ namespace Content.Server.GameObjects.Components.Movement
|
|||||||
{
|
{
|
||||||
base.Initialize();
|
base.Initialize();
|
||||||
|
|
||||||
// This component requires a physics component.
|
// This component requires a collidable component.
|
||||||
if (!Owner.HasComponent<IPhysicsComponent>())
|
if (!Owner.HasComponent<ICollidableComponent>())
|
||||||
Owner.AddComponent<PhysicsComponent>();
|
Owner.AddComponent<CollidableComponent>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
|
|||||||
@@ -71,22 +71,15 @@ namespace Content.Server.GameObjects.Components.Movement
|
|||||||
_entityManager.TryGetEntity(grid.GridEntityId, out var gridEntity))
|
_entityManager.TryGetEntity(grid.GridEntityId, out var gridEntity))
|
||||||
{
|
{
|
||||||
//TODO: Switch to shuttle component
|
//TODO: Switch to shuttle component
|
||||||
if (!gridEntity.TryGetComponent(out IPhysicsComponent physComp))
|
if (!gridEntity.TryGetComponent(out ICollidableComponent collidable))
|
||||||
{
|
{
|
||||||
physComp = gridEntity.AddComponent<PhysicsComponent>();
|
collidable = gridEntity.AddComponent<CollidableComponent>();
|
||||||
physComp.Mass = 1;
|
collidable.Mass = 1;
|
||||||
|
collidable.CanCollide = true;
|
||||||
|
collidable.PhysicsShapes.Add(new PhysShapeGrid(grid));
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: Is this always true?
|
var controller = collidable.EnsureController<ShuttleController>();
|
||||||
if (!gridEntity.HasComponent<ICollidableComponent>())
|
|
||||||
{
|
|
||||||
var collideComp = gridEntity.AddComponent<CollidableComponent>();
|
|
||||||
collideComp.CanCollide = true;
|
|
||||||
//collideComp.IsHardCollidable = true;
|
|
||||||
collideComp.PhysicsShapes.Add(new PhysShapeGrid(grid));
|
|
||||||
}
|
|
||||||
|
|
||||||
var controller = physComp.EnsureController<ShuttleController>();
|
|
||||||
controller.Push(CalcNewVelocity(direction, enabled), CurrentWalkSpeed);
|
controller.Push(CalcNewVelocity(direction, enabled), CurrentWalkSpeed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,9 +92,9 @@ namespace Content.Server.GameObjects.Components.Projectiles
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!entity.Deleted && entity.TryGetComponent(out CameraRecoilComponent recoilComponent)
|
if (!entity.Deleted && entity.TryGetComponent(out CameraRecoilComponent recoilComponent)
|
||||||
&& Owner.TryGetComponent(out IPhysicsComponent physicsComponent))
|
&& Owner.TryGetComponent(out ICollidableComponent collidableComponent))
|
||||||
{
|
{
|
||||||
var direction = physicsComponent.LinearVelocity.Normalized;
|
var direction = collidableComponent.LinearVelocity.Normalized;
|
||||||
recoilComponent.Kick(direction);
|
recoilComponent.Kick(direction);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ namespace Content.Server.GameObjects.Components.Projectiles
|
|||||||
|
|
||||||
public void StartThrow(Vector2 direction, float speed)
|
public void StartThrow(Vector2 direction, float speed)
|
||||||
{
|
{
|
||||||
var comp = Owner.GetComponent<IPhysicsComponent>();
|
var comp = Owner.GetComponent<ICollidableComponent>();
|
||||||
comp.Status = BodyStatus.InAir;
|
comp.Status = BodyStatus.InAir;
|
||||||
|
|
||||||
var controller = comp.EnsureController<ThrownController>();
|
var controller = comp.EnsureController<ThrownController>();
|
||||||
|
|||||||
@@ -21,9 +21,9 @@ namespace Content.Server.GameObjects.Components.Rotatable
|
|||||||
|
|
||||||
private void TryRotate(IEntity user, Angle angle)
|
private void TryRotate(IEntity user, Angle angle)
|
||||||
{
|
{
|
||||||
if (Owner.TryGetComponent(out IPhysicsComponent physics))
|
if (Owner.TryGetComponent(out ICollidableComponent collidable))
|
||||||
{
|
{
|
||||||
if (physics.Anchored)
|
if (collidable.Anchored)
|
||||||
{
|
{
|
||||||
_notifyManager.PopupMessage(Owner.Transform.GridPosition, user, _localizationManager.GetString("It's stuck."));
|
_notifyManager.PopupMessage(Owner.Transform.GridPosition, user, _localizationManager.GetString("It's stuck."));
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ using Content.Server.GameObjects.Components.Damage;
|
|||||||
using Content.Server.GameObjects.Components.Mobs;
|
using Content.Server.GameObjects.Components.Mobs;
|
||||||
using Content.Server.GameObjects.Components.Projectiles;
|
using Content.Server.GameObjects.Components.Projectiles;
|
||||||
using Content.Server.GameObjects.Components.Weapon.Ranged.Ammunition;
|
using Content.Server.GameObjects.Components.Weapon.Ranged.Ammunition;
|
||||||
using Content.Server.Interfaces;
|
|
||||||
using Content.Shared.Audio;
|
using Content.Shared.Audio;
|
||||||
using Content.Shared.GameObjects.Components.Weapons.Ranged;
|
using Content.Shared.GameObjects.Components.Weapons.Ranged;
|
||||||
using Content.Shared.GameObjects.EntitySystems;
|
using Content.Shared.GameObjects.EntitySystems;
|
||||||
@@ -43,7 +42,6 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels
|
|||||||
#pragma warning disable 649
|
#pragma warning disable 649
|
||||||
[Dependency] private IGameTiming _gameTiming;
|
[Dependency] private IGameTiming _gameTiming;
|
||||||
[Dependency] private IRobustRandom _robustRandom;
|
[Dependency] private IRobustRandom _robustRandom;
|
||||||
[Dependency] private readonly IServerNotifyManager _notifyManager;
|
|
||||||
#pragma warning restore 649
|
#pragma warning restore 649
|
||||||
|
|
||||||
public override FireRateSelector FireRateSelector => _fireRateSelector;
|
public override FireRateSelector FireRateSelector => _fireRateSelector;
|
||||||
@@ -385,15 +383,15 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels
|
|||||||
projectileAngle = angle;
|
projectileAngle = angle;
|
||||||
}
|
}
|
||||||
|
|
||||||
var physicsComponent = projectile.GetComponent<IPhysicsComponent>();
|
var collidableComponent = projectile.GetComponent<ICollidableComponent>();
|
||||||
physicsComponent.Status = BodyStatus.InAir;
|
collidableComponent.Status = BodyStatus.InAir;
|
||||||
projectile.Transform.GridPosition = Owner.Transform.GridPosition;
|
projectile.Transform.GridPosition = Owner.Transform.GridPosition;
|
||||||
|
|
||||||
var projectileComponent = projectile.GetComponent<ProjectileComponent>();
|
var projectileComponent = projectile.GetComponent<ProjectileComponent>();
|
||||||
projectileComponent.IgnoreEntity(shooter);
|
projectileComponent.IgnoreEntity(shooter);
|
||||||
|
|
||||||
projectile
|
projectile
|
||||||
.GetComponent<IPhysicsComponent>()
|
.GetComponent<ICollidableComponent>()
|
||||||
.EnsureController<BulletController>()
|
.EnsureController<BulletController>()
|
||||||
.LinearVelocity = projectileAngle.ToVec() * velocity;
|
.LinearVelocity = projectileAngle.ToVec() * velocity;
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Steering
|
|||||||
|
|
||||||
#pragma warning disable 649
|
#pragma warning disable 649
|
||||||
[Dependency] private IMapManager _mapManager;
|
[Dependency] private IMapManager _mapManager;
|
||||||
[Dependency] private IEntityManager _entityManager;
|
|
||||||
[Dependency] private IPauseManager _pauseManager;
|
[Dependency] private IPauseManager _pauseManager;
|
||||||
#pragma warning restore 649
|
#pragma warning restore 649
|
||||||
private PathfindingSystem _pathfindingSystem;
|
private PathfindingSystem _pathfindingSystem;
|
||||||
|
|||||||
@@ -17,18 +17,14 @@ namespace Content.Server.GameObjects.EntitySystems
|
|||||||
[UsedImplicitly]
|
[UsedImplicitly]
|
||||||
public class AtmosphereSystem : EntitySystem
|
public class AtmosphereSystem : EntitySystem
|
||||||
{
|
{
|
||||||
#pragma warning disable 649
|
|
||||||
[Dependency] private readonly IMapManager _mapManager = default!;
|
[Dependency] private readonly IMapManager _mapManager = default!;
|
||||||
[Dependency] private readonly IEntityManager _entityManager = default!;
|
|
||||||
[Dependency] private readonly IPauseManager _pauseManager = default!;
|
[Dependency] private readonly IPauseManager _pauseManager = default!;
|
||||||
#pragma warning restore 649
|
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
base.Initialize();
|
base.Initialize();
|
||||||
|
|
||||||
_mapManager.TileChanged += OnTileChanged;
|
_mapManager.TileChanged += OnTileChanged;
|
||||||
EntityQuery = new MultipleTypeEntityQuery(new List<Type>(){typeof(IGridAtmosphereComponent)});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public IGridAtmosphereComponent? GetGridAtmosphere(GridId gridId)
|
public IGridAtmosphereComponent? GetGridAtmosphere(GridId gridId)
|
||||||
@@ -36,7 +32,7 @@ namespace Content.Server.GameObjects.EntitySystems
|
|||||||
// TODO Return space grid atmosphere for invalid grids or grids with no atmos
|
// TODO Return space grid atmosphere for invalid grids or grids with no atmos
|
||||||
var grid = _mapManager.GetGrid(gridId);
|
var grid = _mapManager.GetGrid(gridId);
|
||||||
|
|
||||||
if (!_entityManager.TryGetEntity(grid.GridEntityId, out var gridEnt)) return null;
|
if (!EntityManager.TryGetEntity(grid.GridEntityId, out var gridEnt)) return null;
|
||||||
|
|
||||||
return gridEnt.TryGetComponent(out IGridAtmosphereComponent atmos) ? atmos : null;
|
return gridEnt.TryGetComponent(out IGridAtmosphereComponent atmos) ? atmos : null;
|
||||||
}
|
}
|
||||||
@@ -45,13 +41,12 @@ namespace Content.Server.GameObjects.EntitySystems
|
|||||||
{
|
{
|
||||||
base.Update(frameTime);
|
base.Update(frameTime);
|
||||||
|
|
||||||
foreach (var gridEnt in RelevantEntities)
|
foreach (var (mapGridComponent, gridAtmosphereComponent) in EntityManager.ComponentManager.EntityQuery<IMapGridComponent, IGridAtmosphereComponent>())
|
||||||
{
|
{
|
||||||
var grid = gridEnt.GetComponent<IMapGridComponent>();
|
if (_pauseManager.IsGridPaused(mapGridComponent.GridIndex))
|
||||||
if (_pauseManager.IsGridPaused(grid.GridIndex))
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
gridEnt.GetComponent<IGridAtmosphereComponent>().Update(frameTime);
|
gridAtmosphereComponent.Update(frameTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -58,23 +58,13 @@ namespace Content.Server.GameObjects.EntitySystems
|
|||||||
|
|
||||||
public override void Update(float frameTime)
|
public override void Update(float frameTime)
|
||||||
{
|
{
|
||||||
foreach (var entity in RelevantEntities)
|
foreach (var (moverComponent, collidableComponent) in EntityManager.ComponentManager.EntityQuery<IMoverComponent, ICollidableComponent>())
|
||||||
{
|
{
|
||||||
|
var entity = moverComponent.Owner;
|
||||||
if (_pauseManager.IsEntityPaused(entity))
|
if (_pauseManager.IsEntityPaused(entity))
|
||||||
{
|
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
|
|
||||||
var mover = entity.GetComponent<IMoverComponent>();
|
UpdateKinematics(entity.Transform, moverComponent, collidableComponent);
|
||||||
var physics = entity.GetComponent<IPhysicsComponent>();
|
|
||||||
if (entity.TryGetComponent<ICollidableComponent>(out var collider))
|
|
||||||
{
|
|
||||||
UpdateKinematics(entity.Transform, mover, physics, collider);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
UpdateKinematics(entity.Transform, mover, physics);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,7 +83,7 @@ namespace Content.Server.GameObjects.EntitySystems
|
|||||||
ev.Entity.RemoveComponent<PlayerInputMoverComponent>();
|
ev.Entity.RemoveComponent<PlayerInputMoverComponent>();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ev.Entity.TryGetComponent(out IPhysicsComponent physics) &&
|
if (ev.Entity.TryGetComponent(out ICollidableComponent physics) &&
|
||||||
physics.TryGetController(out MoverController controller))
|
physics.TryGetController(out MoverController controller))
|
||||||
{
|
{
|
||||||
controller.StopMoving();
|
controller.StopMoving();
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ namespace Content.Server.Throw
|
|||||||
projComp.StartThrow(angle.ToVec(), spd);
|
projComp.StartThrow(angle.ToVec(), spd);
|
||||||
|
|
||||||
if (throwSourceEnt != null &&
|
if (throwSourceEnt != null &&
|
||||||
throwSourceEnt.TryGetComponent<IPhysicsComponent>(out var physics) &&
|
throwSourceEnt.TryGetComponent<ICollidableComponent>(out var physics) &&
|
||||||
physics.TryGetController(out MoverController mover))
|
physics.TryGetController(out MoverController mover))
|
||||||
{
|
{
|
||||||
var physicsMgr = IoCManager.Resolve<IPhysicsManager>();
|
var physicsMgr = IoCManager.Resolve<IPhysicsManager>();
|
||||||
@@ -136,7 +136,7 @@ namespace Content.Server.Throw
|
|||||||
var distance = (targetLoc.ToMapPos(mapManager) - sourceLoc.ToMapPos(mapManager)).Length;
|
var distance = (targetLoc.ToMapPos(mapManager) - sourceLoc.ToMapPos(mapManager)).Length;
|
||||||
var throwDuration = ThrownItemComponent.DefaultThrowTime;
|
var throwDuration = ThrownItemComponent.DefaultThrowTime;
|
||||||
var mass = 1f;
|
var mass = 1f;
|
||||||
if (thrownEnt.TryGetComponent(out IPhysicsComponent physicsComponent))
|
if (thrownEnt.TryGetComponent(out ICollidableComponent physicsComponent))
|
||||||
{
|
{
|
||||||
mass = physicsComponent.Mass;
|
mass = physicsComponent.Mass;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ namespace Content.Shared.GameObjects.Components.Disposal
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Serializable, NetSerializable]
|
[Serializable, NetSerializable]
|
||||||
public enum State
|
public enum PressureState
|
||||||
{
|
{
|
||||||
Ready,
|
Ready,
|
||||||
Pressurizing
|
Pressurizing
|
||||||
|
|||||||
@@ -142,11 +142,11 @@ namespace Content.Shared.GameObjects.Components.Movement
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void OnAdd()
|
public override void OnAdd()
|
||||||
{
|
{
|
||||||
// This component requires that the entity has a PhysicsComponent.
|
// This component requires that the entity has a CollidableComponent.
|
||||||
if (!Owner.HasComponent<IPhysicsComponent>())
|
if (!Owner.HasComponent<ICollidableComponent>())
|
||||||
Logger.Error(
|
Logger.Error(
|
||||||
$"[ECS] {Owner.Prototype?.Name} - {nameof(SharedPlayerInputMoverComponent)} requires" +
|
$"[ECS] {Owner.Prototype?.Name} - {nameof(SharedPlayerInputMoverComponent)} requires" +
|
||||||
$" {nameof(IPhysicsComponent)}. ");
|
$" {nameof(ICollidableComponent)}. ");
|
||||||
|
|
||||||
base.OnAdd();
|
base.OnAdd();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,13 +50,12 @@ namespace Content.Shared.GameObjects.Components.Movement
|
|||||||
|| _slipped.Contains(entity.Uid)
|
|| _slipped.Contains(entity.Uid)
|
||||||
|| !entity.TryGetComponent(out SharedStunnableComponent stun)
|
|| !entity.TryGetComponent(out SharedStunnableComponent stun)
|
||||||
|| !entity.TryGetComponent(out ICollidableComponent otherBody)
|
|| !entity.TryGetComponent(out ICollidableComponent otherBody)
|
||||||
|| !entity.TryGetComponent(out IPhysicsComponent otherPhysics)
|
|
||||||
|| !Owner.TryGetComponent(out ICollidableComponent body))
|
|| !Owner.TryGetComponent(out ICollidableComponent body))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (otherPhysics.LinearVelocity.Length < RequiredSlipSpeed || stun.KnockedDown)
|
if (otherBody.LinearVelocity.Length < RequiredSlipSpeed || stun.KnockedDown)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,8 +29,6 @@ namespace Content.Shared.GameObjects.EntitySystems
|
|||||||
{
|
{
|
||||||
base.Initialize();
|
base.Initialize();
|
||||||
|
|
||||||
EntityQuery = new TypeEntityQuery(typeof(IMoverComponent));
|
|
||||||
|
|
||||||
var moveUpCmdHandler = new MoverDirInputCmdHandler(Direction.North);
|
var moveUpCmdHandler = new MoverDirInputCmdHandler(Direction.North);
|
||||||
var moveLeftCmdHandler = new MoverDirInputCmdHandler(Direction.West);
|
var moveLeftCmdHandler = new MoverDirInputCmdHandler(Direction.West);
|
||||||
var moveRightCmdHandler = new MoverDirInputCmdHandler(Direction.East);
|
var moveRightCmdHandler = new MoverDirInputCmdHandler(Direction.East);
|
||||||
@@ -54,18 +52,17 @@ namespace Content.Shared.GameObjects.EntitySystems
|
|||||||
base.Shutdown();
|
base.Shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void UpdateKinematics(ITransformComponent transform, IMoverComponent mover, IPhysicsComponent physics,
|
protected void UpdateKinematics(ITransformComponent transform, IMoverComponent mover, ICollidableComponent collidable)
|
||||||
ICollidableComponent? collider = null)
|
|
||||||
{
|
{
|
||||||
physics.EnsureController<MoverController>();
|
collidable.EnsureController<MoverController>();
|
||||||
|
|
||||||
var weightless = !transform.Owner.HasComponent<MovementIgnoreGravityComponent>() &&
|
var weightless = !transform.Owner.HasComponent<MovementIgnoreGravityComponent>() &&
|
||||||
_physicsManager.IsWeightless(transform.GridPosition);
|
_physicsManager.IsWeightless(transform.GridPosition);
|
||||||
|
|
||||||
if (weightless && collider != null)
|
if (weightless)
|
||||||
{
|
{
|
||||||
// No gravity: is our entity touching anything?
|
// No gravity: is our entity touching anything?
|
||||||
var touching = IsAroundCollider(transform, mover, collider);
|
var touching = IsAroundCollider(transform, mover, collidable);
|
||||||
|
|
||||||
if (!touching)
|
if (!touching)
|
||||||
{
|
{
|
||||||
@@ -78,18 +75,16 @@ namespace Content.Shared.GameObjects.EntitySystems
|
|||||||
var combined = walkDir + sprintDir;
|
var combined = walkDir + sprintDir;
|
||||||
if (combined.LengthSquared < 0.001 || !ActionBlockerSystem.CanMove(mover.Owner) && !weightless)
|
if (combined.LengthSquared < 0.001 || !ActionBlockerSystem.CanMove(mover.Owner) && !weightless)
|
||||||
{
|
{
|
||||||
if (physics.TryGetController(out MoverController controller))
|
if (collidable.TryGetController(out MoverController controller))
|
||||||
{
|
{
|
||||||
controller.StopMoving();
|
controller.StopMoving();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//Console.WriteLine($"{IoCManager.Resolve<IGameTiming>().TickStamp}: {combined}");
|
|
||||||
|
|
||||||
if (weightless)
|
if (weightless)
|
||||||
{
|
{
|
||||||
if (physics.TryGetController(out MoverController controller))
|
if (collidable.TryGetController(out MoverController controller))
|
||||||
{
|
{
|
||||||
controller.Push(combined, mover.CurrentPushSpeed);
|
controller.Push(combined, mover.CurrentPushSpeed);
|
||||||
}
|
}
|
||||||
@@ -99,12 +94,13 @@ namespace Content.Shared.GameObjects.EntitySystems
|
|||||||
}
|
}
|
||||||
|
|
||||||
var total = walkDir * mover.CurrentWalkSpeed + sprintDir * mover.CurrentSprintSpeed;
|
var total = walkDir * mover.CurrentWalkSpeed + sprintDir * mover.CurrentSprintSpeed;
|
||||||
//Console.WriteLine($"{walkDir} ({mover.CurrentWalkSpeed}) + {sprintDir} ({mover.CurrentSprintSpeed}): {total}");
|
|
||||||
|
|
||||||
{if (physics.TryGetController(out MoverController controller))
|
{
|
||||||
|
if (collidable.TryGetController(out MoverController controller))
|
||||||
{
|
{
|
||||||
controller.Move(total, 1);
|
controller.Move(total, 1);
|
||||||
}}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
transform.LocalRotation = total.GetDir().ToAngle();
|
transform.LocalRotation = total.GetDir().ToAngle();
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ namespace Content.Shared.Health.BodySystem.Mechanism
|
|||||||
private string _name;
|
private string _name;
|
||||||
private string _description;
|
private string _description;
|
||||||
private string _examineMessage;
|
private string _examineMessage;
|
||||||
private string _spritePath;
|
|
||||||
private string _rsiPath;
|
private string _rsiPath;
|
||||||
private string _rsiState;
|
private string _rsiState;
|
||||||
private int _durability;
|
private int _durability;
|
||||||
|
|||||||
Reference in New Issue
Block a user