Remove 700 usages of Component.Owner (#21100)
This commit is contained in:
@@ -65,7 +65,8 @@ namespace Content.Server.Bible
|
||||
}
|
||||
_remQueue.Clear();
|
||||
|
||||
foreach (var (respawning, summonableComp) in EntityQuery<SummonableRespawningComponent, SummonableComponent>())
|
||||
var query = EntityQueryEnumerator<SummonableRespawningComponent, SummonableComponent>();
|
||||
while (query.MoveNext(out var uid, out var respawning, out var summonableComp))
|
||||
{
|
||||
summonableComp.Accumulator += frameTime;
|
||||
if (summonableComp.Accumulator < summonableComp.RespawnTime)
|
||||
@@ -79,11 +80,11 @@ namespace Content.Server.Bible
|
||||
summonableComp.Summon = null;
|
||||
}
|
||||
summonableComp.AlreadySummoned = false;
|
||||
_popupSystem.PopupEntity(Loc.GetString("bible-summon-respawn-ready", ("book", summonableComp.Owner)), summonableComp.Owner, PopupType.Medium);
|
||||
SoundSystem.Play("/Audio/Effects/radpulse9.ogg", Filter.Pvs(summonableComp.Owner), summonableComp.Owner, AudioParams.Default.WithVolume(-4f));
|
||||
_popupSystem.PopupEntity(Loc.GetString("bible-summon-respawn-ready", ("book", uid)), uid, PopupType.Medium);
|
||||
SoundSystem.Play("/Audio/Effects/radpulse9.ogg", Filter.Pvs(uid), uid, AudioParams.Default.WithVolume(-4f));
|
||||
// Clean up the accumulator and respawn tracking component
|
||||
summonableComp.Accumulator = 0;
|
||||
_remQueue.Enqueue(respawning.Owner);
|
||||
_remQueue.Enqueue(uid);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -167,7 +168,7 @@ namespace Content.Server.Bible
|
||||
{
|
||||
if (!TryComp<TransformComponent>(args.User, out var userXform)) return;
|
||||
|
||||
AttemptSummon(component, args.User, userXform);
|
||||
AttemptSummon((uid, component), args.User, userXform);
|
||||
},
|
||||
Text = Loc.GetString("bible-summon-verb"),
|
||||
Priority = 2
|
||||
@@ -183,9 +184,9 @@ namespace Content.Server.Bible
|
||||
args.AddAction(ref component.SummonActionEntity, component.SummonAction);
|
||||
}
|
||||
|
||||
private void OnSummon(EntityUid uid, SummonableComponent component, SummonActionEvent args)
|
||||
private void OnSummon(Entity<SummonableComponent> ent, ref SummonActionEvent args)
|
||||
{
|
||||
AttemptSummon(component, args.Performer, Transform(args.Performer));
|
||||
AttemptSummon(ent, args.Performer, Transform(args.Performer));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -198,9 +199,9 @@ namespace Content.Server.Bible
|
||||
return;
|
||||
|
||||
var source = component.Source;
|
||||
if (source != null && TryComp<SummonableComponent>(source, out var summonable))
|
||||
if (source != null && HasComp<SummonableComponent>(source))
|
||||
{
|
||||
_addQueue.Enqueue(summonable.Owner);
|
||||
_addQueue.Enqueue(source.Value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -209,24 +210,26 @@ namespace Content.Server.Bible
|
||||
/// </summary>
|
||||
private void OnSpawned(EntityUid uid, FamiliarComponent component, GhostRoleSpawnerUsedEvent args)
|
||||
{
|
||||
if (!TryComp<SummonableComponent>(Transform(args.Spawner).ParentUid, out var summonable))
|
||||
var parent = Transform(args.Spawner).ParentUid;
|
||||
if (!TryComp<SummonableComponent>(parent, out var summonable))
|
||||
return;
|
||||
|
||||
component.Source = summonable.Owner;
|
||||
component.Source = parent;
|
||||
summonable.Summon = uid;
|
||||
}
|
||||
|
||||
private void AttemptSummon(SummonableComponent component, EntityUid user, TransformComponent? position)
|
||||
private void AttemptSummon(Entity<SummonableComponent> ent, EntityUid user, TransformComponent? position)
|
||||
{
|
||||
var (uid, component) = ent;
|
||||
if (component.AlreadySummoned || component.SpecialItemPrototype == null)
|
||||
return;
|
||||
if (component.RequiresBibleUser && !HasComp<BibleUserComponent>(user))
|
||||
return;
|
||||
if (!Resolve(user, ref position))
|
||||
return;
|
||||
if (component.Deleted || Deleted(component.Owner))
|
||||
if (component.Deleted || Deleted(uid))
|
||||
return;
|
||||
if (!_blocker.CanInteract(user, component.Owner))
|
||||
if (!_blocker.CanInteract(user, uid))
|
||||
return;
|
||||
|
||||
// Make this familiar the component's summon
|
||||
@@ -237,7 +240,7 @@ namespace Content.Server.Bible
|
||||
if (HasComp<GhostRoleMobSpawnerComponent>(familiar))
|
||||
{
|
||||
_popupSystem.PopupEntity(Loc.GetString("bible-summon-requested"), user, PopupType.Medium);
|
||||
Transform(familiar).AttachParent(component.Owner);
|
||||
Transform(familiar).AttachParent(uid);
|
||||
}
|
||||
component.AlreadySummoned = true;
|
||||
_actionsSystem.RemoveAction(user, component.SummonActionEntity);
|
||||
|
||||
Reference in New Issue
Block a user