Remove 700 usages of Component.Owner (#21100)

This commit is contained in:
DrSmugleaf
2023-10-19 12:34:31 -07:00
committed by GitHub
parent 5825ffb95c
commit f560f88eb5
261 changed files with 2291 additions and 2036 deletions

View File

@@ -19,7 +19,7 @@ namespace Content.Server.Light.EntitySystems
[Dependency] private readonly SharedPointLightSystem _lights = default!;
[Dependency] private readonly TransformSystem _transformSystem = default!;
private HashSet<MatchstickComponent> _litMatches = new();
private readonly HashSet<Entity<MatchstickComponent>> _litMatches = new();
public override void Initialize()
{
@@ -29,42 +29,43 @@ namespace Content.Server.Light.EntitySystems
SubscribeLocalEvent<MatchstickComponent, ComponentShutdown>(OnShutdown);
}
private void OnShutdown(EntityUid uid, MatchstickComponent component, ComponentShutdown args)
private void OnShutdown(Entity<MatchstickComponent> ent, ref ComponentShutdown args)
{
_litMatches.Remove(component);
_litMatches.Remove(ent);
}
public override void Update(float frameTime)
{
base.Update(frameTime);
foreach (var match in _litMatches)
{
if (match.CurrentState != SmokableState.Lit || Paused(match.Owner) || match.Deleted)
if (match.Comp.CurrentState != SmokableState.Lit || Paused(match) || match.Comp.Deleted)
continue;
var xform = Transform(match.Owner);
var xform = Transform(match);
if (xform.GridUid is not {} gridUid)
return;
var position = _transformSystem.GetGridOrMapTilePosition(match.Owner, xform);
var position = _transformSystem.GetGridOrMapTilePosition(match, xform);
_atmosphereSystem.HotspotExpose(gridUid, position, 400, 50, match.Owner, true);
_atmosphereSystem.HotspotExpose(gridUid, position, 400, 50, match, true);
}
}
private void OnInteractUsing(EntityUid uid, MatchstickComponent component, InteractUsingEvent args)
private void OnInteractUsing(Entity<MatchstickComponent> ent, ref InteractUsingEvent args)
{
if (args.Handled || component.CurrentState != SmokableState.Unlit)
if (args.Handled || ent.Comp.CurrentState != SmokableState.Unlit)
return;
var isHotEvent = new IsHotEvent();
RaiseLocalEvent(args.Used, isHotEvent, false);
RaiseLocalEvent(args.Used, isHotEvent);
if (!isHotEvent.IsHot)
return;
Ignite(uid, component, args.User);
Ignite(ent, args.User);
args.Handled = true;
}
@@ -73,19 +74,21 @@ namespace Content.Server.Light.EntitySystems
args.IsHot = component.CurrentState == SmokableState.Lit;
}
public void Ignite(EntityUid uid, MatchstickComponent component, EntityUid user)
public void Ignite(Entity<MatchstickComponent> matchstick, EntityUid user)
{
var component = matchstick.Comp;
// Play Sound
SoundSystem.Play(component.IgniteSound.GetSound(), Filter.Pvs(component.Owner),
component.Owner, AudioHelpers.WithVariation(0.125f).WithVolume(-0.125f));
SoundSystem.Play(component.IgniteSound.GetSound(), Filter.Pvs(matchstick),
matchstick, AudioHelpers.WithVariation(0.125f).WithVolume(-0.125f));
// Change state
SetState(uid, component, SmokableState.Lit);
_litMatches.Add(component);
component.Owner.SpawnTimer(component.Duration * 1000, delegate
SetState(matchstick, component, SmokableState.Lit);
_litMatches.Add(matchstick);
matchstick.Owner.SpawnTimer(component.Duration * 1000, delegate
{
SetState(uid, component, SmokableState.Burnt);
_litMatches.Remove(component);
SetState(matchstick, component, SmokableState.Burnt);
_litMatches.Remove(matchstick);
});
}