Remove redundant IComponent casts

This commit is contained in:
metalgearsloth
2021-12-07 21:54:00 +11:00
parent 8d4799e611
commit 373b5988d7
29 changed files with 53 additions and 53 deletions

View File

@@ -119,7 +119,7 @@ namespace Content.Client.Inventory
}
}
EntitySystem.Get<MovementSpeedModifierSystem>().RefreshMovementSpeedModifiers(((IComponent) this).Owner);
EntitySystem.Get<MovementSpeedModifierSystem>().RefreshMovementSpeedModifiers(Owner);
}
private void _setSlot(Slots slot, EntityUid entity)

View File

@@ -22,7 +22,7 @@ namespace Content.Client.Nutrition.Components
_currentHungerThreshold = hunger.CurrentThreshold;
EntitySystem.Get<MovementSpeedModifierSystem>().RefreshMovementSpeedModifiers(((IComponent) this).Owner);
EntitySystem.Get<MovementSpeedModifierSystem>().RefreshMovementSpeedModifiers(Owner);
}
}
}

View File

@@ -22,7 +22,7 @@ namespace Content.Client.Nutrition.Components
_currentThirstThreshold = thirst.CurrentThreshold;
EntitySystem.Get<MovementSpeedModifierSystem>().RefreshMovementSpeedModifiers(((IComponent) this).Owner);
EntitySystem.Get<MovementSpeedModifierSystem>().RefreshMovementSpeedModifiers(Owner);
}
}
}

View File

@@ -108,9 +108,9 @@ namespace Content.Server.Access.Components
private void HandleIdButton(EntityUid user, ItemSlot slot)
{
if (slot.HasItem)
EntitySystem.Get<ItemSlotsSystem>().TryEjectToHands(((IComponent) this).Owner, slot, user);
EntitySystem.Get<ItemSlotsSystem>().TryEjectToHands(Owner, slot, user);
else
EntitySystem.Get<ItemSlotsSystem>().TryInsertFromHand(((IComponent) this).Owner, slot, user);
EntitySystem.Get<ItemSlotsSystem>().TryInsertFromHand(Owner, slot, user);
}
public void UpdateUserInterface()

View File

@@ -131,7 +131,7 @@ namespace Content.Server.Arcade.Components
if (obj.Session != _player) break;
// TODO: Should this check if the Owner can interact...?
if (!EntitySystem.Get<ActionBlockerSystem>().CanInteract(((IComponent) this).Owner))
if (!EntitySystem.Get<ActionBlockerSystem>().CanInteract(Owner))
{
DeactivePlayer(obj.Session);
break;

View File

@@ -269,7 +269,7 @@ namespace Content.Server.Atmos.Components
range = MaxExplosionRange;
}
EntitySystem.Get<ExplosionSystem>().SpawnExplosion(((IComponent) this).Owner, (int) (range * 0.25f), (int) (range * 0.5f), (int) (range * 1.5f), 1);
EntitySystem.Get<ExplosionSystem>().SpawnExplosion(Owner, (int) (range * 0.25f), (int) (range * 0.5f), (int) (range * 1.5f), 1);
IoCManager.Resolve<IEntityManager>().QueueDeleteEntity(Owner);
return;

View File

@@ -562,10 +562,10 @@ namespace Content.Server.Botany.Components
else
{
var amt = FixedPoint2.New(1);
foreach (var reagent in solutionSystem.RemoveEachReagent(((IComponent) this).Owner, solution, amt))
foreach (var reagent in solutionSystem.RemoveEachReagent(Owner, solution, amt))
{
var reagentProto = _prototypeManager.Index<ReagentPrototype>(reagent);
reagentProto.ReactionPlant(((IComponent) this).Owner, new Solution.ReagentQuantity(reagent, amt), solution);
reagentProto.ReactionPlant(Owner, new Solution.ReagentQuantity(reagent, amt), solution);
}
}

View File

@@ -141,7 +141,7 @@ namespace Content.Server.Cargo.Components
// attempt to attach the label
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(product, out PaperLabelComponent label))
{
EntitySystem.Get<ItemSlotsSystem>().TryInsert(((IComponent) this).Owner, label.LabelSlot, printed);
EntitySystem.Get<ItemSlotsSystem>().TryInsert(Owner, label.LabelSlot, printed);
}
}

View File

@@ -121,7 +121,7 @@ namespace Content.Server.Chemistry.Components
switch (msg.Action)
{
case UiAction.Eject:
EntitySystem.Get<ItemSlotsSystem>().TryEjectToHands(((IComponent) this).Owner, BeakerSlot, player);
EntitySystem.Get<ItemSlotsSystem>().TryEjectToHands(Owner, BeakerSlot, player);
break;
case UiAction.ChemButton:
TransferReagent(msg.Id, msg.Amount, msg.IsBuffer);

View File

@@ -149,7 +149,7 @@ namespace Content.Server.Chemistry.Components
switch (msg.Button)
{
case UiButton.Eject:
EntitySystem.Get<ItemSlotsSystem>().TryEjectToHands(((IComponent) this).Owner, BeakerSlot, obj.Session.AttachedEntity);
EntitySystem.Get<ItemSlotsSystem>().TryEjectToHands(Owner, BeakerSlot, obj.Session.AttachedEntity);
break;
case UiButton.Clear:
TryClear();

View File

@@ -85,7 +85,7 @@ namespace Content.Server.Climbing.Components
Body.ApplyLinearImpulse((to - from).Normalized * velocity * Body.Mass * 5);
OwnerIsTransitioning = true;
EntitySystem.Get<ClimbSystem>().UnsetTransitionBoolAfterBufferTime(((IComponent) this).Owner, this);
EntitySystem.Get<ClimbSystem>().UnsetTransitionBoolAfterBufferTime(Owner, this);
}
public void Update()

View File

@@ -124,7 +124,7 @@ namespace Content.Server.Construction.Components
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<ConstructionComponent?>(Owner, out var construction))
{
// Attempt to set pathfinding to the machine node...
EntitySystem.Get<ConstructionSystem>().SetPathfindingTarget(((IComponent) this).Owner, "machine", construction);
EntitySystem.Get<ConstructionSystem>().SetPathfindingTarget(Owner, "machine", construction);
}
}
@@ -271,7 +271,7 @@ namespace Content.Server.Construction.Components
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out ConstructionComponent? construction))
{
// So prying the components off works correctly.
EntitySystem.Get<ConstructionSystem>().ResetEdge(((IComponent) this).Owner, construction);
EntitySystem.Get<ConstructionSystem>().ResetEdge(Owner, construction);
}
return true;

View File

@@ -32,7 +32,7 @@ namespace Content.Server.Disposal.Tube.Components
EntitySystem.Get<AtmosphereSystem>().Merge(holderComponent.Air, from.Air);
from.Air.Clear();
return EntitySystem.Get<DisposableSystem>().EnterTube(((IComponent) holderComponent).Owner, ((IComponent) this).Owner, holderComponent, null, this);
return EntitySystem.Get<DisposableSystem>().EnterTube(((IComponent) holderComponent).Owner, Owner, holderComponent, null, this);
}
protected override Direction[] ConnectableDirections()

View File

@@ -48,7 +48,7 @@ namespace Content.Server.Ghost.Roles.Components
mob.EnsureComponent<MindComponent>();
var ghostRoleSystem = EntitySystem.Get<GhostRoleSystem>();
ghostRoleSystem.GhostRoleInternalCreateMindAndTransfer(session, ((IComponent) this).Owner, mob, this);
ghostRoleSystem.GhostRoleInternalCreateMindAndTransfer(session, Owner, mob, this);
if (++_currentTakeovers < _availableTakeovers)
return true;

View File

@@ -30,10 +30,10 @@ namespace Content.Server.Ghost.Roles.Components
return false;
if (MakeSentient)
MakeSentientCommand.MakeSentient(((IComponent) this).Owner, IoCManager.Resolve<IEntityManager>());
MakeSentientCommand.MakeSentient(Owner, IoCManager.Resolve<IEntityManager>());
var ghostRoleSystem = EntitySystem.Get<GhostRoleSystem>();
ghostRoleSystem.GhostRoleInternalCreateMindAndTransfer(session, ((IComponent) this).Owner, ((IComponent) this).Owner, this);
ghostRoleSystem.GhostRoleInternalCreateMindAndTransfer(session, Owner, Owner, this);
ghostRoleSystem.UnregisterGhostRole(this);

View File

@@ -201,7 +201,7 @@ namespace Content.Server.Inventory.Components
var pass = false;
reason = null;
if (mobCheck && !EntitySystem.Get<ActionBlockerSystem>().CanEquip(((IComponent) this).Owner))
if (mobCheck && !EntitySystem.Get<ActionBlockerSystem>().CanEquip(Owner))
{
reason = Loc.GetString("inventory-component-can-equip-cannot");
return false;
@@ -288,7 +288,7 @@ namespace Content.Server.Inventory.Components
private void UpdateMovementSpeed()
{
EntitySystem.Get<MovementSpeedModifierSystem>().RefreshMovementSpeedModifiers(((IComponent) this).Owner);
EntitySystem.Get<MovementSpeedModifierSystem>().RefreshMovementSpeedModifiers(Owner);
}
public void ForceUnequip(Slots slot)
@@ -323,7 +323,7 @@ namespace Content.Server.Inventory.Components
/// </returns>
public bool CanUnequip(Slots slot, bool mobCheck = true)
{
if (mobCheck && !EntitySystem.Get<ActionBlockerSystem>().CanUnequip(((IComponent) this).Owner))
if (mobCheck && !EntitySystem.Get<ActionBlockerSystem>().CanUnequip(Owner))
return false;
var inventorySlot = _slotContainers[slot];

View File

@@ -90,7 +90,7 @@ namespace Content.Server.Nutrition.Components
if (_lastHungerThreshold == HungerThreshold.Starving && _currentHungerThreshold != HungerThreshold.Dead &&
IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out MovementSpeedModifierComponent? movementSlowdownComponent))
{
EntitySystem.Get<MovementSpeedModifierSystem>().RefreshMovementSpeedModifiers(((IComponent) this).Owner);
EntitySystem.Get<MovementSpeedModifierSystem>().RefreshMovementSpeedModifiers(Owner);
}
// Update UI
@@ -126,7 +126,7 @@ namespace Content.Server.Nutrition.Components
case HungerThreshold.Starving:
// TODO: If something else bumps this could cause mega-speed.
// If some form of speed update system if multiple things are touching it use that.
EntitySystem.Get<MovementSpeedModifierSystem>().RefreshMovementSpeedModifiers(((IComponent) this).Owner);
EntitySystem.Get<MovementSpeedModifierSystem>().RefreshMovementSpeedModifiers(Owner);
_lastHungerThreshold = _currentHungerThreshold;
_actualDecayRate = _baseDecayRate * 0.6f;
return;

View File

@@ -89,7 +89,7 @@ namespace Content.Server.Nutrition.Components
if (_lastThirstThreshold == ThirstThreshold.Parched && _currentThirstThreshold != ThirstThreshold.Dead &&
IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out MovementSpeedModifierComponent? movementSlowdownComponent))
{
EntitySystem.Get<MovementSpeedModifierSystem>().RefreshMovementSpeedModifiers(((IComponent) this).Owner);
EntitySystem.Get<MovementSpeedModifierSystem>().RefreshMovementSpeedModifiers(Owner);
}
// Update UI
@@ -123,7 +123,7 @@ namespace Content.Server.Nutrition.Components
return;
case ThirstThreshold.Parched:
EntitySystem.Get<MovementSpeedModifierSystem>().RefreshMovementSpeedModifiers(((IComponent) this).Owner);
EntitySystem.Get<MovementSpeedModifierSystem>().RefreshMovementSpeedModifiers(Owner);
_lastThirstThreshold = _currentThirstThreshold;
_actualDecayRate = _baseDecayRate * 0.6f;
return;

View File

@@ -73,7 +73,7 @@ namespace Content.Server.PowerCell.Components
var light = (int) Math.Ceiling(Math.Sqrt(CurrentCharge) / 30);
CurrentCharge = 0;
EntitySystem.Get<ExplosionSystem>().SpawnExplosion(((IComponent) this).Owner, 0, heavy, light, light*2);
EntitySystem.Get<ExplosionSystem>().SpawnExplosion(Owner, 0, heavy, light, light*2);
IoCManager.Resolve<IEntityManager>().DeleteEntity(Owner);
}

View File

@@ -33,11 +33,11 @@ namespace Content.Server.Shuttles.Components
if (!_enabled)
{
system.DisableThruster(((IComponent) this).Owner, this);
system.DisableThruster(Owner, this);
}
else if (system.CanEnable(((IComponent) this).Owner, this))
else if (system.CanEnable(Owner, this))
{
system.EnableThruster(((IComponent) this).Owner, this);
system.EnableThruster(Owner, this);
}
}
}

View File

@@ -221,7 +221,7 @@ namespace Content.Server.Storage.Components
var targetIsItem = IoCManager.Resolve<IEntityManager>().HasComponent<SharedItemComponent>(entity);
var targetIsMob = IoCManager.Resolve<IEntityManager>().HasComponent<SharedBodyComponent>(entity);
var storageIsItem = IoCManager.Resolve<IEntityManager>().HasComponent<SharedItemComponent>(((IComponent) this).Owner);
var storageIsItem = IoCManager.Resolve<IEntityManager>().HasComponent<SharedItemComponent>(Owner);
var allowedToEat = false;

View File

@@ -94,7 +94,7 @@ namespace Content.Server.Storage.Components
private void UpdateStorageVisualization()
{
if (!_entityManager.TryGetComponent(((IComponent) this).Owner, out AppearanceComponent appearance))
if (!_entityManager.TryGetComponent(Owner, out AppearanceComponent appearance))
return;
bool open = SubscribedSessions.Count != 0;
@@ -102,7 +102,7 @@ namespace Content.Server.Storage.Components
appearance.SetData(StorageVisuals.Open, open);
appearance.SetData(SharedBagOpenVisuals.BagState, open ? SharedBagState.Open : SharedBagState.Closed);
if (_entityManager.HasComponent<ItemCounterComponent>(((IComponent) this).Owner))
if (_entityManager.HasComponent<ItemCounterComponent>(Owner))
appearance.SetData(StackVisuals.Hide, !open);
}
@@ -402,7 +402,7 @@ namespace Content.Server.Storage.Components
{
if (_entityManager.TryGetComponent(entity, out ServerStorageComponent storageComponent))
{
DebugTools.Assert(storageComponent != this, $"Storage component contains itself!? Entity: {((IComponent) this).Owner}");
DebugTools.Assert(storageComponent != this, $"Storage component contains itself!? Entity: {Owner}");
storageComponent.UnsubscribeSession(session);
}

View File

@@ -365,7 +365,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
_entities.GetComponent<TransformComponent>(projectile).WorldRotation = projectileAngle + MathHelper.PiOver2;
}
_entities.EventBus.RaiseLocalEvent(((IComponent) this).Owner, new GunShotEvent(firedProjectiles));
_entities.EventBus.RaiseLocalEvent(Owner, new GunShotEvent(firedProjectiles));
_entities.EventBus.RaiseLocalEvent(ammo, new AmmoShotEvent(firedProjectiles));
}

View File

@@ -86,7 +86,7 @@ namespace Content.Shared.Actions.Components
if (_holderActionsComponent == null) return;
foreach (var (actionType, state) in _actions)
{
_holderActionsComponent.GrantOrUpdateItemAction(actionType, ((IComponent) this).Owner, state);
_holderActionsComponent.GrantOrUpdateItemAction(actionType, Owner, state);
}
}
@@ -95,7 +95,7 @@ namespace Content.Shared.Actions.Components
if (_holderActionsComponent == null) return;
foreach (var (actionType, state) in _actions)
{
_holderActionsComponent.RevokeItemAction(actionType, ((IComponent) this).Owner);
_holderActionsComponent.RevokeItemAction(actionType, Owner);
}
}
@@ -152,7 +152,7 @@ namespace Content.Shared.Actions.Components
if (!dirty) return;
_actions[actionType] = actionState;
_holderActionsComponent?.GrantOrUpdateItemAction(actionType, ((IComponent) this).Owner, actionState);
_holderActionsComponent?.GrantOrUpdateItemAction(actionType, Owner, actionState);
}
/// <summary>

View File

@@ -146,7 +146,7 @@ namespace Content.Shared.Body.Components
var argsAdded = new BodyPartAddedEventArgs(slot.Id, part);
EntitySystem.Get<SharedHumanoidAppearanceSystem>().BodyPartAdded(((IComponent) this).Owner, argsAdded);
EntitySystem.Get<SharedHumanoidAppearanceSystem>().BodyPartAdded(Owner, argsAdded);
foreach (var component in IoCManager.Resolve<IEntityManager>().GetComponents<IBodyPartAdded>(Owner).ToArray())
{
component.BodyPartAdded(argsAdded);
@@ -174,7 +174,7 @@ namespace Content.Shared.Body.Components
var args = new BodyPartRemovedEventArgs(slot.Id, part);
EntitySystem.Get<SharedHumanoidAppearanceSystem>().BodyPartRemoved(((IComponent) this).Owner, args);
EntitySystem.Get<SharedHumanoidAppearanceSystem>().BodyPartRemoved(Owner, args);
foreach (var component in IoCManager.Resolve<IEntityManager>().GetComponents<IBodyPartRemoved>(Owner))
{
component.BodyPartRemoved(args);
@@ -184,7 +184,7 @@ namespace Content.Shared.Body.Components
if (part.PartType == BodyPartType.Leg &&
GetPartsOfType(BodyPartType.Leg).ToArray().Length == 0)
{
EntitySystem.Get<StandingStateSystem>().Down(((IComponent) this).Owner);
EntitySystem.Get<StandingStateSystem>().Down(Owner);
}
if (part.IsVital && SlotParts.Count(x => x.Value.PartType == part.PartType) == 0)

View File

@@ -37,11 +37,11 @@ namespace Content.Shared.Body.Components
{
if (old.Body == null)
{
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(((IComponent) this).Owner, new RemovedFromPartEvent(old));
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(Owner, new RemovedFromPartEvent(old));
}
else
{
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(((IComponent) this).Owner, new RemovedFromPartInBodyEvent(old.Body, old));
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(Owner, new RemovedFromPartInBodyEvent(old.Body, old));
}
}
@@ -49,11 +49,11 @@ namespace Content.Shared.Body.Components
{
if (value.Body == null)
{
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(((IComponent) this).Owner, new AddedToPartEvent(value));
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(Owner, new AddedToPartEvent(value));
}
else
{
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(((IComponent) this).Owner, new AddedToPartInBodyEvent(value.Body, value));
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(Owner, new AddedToPartInBodyEvent(value.Body, value));
}
}
}

View File

@@ -95,7 +95,7 @@ namespace Content.Shared.Damage
damage.DamageDict.Add(typeID, damageValue);
}
var actual = EntitySystem.Get<DamageableSystem>().TryChangeDamage(((IComponent) this).Owner, damage);
var actual = EntitySystem.Get<DamageableSystem>().TryChangeDamage(Owner, damage);
// should logging be disabled during rad storms? a lot of entities are going to be damaged.
if (actual != null && !actual.Empty)
@@ -120,7 +120,7 @@ namespace Content.Shared.Damage
damage.DamageDict.Add(typeID, damageValue);
}
var actual = EntitySystem.Get<DamageableSystem>().TryChangeDamage(((IComponent) this).Owner, damage);
var actual = EntitySystem.Get<DamageableSystem>().TryChangeDamage(Owner, damage);
// will logging handle nukes?
if (actual != null && !actual.Empty)

View File

@@ -433,7 +433,7 @@ namespace Content.Shared.Hands.Components
/// </summary>
private bool PlayerCanDrop()
{
if (!IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<ActionBlockerSystem>().CanDrop(((IComponent) this).Owner))
if (!IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<ActionBlockerSystem>().CanDrop(Owner))
return false;
return true;

View File

@@ -291,7 +291,7 @@ namespace Content.Shared.MobState.Components
{
if (!current.HasValue)
{
old?.ExitState(((IComponent) this).Owner, IoCManager.Resolve<IEntityManager>());
old?.ExitState(Owner, IoCManager.Resolve<IEntityManager>());
return;
}
@@ -301,16 +301,16 @@ namespace Content.Shared.MobState.Components
if (state == old)
{
state.UpdateState(((IComponent) this).Owner, threshold, IoCManager.Resolve<IEntityManager>());
state.UpdateState(Owner, threshold, IoCManager.Resolve<IEntityManager>());
return;
}
old?.ExitState(((IComponent) this).Owner, IoCManager.Resolve<IEntityManager>());
old?.ExitState(Owner, IoCManager.Resolve<IEntityManager>());
CurrentState = state;
state.EnterState(((IComponent) this).Owner, IoCManager.Resolve<IEntityManager>());
state.UpdateState(((IComponent) this).Owner, threshold, IoCManager.Resolve<IEntityManager>());
state.EnterState(Owner, IoCManager.Resolve<IEntityManager>());
state.UpdateState(Owner, threshold, IoCManager.Resolve<IEntityManager>());
var message = new MobStateChangedMessage(this, old, state);
#pragma warning disable 618