Inline OwnerUid

This commit is contained in:
Vera Aguilera Puerto
2021-12-03 16:30:34 +01:00
parent 2eacf98335
commit f386b57148
85 changed files with 219 additions and 215 deletions

View File

@@ -86,7 +86,7 @@ namespace Content.Shared.Actions.Components
if (_holderActionsComponent == null) return;
foreach (var (actionType, state) in _actions)
{
_holderActionsComponent.GrantOrUpdateItemAction(actionType, OwnerUid, state);
_holderActionsComponent.GrantOrUpdateItemAction(actionType, ((IComponent) this).Owner, state);
}
}
@@ -95,7 +95,7 @@ namespace Content.Shared.Actions.Components
if (_holderActionsComponent == null) return;
foreach (var (actionType, state) in _actions)
{
_holderActionsComponent.RevokeItemAction(actionType, OwnerUid);
_holderActionsComponent.RevokeItemAction(actionType, ((IComponent) this).Owner);
}
}
@@ -152,7 +152,7 @@ namespace Content.Shared.Actions.Components
if (!dirty) return;
_actions[actionType] = actionState;
_holderActionsComponent?.GrantOrUpdateItemAction(actionType, OwnerUid, actionState);
_holderActionsComponent?.GrantOrUpdateItemAction(actionType, ((IComponent) this).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(OwnerUid, argsAdded);
EntitySystem.Get<SharedHumanoidAppearanceSystem>().BodyPartAdded(((IComponent) this).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(OwnerUid, args);
EntitySystem.Get<SharedHumanoidAppearanceSystem>().BodyPartRemoved(((IComponent) this).Owner, args);
foreach (var component in IoCManager.Resolve<IEntityManager>().GetComponents<IBodyPartRemoved>(Owner))
{
component.BodyPartRemoved(args);
@@ -184,14 +184,14 @@ namespace Content.Shared.Body.Components
if (part.PartType == BodyPartType.Leg &&
GetPartsOfType(BodyPartType.Leg).ToArray().Length == 0)
{
EntitySystem.Get<StandingStateSystem>().Down(OwnerUid);
EntitySystem.Get<StandingStateSystem>().Down(((IComponent) this).Owner);
}
if (part.IsVital && SlotParts.Count(x => x.Value.PartType == part.PartType) == 0)
{
// TODO BODY SYSTEM KILL : Find a more elegant way of killing em than just dumping bloodloss damage.
var damage = new DamageSpecifier(_prototypeManager.Index<DamageTypePrototype>("Bloodloss"), 300);
EntitySystem.Get<DamageableSystem>().TryChangeDamage(part.OwnerUid, damage);
EntitySystem.Get<DamageableSystem>().TryChangeDamage(((IComponent) part).Owner, damage);
}
OnBodyChanged();
@@ -468,7 +468,7 @@ namespace Content.Shared.Body.Components
var i = 0;
foreach (var (part, slot) in SlotParts)
{
parts[i] = (slot.Id, part.OwnerUid);
parts[i] = (slot.Id, OwnerUid: ((IComponent) part).Owner);
i++;
}

View File

@@ -305,7 +305,7 @@ namespace Content.Shared.Body.Components
foreach (var mechanism in _mechanisms)
{
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(mechanism.OwnerUid, new AddedToBodyEvent(body));
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(((IComponent) mechanism).Owner, new AddedToBodyEvent(body));
}
}
@@ -320,7 +320,7 @@ namespace Content.Shared.Body.Components
foreach (var mechanism in _mechanisms)
{
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(mechanism.OwnerUid, new RemovedFromBodyEvent(old));
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(((IComponent) mechanism).Owner, new RemovedFromBodyEvent(old));
}
}

View File

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

View File

@@ -57,7 +57,7 @@ namespace Content.Shared.Buckle
private void PreventCollision(EntityUid uid, SharedBuckleComponent component, PreventCollideEvent args)
{
if (args.BodyB.OwnerUid != component.LastEntityBuckledTo) return;
if (args.BodyB.Owner != component.LastEntityBuckledTo) return;
component.IsOnStrapEntityThisFrame = true;
if (component.Buckled || component.DontCollide)

View File

@@ -75,9 +75,9 @@ namespace Content.Shared.Chemistry
if (component.ModifierTimer > currentTime) continue;
_components.RemoveAt(i);
EntityManager.RemoveComponent<MovespeedModifierMetabolismComponent>(component.OwnerUid);
EntityManager.RemoveComponent<MovespeedModifierMetabolismComponent>(((IComponent) component).Owner);
_movespeed.RefreshMovementSpeedModifiers(component.OwnerUid);
_movespeed.RefreshMovementSpeedModifiers(((IComponent) component).Owner);
}
}
}

View File

@@ -95,7 +95,7 @@ namespace Content.Shared.Damage
damage.DamageDict.Add(typeID, damageValue);
}
var actual = EntitySystem.Get<DamageableSystem>().TryChangeDamage(OwnerUid, damage);
var actual = EntitySystem.Get<DamageableSystem>().TryChangeDamage(((IComponent) this).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(OwnerUid, damage);
var actual = EntitySystem.Get<DamageableSystem>().TryChangeDamage(((IComponent) this).Owner, damage);
// will logging handle nukes?
if (actual != null && !actual.Empty)

View File

@@ -128,9 +128,9 @@ namespace Content.Shared.Damage
SetTotalDamage(component, component.Damage.Total, logChange);
component.Dirty();
if (EntityManager.TryGetComponent<AppearanceComponent>(component.OwnerUid, out var appearance) && damageDelta != null)
if (EntityManager.TryGetComponent<AppearanceComponent>(((IComponent) component).Owner, out var appearance) && damageDelta != null)
appearance.SetData(DamageVisualizerKeys.DamageUpdateGroups, damageDelta.GetDamagePerGroup().Keys.ToList());
RaiseLocalEvent(component.OwnerUid, new DamageChangedEvent(component, damageDelta, interruptsDoAfters), false);
RaiseLocalEvent(((IComponent) component).Owner, new DamageChangedEvent(component, damageDelta, interruptsDoAfters), false);
}
/// <summary>

View File

@@ -31,7 +31,7 @@ namespace Content.Shared.Disposal
private void HandlePreventCollide(EntityUid uid, SharedDisposalUnitComponent component, PreventCollideEvent args)
{
var otherBody = args.BodyB.OwnerUid;
var otherBody = args.BodyB.Owner;
// Items dropped shouldn't collide but items thrown should
if (EntityManager.HasComponent<SharedItemComponent>(otherBody) &&

View File

@@ -56,7 +56,7 @@ namespace Content.Shared.Friction
if (body.Deleted ||
prediction && !body.Predict ||
body.BodyStatus == BodyStatus.InAir ||
Mover.UseMobMovement(body.OwnerUid)) continue;
Mover.UseMobMovement(((IComponent) body).Owner)) continue;
var surfaceFriction = GetTileFriction(body);
var bodyModifier = IoCManager.Resolve<IEntityManager>().GetComponentOrNull<SharedTileFrictionModifier>(body.Owner)?.Modifier ?? 1.0f;

View File

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

View File

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

View File

@@ -36,7 +36,7 @@ public class SlowContactsSystem : EntitySystem
foreach (var colliding in _physics.GetCollidingEntities(physicsComponent))
{
var ent = colliding.OwnerUid;
var ent = ((IComponent) colliding).Owner;
if (!EntityManager.TryGetComponent<SlowContactsComponent>(ent, out var slowContactsComponent))
continue;
@@ -49,7 +49,7 @@ public class SlowContactsSystem : EntitySystem
private void OnEntityExit(EntityUid uid, SlowContactsComponent component, EndCollideEvent args)
{
var otherUid = args.OtherFixture.Body.OwnerUid;
var otherUid = ((IComponent) args.OtherFixture.Body).Owner;
if (!EntityManager.HasComponent<MovementSpeedModifierComponent>(otherUid)
|| !EntityManager.HasComponent<SlowsOnContactComponent>(otherUid))
return;
@@ -64,7 +64,7 @@ public class SlowContactsSystem : EntitySystem
private void OnEntityEnter(EntityUid uid, SlowContactsComponent component, StartCollideEvent args)
{
var otherUid = args.OtherFixture.Body.OwnerUid;
var otherUid = ((IComponent) args.OtherFixture.Body).Owner;
if (!EntityManager.HasComponent<MovementSpeedModifierComponent>(otherUid))
return;
if (!_statusCapableInContact.ContainsKey(otherUid))

View File

@@ -96,15 +96,15 @@ namespace Content.Shared.Movement
protected void HandleMobMovement(IMoverComponent mover, PhysicsComponent physicsComponent,
IMobMoverComponent mobMover)
{
DebugTools.Assert(!UsedMobMovement.ContainsKey(mover.OwnerUid));
DebugTools.Assert(!UsedMobMovement.ContainsKey(mover.Owner));
if (!UseMobMovement(physicsComponent))
{
UsedMobMovement[mover.OwnerUid] = false;
UsedMobMovement[mover.Owner] = false;
return;
}
UsedMobMovement[mover.OwnerUid] = true;
UsedMobMovement[mover.Owner] = true;
var transform = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(mover.Owner);
var weightless = mover.Owner.IsWeightless(physicsComponent, mapManager: _mapManager, entityManager: _entityManager);
var (walkDir, sprintDir) = mover.VelocityDir;
@@ -167,7 +167,7 @@ namespace Content.Shared.Movement
IoCManager.Resolve<IEntityManager>().HasComponent<MobStateComponent>(body.Owner) &&
// If we're being pulled then don't mess with our velocity.
(!IoCManager.Resolve<IEntityManager>().TryGetComponent(body.Owner, out SharedPullableComponent? pullable) || !pullable.BeingPulled) &&
_blocker.CanMove(body.OwnerUid);
_blocker.CanMove(((IComponent) body).Owner);
}
/// <summary>

View File

@@ -13,7 +13,7 @@ namespace Content.Shared.Projectiles
private void PreventCollision(EntityUid uid, SharedProjectileComponent component, PreventCollideEvent args)
{
if (component.IgnoreShooter && args.BodyB.OwnerUid == component.Shooter)
if (component.IgnoreShooter && args.BodyB.Owner == component.Shooter)
{
args.Cancel();
return;

View File

@@ -45,7 +45,7 @@ namespace Content.Shared.Pulling.Systems
SharedPullerComponent component,
PullStartedMessage args)
{
if (args.Puller.OwnerUid != uid)
if (args.Puller.Owner != uid)
return;
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(component.Owner, out SharedAlertsComponent? alerts))
@@ -59,7 +59,7 @@ namespace Content.Shared.Pulling.Systems
SharedPullerComponent component,
PullStoppedMessage args)
{
if (args.Puller.OwnerUid != uid)
if (args.Puller.Owner != uid)
return;
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(component.Owner, out SharedAlertsComponent? alerts))
@@ -75,7 +75,7 @@ namespace Content.Shared.Pulling.Systems
private void RefreshMovementSpeed(SharedPullerComponent component)
{
_movementSpeedModifierSystem.RefreshMovementSpeedModifiers(component.OwnerUid);
_movementSpeedModifierSystem.RefreshMovementSpeedModifiers(((IComponent) component).Owner);
}
}
}

View File

@@ -59,10 +59,10 @@ namespace Content.Shared.Pulling
// Messaging
var message = new PullStoppedMessage(pullerPhysics, pullablePhysics);
RaiseLocalEvent(puller.OwnerUid, message, broadcast: false);
RaiseLocalEvent(((IComponent) puller).Owner, message, broadcast: false);
if ((!IoCManager.Resolve<IEntityManager>().EntityExists(pullable.Owner) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(pullable.Owner).EntityLifeStage) <= EntityLifeStage.MapInitialized)
RaiseLocalEvent(pullable.OwnerUid, message);
RaiseLocalEvent(((IComponent) pullable).Owner, message);
// Networking
puller.Dirty();
@@ -106,7 +106,7 @@ namespace Content.Shared.Pulling
var union = pullerPhysics.GetWorldAABB().Union(pullablePhysics.GetWorldAABB());
var length = Math.Max(union.Size.X, union.Size.Y) * 0.75f;
pullable.PullJoint = _jointSystem.CreateDistanceJoint(pullablePhysics.OwnerUid, pullerPhysics.Owner, id:$"pull-joint-{pullablePhysics.Owner}");
pullable.PullJoint = _jointSystem.CreateDistanceJoint(((IComponent) pullablePhysics).Owner, pullerPhysics.Owner, id:$"pull-joint-{pullablePhysics.Owner}");
pullable.PullJoint.CollideConnected = false;
// This maximum has to be there because if the object is constrained too closely, the clamping goes backwards and asserts.
pullable.PullJoint.MaxLength = Math.Max(1.0f, length);
@@ -117,8 +117,8 @@ namespace Content.Shared.Pulling
// Messaging
var message = new PullStartedMessage(pullerPhysics, pullablePhysics);
RaiseLocalEvent(puller.OwnerUid, message, broadcast: false);
RaiseLocalEvent(pullable.OwnerUid, message);
RaiseLocalEvent(((IComponent) puller).Owner, message, broadcast: false);
RaiseLocalEvent(((IComponent) pullable).Owner, message);
// Networking
puller.Dirty();

View File

@@ -92,7 +92,7 @@ namespace Content.Shared.Pulling
}
var msg = new StopPullingEvent(user);
RaiseLocalEvent(pullable.OwnerUid, msg);
RaiseLocalEvent(((IComponent) pullable).Owner, msg);
if (msg.Cancelled) return false;
@@ -173,14 +173,14 @@ namespace Content.Shared.Pulling
var pullAttempt = new PullAttemptMessage(pullerPhysics, pullablePhysics);
RaiseLocalEvent(puller.OwnerUid, pullAttempt, broadcast: false);
RaiseLocalEvent(((IComponent) puller).Owner, pullAttempt, broadcast: false);
if (pullAttempt.Cancelled)
{
return false;
}
RaiseLocalEvent(pullable.OwnerUid, pullAttempt);
RaiseLocalEvent(((IComponent) pullable).Owner, pullAttempt);
if (pullAttempt.Cancelled)
{

View File

@@ -102,7 +102,7 @@ namespace Content.Shared.Pulling
// Raise a "you are being pulled" alert if the pulled entity has alerts.
private static void PullableHandlePullStarted(EntityUid uid, SharedPullableComponent component, PullStartedMessage args)
{
if (args.Pulled.OwnerUid != uid)
if (args.Pulled.Owner != uid)
return;
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(component.Owner, out SharedAlertsComponent? alerts))
@@ -111,7 +111,7 @@ namespace Content.Shared.Pulling
private static void PullableHandlePullStopped(EntityUid uid, SharedPullableComponent component, PullStoppedMessage args)
{
if (args.Pulled.OwnerUid != uid)
if (args.Pulled.Owner != uid)
return;
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(component.Owner, out SharedAlertsComponent? alerts))

View File

@@ -50,7 +50,10 @@ namespace Content.Shared.Shuttles.Components
public override ComponentState GetComponentState()
{
return new PilotComponentState(Console?.OwnerUid);
if(Console == null)
return new
return new PilotComponentState(((IComponent) Console).Owner);
}
[Serializable, NetSerializable]

View File

@@ -33,7 +33,7 @@ namespace Content.Shared.Slippery
private void HandleCollide(EntityUid uid, SlipperyComponent component, StartCollideEvent args)
{
var otherUid = args.OtherFixture.Body.OwnerUid;
var otherUid = ((IComponent) args.OtherFixture.Body).Owner;
if (!CanSlip(component, otherUid)) return;
@@ -74,7 +74,7 @@ namespace Content.Shared.Slippery
private bool TrySlip(SlipperyComponent component, IPhysBody ourBody, IPhysBody otherBody)
{
if (!CanSlip(component, otherBody.OwnerUid)) return false;
if (!CanSlip(component, otherBody.Owner)) return false;
if (otherBody.LinearVelocity.Length < component.RequiredSlipSpeed)
{
@@ -89,14 +89,14 @@ namespace Content.Shared.Slippery
}
var ev = new SlipAttemptEvent();
RaiseLocalEvent(otherBody.OwnerUid, ev, false);
RaiseLocalEvent(otherBody.Owner, ev, false);
if (ev.Cancelled)
return false;
otherBody.LinearVelocity *= component.LaunchForwardsMultiplier;
_stunSystem.TryParalyze(otherBody.OwnerUid, TimeSpan.FromSeconds(5));
component.Slipped.Add(otherBody.OwnerUid);
_stunSystem.TryParalyze(otherBody.Owner, TimeSpan.FromSeconds(5));
component.Slipped.Add(otherBody.Owner);
component.Dirty();
PlaySound(component);