Server EntitySystem cleanup (#1617)
* Server EntitySystem cleanup I went after low-hanging fruit systems. * Add / change to internal access modifiers to systems * Use EntityQuery to get components instead * Add sealed modifier to systems * Remove unused imports * Add jetbrains annotation for unused classes * Removed some pragmas for dependencies This should also fix a decent chunk of the server build warnings, at least the ones that matter. * Also disposals * Update Content.Server/GameObjects/EntitySystems/GravitySystem.cs * Fix build Co-authored-by: Metal Gear Sloth <metalgearsloth@gmail.com> Co-authored-by: Víctor Aguilera Puerto <6766154+Zumorica@users.noreply.github.com>
This commit is contained in:
@@ -33,9 +33,6 @@ namespace Content.Server.GameObjects.EntitySystems.AI
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
// register entity query
|
||||
EntityQuery = new TypeEntityQuery(typeof(AiControllerComponent));
|
||||
|
||||
var processors = _reflectionManager.GetAllChildren<AiLogicProcessor>();
|
||||
foreach (var processor in processors)
|
||||
{
|
||||
@@ -49,18 +46,16 @@ namespace Content.Server.GameObjects.EntitySystems.AI
|
||||
/// <inheritdoc />
|
||||
public override void Update(float frameTime)
|
||||
{
|
||||
var entities = EntityManager.GetEntities(EntityQuery);
|
||||
foreach (var entity in entities)
|
||||
foreach (var comp in ComponentManager.EntityQuery<AiControllerComponent>())
|
||||
{
|
||||
if (_pauseManager.IsEntityPaused(entity))
|
||||
if (_pauseManager.IsEntityPaused(comp.Owner))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
ProcessorInitialize(comp);
|
||||
|
||||
var aiComp = entity.GetComponent<AiControllerComponent>();
|
||||
ProcessorInitialize(aiComp);
|
||||
|
||||
var processor = aiComp.Processor;
|
||||
var processor = comp.Processor;
|
||||
|
||||
processor.Update(frameTime);
|
||||
}
|
||||
|
||||
@@ -581,7 +581,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Steering
|
||||
return Vector2.Zero;
|
||||
}
|
||||
|
||||
if (target.TryGetComponent(out IPhysicsComponent physicsComponent))
|
||||
if (target.TryGetComponent(out ICollidableComponent physicsComponent))
|
||||
{
|
||||
var targetDistance = (targetPos.Position - entityPos.Position);
|
||||
targetPos = targetPos.Offset(physicsComponent.LinearVelocity * targetDistance);
|
||||
@@ -640,11 +640,12 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Steering
|
||||
// if we're moving in the same direction then ignore
|
||||
// So if 2 entities are moving towards each other and both detect a collision they'll both move in the same direction
|
||||
// i.e. towards the right
|
||||
if (physicsEntity.TryGetComponent(out IPhysicsComponent physicsComponent) &&
|
||||
if (physicsEntity.TryGetComponent(out ICollidableComponent physicsComponent) &&
|
||||
Vector2.Dot(physicsComponent.LinearVelocity, direction) > 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var centerGrid = physicsEntity.Transform.GridPosition;
|
||||
// Check how close we are to center of tile and get the inverse; if we're closer this is stronger
|
||||
var additionalVector = (centerGrid.Position - entityGridCoords.Position);
|
||||
|
||||
Reference in New Issue
Block a user