Gets rid of all ComponentManager usages. (#4707)

This commit is contained in:
Vera Aguilera Puerto
2021-09-28 13:35:29 +02:00
committed by GitHub
parent 7953e5b962
commit 0be5ff829b
158 changed files with 321 additions and 333 deletions

View File

@@ -19,7 +19,7 @@ namespace Content.Shared.Actions
_timeSinceCooldownCheck += frameTime;
if (_timeSinceCooldownCheck < CooldownCheckIntervalSeconds) return;
foreach (var comp in ComponentManager.EntityQuery<SharedActionsComponent>(false))
foreach (var comp in EntityManager.EntityQuery<SharedActionsComponent>(false))
{
comp.ExpireCooldowns();
}

View File

@@ -17,7 +17,7 @@ namespace Content.Shared.Audio
// Reason I didn't make this eventbus for the callers is because it seemed a bit silly
// trying to account for damageable + powered + toggle, plus we can't just check if it's powered.
// So we'll just call it directly for whatever.
if (!ComponentManager.TryGetComponent<AmbientSoundComponent>(uid, out var ambience) ||
if (!EntityManager.TryGetComponent<AmbientSoundComponent>(uid, out var ambience) ||
ambience.Enabled == value) return;
ambience.Enabled = value;

View File

@@ -10,7 +10,7 @@ namespace Content.Shared.Body.Mechanism
{
base.Update(frameTime);
foreach (var mechanism in ComponentManager.EntityQuery<SharedMechanismComponent>(true))
foreach (var mechanism in EntityManager.EntityQuery<SharedMechanismComponent>(true))
{
mechanism.Update(frameTime);
}

View File

@@ -10,7 +10,7 @@ namespace Content.Shared.Chemistry.EntitySystems
{
public void Refill(EntityUid targetUid, Solution targetSolution, Solution addedSolution)
{
if (!ComponentManager.HasComponent<RefillableSolutionComponent>(targetUid))
if (!EntityManager.HasComponent<RefillableSolutionComponent>(targetUid))
return;
TryAddSolution(targetUid, targetSolution, addedSolution);
@@ -18,7 +18,7 @@ namespace Content.Shared.Chemistry.EntitySystems
public void Inject(EntityUid targetUid, Solution targetSolution, Solution addedSolution)
{
if (!ComponentManager.HasComponent<InjectableSolutionComponent>(targetUid))
if (!EntityManager.HasComponent<InjectableSolutionComponent>(targetUid))
return;
TryAddSolution(targetUid, targetSolution, addedSolution);
@@ -26,7 +26,7 @@ namespace Content.Shared.Chemistry.EntitySystems
public Solution Draw(EntityUid targetUid, Solution solution, ReagentUnit amount)
{
if (!ComponentManager.HasComponent<DrawableSolutionComponent>(targetUid))
if (!EntityManager.HasComponent<DrawableSolutionComponent>(targetUid))
{
return new Solution();
}
@@ -36,7 +36,7 @@ namespace Content.Shared.Chemistry.EntitySystems
public Solution Drain(EntityUid targetUid, Solution targetSolution, ReagentUnit amount)
{
if (!ComponentManager.HasComponent<DrainableSolutionComponent>(targetUid))
if (!EntityManager.HasComponent<DrainableSolutionComponent>(targetUid))
{
return new Solution();
}
@@ -47,8 +47,8 @@ namespace Content.Shared.Chemistry.EntitySystems
public bool TryGetInjectableSolution(EntityUid targetUid,
[NotNullWhen(true)] out Solution? solution)
{
if (ComponentManager.TryGetComponent(targetUid, out InjectableSolutionComponent? injectable) &&
ComponentManager.TryGetComponent(targetUid, out SolutionContainerManagerComponent? manager) &&
if (EntityManager.TryGetComponent(targetUid, out InjectableSolutionComponent? injectable) &&
EntityManager.TryGetComponent(targetUid, out SolutionContainerManagerComponent? manager) &&
manager.Solutions.TryGetValue(injectable.Solution, out solution))
{
return true;
@@ -61,8 +61,8 @@ namespace Content.Shared.Chemistry.EntitySystems
public bool TryGetRefillableSolution(EntityUid targetUid,
[NotNullWhen(true)] out Solution? solution)
{
if (ComponentManager.TryGetComponent(targetUid, out RefillableSolutionComponent? refillable) &&
ComponentManager.TryGetComponent(targetUid, out SolutionContainerManagerComponent? manager) &&
if (EntityManager.TryGetComponent(targetUid, out RefillableSolutionComponent? refillable) &&
EntityManager.TryGetComponent(targetUid, out SolutionContainerManagerComponent? manager) &&
manager.Solutions.TryGetValue(refillable.Solution, out var refillableSolution))
{
solution = refillableSolution;
@@ -76,9 +76,9 @@ namespace Content.Shared.Chemistry.EntitySystems
public bool TryGetDrainableSolution(EntityUid targetUid,
[NotNullWhen(true)] out Solution? solution)
{
if (ComponentManager.TryGetComponent(targetUid,out DrainableSolutionComponent? drainable) &&
ComponentManager.TryGetComponent(targetUid,out SolutionContainerManagerComponent? manager) &&
manager.Solutions.TryGetValue(drainable.Solution, out solution))
if (EntityManager.TryGetComponent(targetUid,out DrainableSolutionComponent? drainable) &&
EntityManager.TryGetComponent(targetUid,out SolutionContainerManagerComponent? manager) &&
manager.Solutions.TryGetValue(drainable.Solution, out solution))
{
return true;
}

View File

@@ -144,7 +144,7 @@ namespace Content.Shared.Chemistry.EntitySystems
public void RemoveAllSolution(EntityUid uid)
{
if (!ComponentManager.TryGetComponent(uid, out SolutionContainerManagerComponent? solutionContainerManager))
if (!EntityManager.TryGetComponent(uid, out SolutionContainerManagerComponent? solutionContainerManager))
return;
foreach (var solution in solutionContainerManager.Solutions.Values)
@@ -224,7 +224,7 @@ namespace Content.Shared.Chemistry.EntitySystems
public bool TryGetSolution(EntityUid uid, string name,
[NotNullWhen(true)] out Solution? solution)
{
if (!ComponentManager.TryGetComponent(uid, out SolutionContainerManagerComponent? solutionsMgr))
if (!EntityManager.TryGetComponent(uid, out SolutionContainerManagerComponent? solutionsMgr))
{
solution = null;
return false;

View File

@@ -29,9 +29,9 @@ namespace Content.Shared.Chemistry
if (args.Current is not MovespeedModifierMetabolismComponentState cast)
return;
if (ComponentManager.TryGetComponent<MovementSpeedModifierComponent>(uid, out var modifier) &&
if (EntityManager.TryGetComponent<MovementSpeedModifierComponent>(uid, out var modifier) &&
(!component.WalkSpeedModifier.Equals(cast.WalkSpeedModifier) ||
!component.SprintSpeedModifier.Equals(cast.SprintSpeedModifier)))
!component.SprintSpeedModifier.Equals(cast.SprintSpeedModifier)))
{
modifier.RefreshMovementSpeedModifiers();
}
@@ -65,7 +65,7 @@ namespace Content.Shared.Chemistry
if (component.ModifierTimer > currentTime) continue;
_components.RemoveAt(i);
ComponentManager.RemoveComponent<MovespeedModifierMetabolismComponent>(component.Owner.Uid);
EntityManager.RemoveComponent<MovespeedModifierMetabolismComponent>(component.Owner.Uid);
if (component.Owner.TryGetComponent(out MovementSpeedModifierComponent? modifier))
{

View File

@@ -16,7 +16,7 @@ namespace Content.Shared.Cuffs
private void HandleMoveAttempt(EntityUid uid, SharedCuffableComponent component, MovementAttemptEvent args)
{
if (component.CanStillInteract || !ComponentManager.TryGetComponent(uid, out SharedPullableComponent? pullable) || !pullable.BeingPulled)
if (component.CanStillInteract || !EntityManager.TryGetComponent(uid, out SharedPullableComponent? pullable) || !pullable.BeingPulled)
return;
args.Cancel();

View File

@@ -100,7 +100,7 @@ namespace Content.Shared.Damage
/// </returns>
public DamageSpecifier? TryChangeDamage(EntityUid uid, DamageSpecifier damage, bool ignoreResistances = false)
{
if (!ComponentManager.TryGetComponent<DamageableComponent>(uid, out var damageable))
if (!EntityManager.TryGetComponent<DamageableComponent>(uid, out var damageable))
{
// TODO BODY SYSTEM pass damage onto body system
return null;

View File

@@ -34,8 +34,8 @@ namespace Content.Shared.Disposal
var otherBody = args.BodyB.Owner.Uid;
// Items dropped shouldn't collide but items thrown should
if (ComponentManager.HasComponent<SharedItemComponent>(otherBody) &&
!ComponentManager.HasComponent<ThrownItemComponent>(otherBody))
if (EntityManager.HasComponent<SharedItemComponent>(otherBody) &&
!EntityManager.HasComponent<ThrownItemComponent>(otherBody))
{
args.Cancel();
return;

View File

@@ -40,7 +40,7 @@ namespace Content.Shared.Nutrition.EntitySystems
creamPied.CreamPied = value;
if (ComponentManager.TryGetComponent(uid, out SharedAppearanceComponent? appearance))
if (EntityManager.TryGetComponent(uid, out SharedAppearanceComponent? appearance))
{
appearance.SetData(CreamPiedVisuals.Creamed, value);
}
@@ -64,7 +64,7 @@ namespace Content.Shared.Nutrition.EntitySystems
CreamedEntity(uid, creamPied, args);
if (ComponentManager.TryGetComponent(uid, out SharedStunnableComponent? stun))
if (EntityManager.TryGetComponent(uid, out SharedStunnableComponent? stun))
{
stun.Paralyze(creamPie.ParalyzeTime);
}

View File

@@ -26,7 +26,7 @@ namespace Content.Shared.Pulling.Systems
if (component.Pulling == EntityManager.GetEntity(args.BlockingEntity))
{
if (ComponentManager.TryGetComponent<SharedPullableComponent>(args.BlockingEntity, out var comp))
if (EntityManager.TryGetComponent<SharedPullableComponent>(args.BlockingEntity, out var comp))
{
comp.TryStopPull(EntityManager.GetEntity(uid));
}

View File

@@ -50,7 +50,7 @@ namespace Content.Shared.Slippery
if (!component.Slippery
|| component.Owner.IsInContainer()
|| component.Slipped.Contains(uid)
|| !ComponentManager.TryGetComponent<SharedStunnableComponent>(uid, out stunnableComponent))
|| !EntityManager.TryGetComponent<SharedStunnableComponent>(uid, out stunnableComponent))
{
stunnableComponent = null;
return false;
@@ -99,7 +99,7 @@ namespace Content.Shared.Slippery
if (component.Deleted || !component.Slippery || component.Colliding.Count == 0)
return true;
if (!ComponentManager.TryGetComponent(component.Owner.Uid, out PhysicsComponent? body))
if (!EntityManager.TryGetComponent(component.Owner.Uid, out PhysicsComponent? body))
{
component.Colliding.Clear();
return true;

View File

@@ -23,7 +23,7 @@ namespace Content.Shared.Stunnable
{
base.Update(frameTime);
foreach (var component in ComponentManager.EntityQuery<SharedStunnableComponent>(true))
foreach (var component in EntityManager.EntityQuery<SharedStunnableComponent>(true))
{
component.Update(frameTime);
}

View File

@@ -118,7 +118,7 @@ namespace Content.Shared.SubFloor
private void UpdateAll()
{
foreach (var comp in ComponentManager.EntityQuery<SubFloorHideComponent>(true))
foreach (var comp in EntityManager.EntityQuery<SubFloorHideComponent>(true))
{
UpdateEntity(comp.Owner.Uid);
}
@@ -130,14 +130,14 @@ namespace Content.Shared.SubFloor
foreach (var uid in grid.GetAnchoredEntities(position))
{
if(ComponentManager.HasComponent<SubFloorHideComponent>(uid))
if(EntityManager.HasComponent<SubFloorHideComponent>(uid))
UpdateEntity(uid, isSubFloor);
}
}
private void UpdateEntity(EntityUid uid)
{
var transform = ComponentManager.GetComponent<ITransformComponent>(uid);
var transform = EntityManager.GetComponent<ITransformComponent>(uid);
if (!_mapManager.TryGetGrid(transform.GridID, out var grid))
{
@@ -162,7 +162,7 @@ namespace Content.Shared.SubFloor
// We only need to query the subfloor component to check if it's enabled or not when we're not on subfloor.
// Getting components is expensive, after all.
if (!subFloor && ComponentManager.TryGetComponent(uid, out SubFloorHideComponent? subFloorHideComponent))
if (!subFloor && EntityManager.TryGetComponent(uid, out SubFloorHideComponent? subFloorHideComponent))
{
// If the component isn't enabled, then subfloor will always be true, and the entity will be shown.
if (!subFloorHideComponent.Enabled)
@@ -170,7 +170,7 @@ namespace Content.Shared.SubFloor
subFloor = true;
}
// We only need to query the TransformComp if the SubfloorHide is enabled and requires anchoring.
else if (subFloorHideComponent.RequireAnchored && ComponentManager.TryGetComponent(uid, out ITransformComponent? transformComponent))
else if (subFloorHideComponent.RequireAnchored && EntityManager.TryGetComponent(uid, out ITransformComponent? transformComponent))
{
// If we require the entity to be anchored but it's not, this will set subfloor to true, unhiding it.
subFloor = !transformComponent.Anchored;
@@ -181,19 +181,19 @@ namespace Content.Shared.SubFloor
var subFloorVisible = ShowAll || subFloor;
// Show sprite
if (ComponentManager.TryGetComponent(uid, out SharedSpriteComponent? spriteComponent))
if (EntityManager.TryGetComponent(uid, out SharedSpriteComponent? spriteComponent))
{
spriteComponent.Visible = subFloorVisible;
}
// Set an appearance data value so visualizers can use this as needed.
if (ComponentManager.TryGetComponent(uid, out SharedAppearanceComponent? appearanceComponent))
if (EntityManager.TryGetComponent(uid, out SharedAppearanceComponent? appearanceComponent))
{
appearanceComponent.SetData(SubFloorVisuals.SubFloor, subFloorVisible);
}
// So for collision all we care about is that the component is running.
if (ComponentManager.TryGetComponent(uid, out PhysicsComponent? physicsComponent))
if (EntityManager.TryGetComponent(uid, out PhysicsComponent? physicsComponent))
{
physicsComponent.CanCollide = subFloor;
}

View File

@@ -98,7 +98,7 @@ namespace Content.Shared.Throwing
if (thrownItem.Owner.TryGetContainerMan(out var containerManager) &&
containerManager.Owner.HasComponent<SharedHandsComponent>())
{
ComponentManager.RemoveComponent(landing.Uid, thrownItem);
EntityManager.RemoveComponent(landing.Uid, thrownItem);
return;
}
@@ -108,7 +108,7 @@ namespace Content.Shared.Throwing
var landMsg = new LandEvent(user, landing, coordinates);
RaiseLocalEvent(landing.Uid, landMsg, false);
ComponentManager.RemoveComponent(landing.Uid, thrownItem);
EntityManager.RemoveComponent(landing.Uid, thrownItem);
}
/// <summary>