Remove some obsolete AppearanceComponent method usages (#13726)

This commit is contained in:
Visne
2023-02-02 17:34:53 +01:00
committed by GitHub
parent 23b90de34d
commit 5a5a3afbb1
111 changed files with 428 additions and 349 deletions

View File

@@ -19,6 +19,7 @@ namespace Content.Server.Light.EntitySystems
{
[Dependency] private readonly AmbientSoundSystem _ambient = default!;
[Dependency] private readonly StationSystem _station = default!;
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
public override void Initialize()
{
@@ -110,7 +111,7 @@ namespace Content.Server.Light.EntitySystems
continue;
pointLight.Color = details.EmergencyLightColor;
appearance.SetData(EmergencyLightVisuals.Color, details.EmergencyLightColor);
_appearance.SetData(appearance.Owner, EmergencyLightVisuals.Color, details.EmergencyLightColor, appearance);
if (details.ForceEnableEmergencyLights && !light.ForciblyEnabled)
{
@@ -198,7 +199,7 @@ namespace Content.Server.Light.EntitySystems
}
if (TryComp(component.Owner, out AppearanceComponent? appearance))
appearance.SetData(EmergencyLightVisuals.On, false);
_appearance.SetData(appearance.Owner, EmergencyLightVisuals.On, false, appearance);
_ambient.SetAmbience(component.Owner, false);
}
@@ -212,7 +213,7 @@ namespace Content.Server.Light.EntitySystems
if (TryComp(component.Owner, out AppearanceComponent? appearance))
{
appearance.SetData(EmergencyLightVisuals.On, true);
_appearance.SetData(appearance.Owner, EmergencyLightVisuals.On, true, appearance);
}
_ambient.SetAmbience(component.Owner, true);

View File

@@ -21,6 +21,7 @@ namespace Content.Server.Light.EntitySystems
[Dependency] private readonly ClothingSystem _clothing = default!;
[Dependency] private readonly TagSystem _tagSystem = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
public override void Initialize()
{
@@ -107,20 +108,20 @@ namespace Content.Server.Light.EntitySystems
{
if (!Resolve(component.Owner, ref appearance, false)) return;
appearance.SetData(ExpendableLightVisuals.State, component.CurrentState);
_appearance.SetData(appearance.Owner, ExpendableLightVisuals.State, component.CurrentState, appearance);
switch (component.CurrentState)
{
case ExpendableLightState.Lit:
appearance.SetData(ExpendableLightVisuals.Behavior, component.TurnOnBehaviourID);
_appearance.SetData(appearance.Owner, ExpendableLightVisuals.Behavior, component.TurnOnBehaviourID, appearance);
break;
case ExpendableLightState.Fading:
appearance.SetData(ExpendableLightVisuals.Behavior, component.FadeOutBehaviourID);
_appearance.SetData(appearance.Owner, ExpendableLightVisuals.Behavior, component.FadeOutBehaviourID, appearance);
break;
case ExpendableLightState.Dead:
appearance.SetData(ExpendableLightVisuals.Behavior, string.Empty);
_appearance.SetData(appearance.Owner, ExpendableLightVisuals.Behavior, string.Empty, appearance);
var isHotEvent = new IsHotEvent() {IsHot = true};
RaiseLocalEvent(component.Owner, isHotEvent);
break;

View File

@@ -2,6 +2,7 @@ using Content.Server.Light.Components;
using Content.Shared.Destructible;
using Content.Shared.Light;
using Content.Shared.Throwing;
using Robust.Server.GameObjects;
using Robust.Shared.Audio;
using Robust.Shared.Player;
@@ -9,6 +10,8 @@ namespace Content.Server.Light.EntitySystems
{
public sealed class LightBulbSystem : EntitySystem
{
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
public override void Initialize()
{
base.Initialize();
@@ -75,8 +78,8 @@ namespace Content.Server.Light.EntitySystems
return;
// try to update appearance and color
appearance.SetData(LightBulbVisuals.State, bulb.State);
appearance.SetData(LightBulbVisuals.Color, bulb.Color);
_appearance.SetData(uid, LightBulbVisuals.State, bulb.State, appearance);
_appearance.SetData(uid, LightBulbVisuals.Color, bulb.Color, appearance);
}
}
}

View File

@@ -21,7 +21,7 @@ namespace Content.Server.Light.EntitySystems
&& EntityManager.TryGetComponent<MatchstickComponent?>(args.Used, out var matchstick)
&& matchstick.CurrentState == SmokableState.Unlit)
{
_stickSystem.Ignite(matchstick, args.User);
_stickSystem.Ignite(uid, matchstick, args.User);
args.Handled = true;
}
}

View File

@@ -13,10 +13,12 @@ namespace Content.Server.Light.EntitySystems
{
public sealed class MatchstickSystem : EntitySystem
{
private HashSet<MatchstickComponent> _litMatches = new();
[Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!;
[Dependency] private readonly TransformSystem _transformSystem = default!;
[Dependency] private readonly SharedItemSystem _item = default!;
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
private HashSet<MatchstickComponent> _litMatches = new();
public override void Initialize()
{
@@ -61,7 +63,7 @@ namespace Content.Server.Light.EntitySystems
if (!isHotEvent.IsHot)
return;
Ignite(component, args.User);
Ignite(uid, component, args.User);
args.Handled = true;
}
@@ -70,23 +72,23 @@ namespace Content.Server.Light.EntitySystems
args.IsHot = component.CurrentState == SmokableState.Lit;
}
public void Ignite(MatchstickComponent component, EntityUid user)
public void Ignite(EntityUid uid, MatchstickComponent component, EntityUid user)
{
// Play Sound
SoundSystem.Play(component.IgniteSound.GetSound(), Filter.Pvs(component.Owner),
component.Owner, AudioHelpers.WithVariation(0.125f).WithVolume(-0.125f));
// Change state
SetState(component, SmokableState.Lit);
SetState(uid, component, SmokableState.Lit);
_litMatches.Add(component);
component.Owner.SpawnTimer(component.Duration * 1000, delegate
{
SetState(component, SmokableState.Burnt);
SetState(uid, component, SmokableState.Burnt);
_litMatches.Remove(component);
});
}
private void SetState(MatchstickComponent component, SmokableState value)
private void SetState(EntityUid uid, MatchstickComponent component, SmokableState value)
{
component.CurrentState = value;
@@ -110,7 +112,7 @@ namespace Content.Server.Light.EntitySystems
if (EntityManager.TryGetComponent(component.Owner, out AppearanceComponent? appearance))
{
appearance.SetData(SmokingVisuals.Smoking, component.CurrentState);
_appearance.SetData(uid, SmokingVisuals.Smoking, component.CurrentState, appearance);
}
}
}

View File

@@ -39,6 +39,7 @@ namespace Content.Server.Light.EntitySystems
[Dependency] private readonly SignalLinkerSystem _signalSystem = default!;
[Dependency] private readonly SharedContainerSystem _containerSystem = default!;
[Dependency] private readonly DoAfterSystem _doAfterSystem = default!;
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
private static readonly TimeSpan ThunkDelay = TimeSpan.FromSeconds(2);
public const string LightBulbContainer = "light_bulb";
@@ -270,7 +271,7 @@ namespace Content.Server.Light.EntitySystems
{
SetLight(uid, false, light: light);
powerReceiver.Load = 0;
appearance?.SetData(PoweredLightVisuals.BulbState, PoweredLightState.Empty);
_appearance.SetData(uid, PoweredLightVisuals.BulbState, PoweredLightState.Empty, appearance);
return;
}
@@ -280,7 +281,7 @@ namespace Content.Server.Light.EntitySystems
if (powerReceiver.Powered && light.On)
{
SetLight(uid, true, lightBulb.Color, light, lightBulb.LightRadius, lightBulb.LightEnergy, lightBulb.LightSoftness);
appearance?.SetData(PoweredLightVisuals.BulbState, PoweredLightState.On);
_appearance.SetData(uid, PoweredLightVisuals.BulbState, PoweredLightState.On, appearance);
var time = _gameTiming.CurTime;
if (time > light.LastThunk + ThunkDelay)
{
@@ -291,16 +292,16 @@ namespace Content.Server.Light.EntitySystems
else
{
SetLight(uid, false, light: light);
appearance?.SetData(PoweredLightVisuals.BulbState, PoweredLightState.Off);
_appearance.SetData(uid, PoweredLightVisuals.BulbState, PoweredLightState.Off, appearance);
}
break;
case LightBulbState.Broken:
SetLight(uid, false, light: light);
appearance?.SetData(PoweredLightVisuals.BulbState, PoweredLightState.Broken);
_appearance.SetData(uid, PoweredLightVisuals.BulbState, PoweredLightState.Broken, appearance);
break;
case LightBulbState.Burned:
SetLight(uid, false, light: light);
appearance?.SetData(PoweredLightVisuals.BulbState, PoweredLightState.Burned);
_appearance.SetData(uid, PoweredLightVisuals.BulbState, PoweredLightState.Burned, appearance);
break;
}
@@ -335,10 +336,10 @@ namespace Content.Server.Light.EntitySystems
light.LastGhostBlink = time;
ToggleBlinkingLight(light, true);
ToggleBlinkingLight(uid, light, true);
light.Owner.SpawnTimer(light.GhostBlinkingTime, () =>
{
ToggleBlinkingLight(light, false);
ToggleBlinkingLight(uid, light, false);
});
args.Handled = true;
@@ -349,7 +350,7 @@ namespace Content.Server.Light.EntitySystems
UpdateLight(uid, component);
}
public void ToggleBlinkingLight(PoweredLightComponent light, bool isNowBlinking)
public void ToggleBlinkingLight(EntityUid uid, PoweredLightComponent light, bool isNowBlinking)
{
if (light.IsBlinking == isNowBlinking)
return;
@@ -358,7 +359,8 @@ namespace Content.Server.Light.EntitySystems
if (!EntityManager.TryGetComponent(light.Owner, out AppearanceComponent? appearance))
return;
appearance.SetData(PoweredLightVisuals.Blinking, isNowBlinking);
_appearance.SetData(uid, PoweredLightVisuals.Blinking, isNowBlinking, appearance);
}
private void OnSignalReceived(EntityUid uid, PoweredLightComponent component, SignalReceivedEvent args)

View File

@@ -14,6 +14,7 @@ namespace Content.Server.Light.EntitySystems
public sealed class UnpoweredFlashlightSystem : EntitySystem
{
[Dependency] private readonly SharedActionsSystem _actionsSystem = default!;
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
public override void Initialize()
{
@@ -30,7 +31,7 @@ namespace Content.Server.Light.EntitySystems
if (args.Handled)
return;
ToggleLight(component);
ToggleLight(uid, component);
args.Handled = true;
}
@@ -48,7 +49,7 @@ namespace Content.Server.Light.EntitySystems
ActivationVerb verb = new();
verb.Text = Loc.GetString("toggle-flashlight-verb-get-data-text");
verb.IconTexture = "/Textures/Interface/VerbIcons/light.svg.192dpi.png";
verb.Act = () => ToggleLight(component);
verb.Act = () => ToggleLight(uid, component);
verb.Priority = -1; // For things like PDA's, Open-UI and other verbs that should be higher priority.
args.Verbs.Add(verb);
@@ -58,7 +59,7 @@ namespace Content.Server.Light.EntitySystems
{
_actionsSystem.AddAction(uid, component.ToggleAction, null);
}
public void ToggleLight(UnpoweredFlashlightComponent flashlight)
public void ToggleLight(EntityUid uid, UnpoweredFlashlightComponent flashlight)
{
if (!EntityManager.TryGetComponent(flashlight.Owner, out PointLightComponent? light))
return;
@@ -67,7 +68,7 @@ namespace Content.Server.Light.EntitySystems
light.Enabled = flashlight.LightOn;
if (EntityManager.TryGetComponent(flashlight.Owner, out AppearanceComponent? appearance))
appearance.SetData(UnpoweredFlashlightVisuals.LightOn, flashlight.LightOn);
_appearance.SetData(uid, UnpoweredFlashlightVisuals.LightOn, flashlight.LightOn, appearance);
SoundSystem.Play(flashlight.ToggleSound.GetSound(), Filter.Pvs(light.Owner), flashlight.Owner);