Remove server-side sprite references from Flash system (#15893)
This commit is contained in:
@@ -1,9 +1,9 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Content.Server.Flash.Components;
|
using Content.Server.Flash.Components;
|
||||||
using Content.Server.Light.EntitySystems;
|
using Content.Server.Light.EntitySystems;
|
||||||
|
using Content.Server.Popups;
|
||||||
using Content.Server.Stunnable;
|
using Content.Server.Stunnable;
|
||||||
using Content.Shared.Examine;
|
using Content.Shared.Examine;
|
||||||
using Content.Shared.Eye.Blinding;
|
|
||||||
using Content.Shared.Eye.Blinding.Components;
|
using Content.Shared.Eye.Blinding.Components;
|
||||||
using Content.Shared.Flash;
|
using Content.Shared.Flash;
|
||||||
using Content.Shared.IdentityManagement;
|
using Content.Shared.IdentityManagement;
|
||||||
@@ -29,9 +29,11 @@ namespace Content.Server.Flash
|
|||||||
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
||||||
[Dependency] private readonly StunSystem _stunSystem = default!;
|
[Dependency] private readonly StunSystem _stunSystem = default!;
|
||||||
[Dependency] private readonly InventorySystem _inventorySystem = default!;
|
[Dependency] private readonly InventorySystem _inventorySystem = default!;
|
||||||
[Dependency] private readonly MetaDataSystem _metaSystem = default!;
|
[Dependency] private readonly AudioSystem _audio = default!;
|
||||||
[Dependency] private readonly SharedInteractionSystem _interactionSystem = default!;
|
[Dependency] private readonly SharedInteractionSystem _interactionSystem = default!;
|
||||||
[Dependency] private readonly TagSystem _tagSystem = default!;
|
[Dependency] private readonly TagSystem _tagSystem = default!;
|
||||||
|
[Dependency] private readonly PopupSystem _popup = default!;
|
||||||
|
[Dependency] private readonly AppearanceSystem _appearance = default!;
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
@@ -51,7 +53,7 @@ namespace Content.Server.Flash
|
|||||||
{
|
{
|
||||||
if (!args.IsHit ||
|
if (!args.IsHit ||
|
||||||
!args.HitEntities.Any() ||
|
!args.HitEntities.Any() ||
|
||||||
!UseFlash(comp, args.User))
|
!UseFlash(uid, comp, args.User))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -65,48 +67,39 @@ namespace Content.Server.Flash
|
|||||||
|
|
||||||
private void OnFlashUseInHand(EntityUid uid, FlashComponent comp, UseInHandEvent args)
|
private void OnFlashUseInHand(EntityUid uid, FlashComponent comp, UseInHandEvent args)
|
||||||
{
|
{
|
||||||
if (args.Handled || !UseFlash(comp, args.User))
|
if (args.Handled || !UseFlash(uid, comp, args.User))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
args.Handled = true;
|
args.Handled = true;
|
||||||
FlashArea(uid, args.User, comp.Range, comp.AoeFlashDuration, comp.SlowTo, true);
|
FlashArea(uid, args.User, comp.Range, comp.AoeFlashDuration, comp.SlowTo, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool UseFlash(FlashComponent comp, EntityUid user)
|
private bool UseFlash(EntityUid uid, FlashComponent comp, EntityUid user)
|
||||||
{
|
{
|
||||||
if (comp.HasUses)
|
if (!comp.HasUses || comp.Flashing)
|
||||||
{
|
|
||||||
// TODO flash visualizer
|
|
||||||
if (!EntityManager.TryGetComponent<SpriteComponent?>(comp.Owner, out var sprite))
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (--comp.Uses == 0)
|
comp.Uses--;
|
||||||
{
|
_audio.PlayPvs(comp.Sound, uid);
|
||||||
sprite.LayerSetState(0, "burnt");
|
|
||||||
|
|
||||||
_tagSystem.AddTag(comp.Owner, "Trash");
|
|
||||||
comp.Owner.PopupMessage(user, Loc.GetString("flash-component-becomes-empty"));
|
|
||||||
}
|
|
||||||
else if (!comp.Flashing)
|
|
||||||
{
|
|
||||||
int animLayer = sprite.AddLayerWithState("flashing");
|
|
||||||
comp.Flashing = true;
|
comp.Flashing = true;
|
||||||
|
_appearance.SetData(uid, FlashVisuals.Flashing, true);
|
||||||
|
|
||||||
comp.Owner.SpawnTimer(400, () =>
|
if (comp.Uses == 0)
|
||||||
{
|
{
|
||||||
sprite.RemoveLayer(animLayer);
|
_appearance.SetData(uid, FlashVisuals.Burnt, true);
|
||||||
|
_tagSystem.AddTag(uid, "Trash");
|
||||||
|
_popup.PopupEntity(Loc.GetString("flash-component-becomes-empty"), user);
|
||||||
|
}
|
||||||
|
|
||||||
|
uid.SpawnTimer(400, () =>
|
||||||
|
{
|
||||||
|
_appearance.SetData(uid, FlashVisuals.Flashing, false);
|
||||||
comp.Flashing = false;
|
comp.Flashing = false;
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
SoundSystem.Play(comp.Sound.GetSound(), Filter.Pvs(comp.Owner), comp.Owner, AudioParams.Default);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Flash(EntityUid target, EntityUid? user, EntityUid? used, float flashDuration, float slowTo, bool displayPopup = true, FlashableComponent? flashable = null)
|
public void Flash(EntityUid target, EntityUid? user, EntityUid? used, float flashDuration, float slowTo, bool displayPopup = true, FlashableComponent? flashable = null)
|
||||||
{
|
{
|
||||||
if (!Resolve(target, ref flashable, false)) return;
|
if (!Resolve(target, ref flashable, false)) return;
|
||||||
|
|||||||
@@ -24,4 +24,13 @@ namespace Content.Shared.Flash
|
|||||||
Time = time;
|
Time = time;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Serializable, NetSerializable]
|
||||||
|
public enum FlashVisuals : byte
|
||||||
|
{
|
||||||
|
BaseLayer,
|
||||||
|
LightLayer,
|
||||||
|
Burnt,
|
||||||
|
Flashing,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,6 +65,18 @@
|
|||||||
id: lanternextrabright
|
id: lanternextrabright
|
||||||
description: Blinding.
|
description: Blinding.
|
||||||
components:
|
components:
|
||||||
|
- type: Sprite
|
||||||
|
sprite: Objects/Tools/lantern.rsi
|
||||||
|
layers:
|
||||||
|
- state: lantern
|
||||||
|
map: [ "enum.FlashVisuals.BaseLayer" ]
|
||||||
|
- state: lantern-on
|
||||||
|
shader: unshaded
|
||||||
|
visible: false
|
||||||
|
map: [ "light" ]
|
||||||
|
- state: flashing
|
||||||
|
map: [ "enum.FlashVisuals.LightLayer" ]
|
||||||
|
visible: false
|
||||||
- type: PointLight
|
- type: PointLight
|
||||||
enabled: false
|
enabled: false
|
||||||
radius: 5
|
radius: 5
|
||||||
@@ -72,3 +84,13 @@
|
|||||||
color: "#FFC458"
|
color: "#FFC458"
|
||||||
- type: Flash
|
- type: Flash
|
||||||
uses: 15
|
uses: 15
|
||||||
|
- type: Appearance
|
||||||
|
- type: GenericVisualizer
|
||||||
|
visuals:
|
||||||
|
enum.FlashVisuals.Burnt:
|
||||||
|
enum.FlashVisuals.BaseLayer:
|
||||||
|
True: {state: burnt}
|
||||||
|
enum.FlashVisuals.Flashing:
|
||||||
|
enum.FlashVisuals.LightLayer:
|
||||||
|
True: {visible: true}
|
||||||
|
False: {visible: false}
|
||||||
|
|||||||
@@ -53,7 +53,13 @@
|
|||||||
components:
|
components:
|
||||||
- type: Sprite
|
- type: Sprite
|
||||||
sprite: Objects/Weapons/Melee/flash.rsi
|
sprite: Objects/Weapons/Melee/flash.rsi
|
||||||
state: flash
|
layers:
|
||||||
|
- state: flash
|
||||||
|
map: [ "enum.FlashVisuals.BaseLayer" ]
|
||||||
|
- state: flashing
|
||||||
|
map: [ "enum.FlashVisuals.LightLayer" ]
|
||||||
|
visible: false
|
||||||
|
shader: unshaded
|
||||||
- type: Flash
|
- type: Flash
|
||||||
- type: MeleeWeapon
|
- type: MeleeWeapon
|
||||||
damage:
|
damage:
|
||||||
@@ -66,6 +72,16 @@
|
|||||||
- type: ItemCooldown
|
- type: ItemCooldown
|
||||||
- type: StaticPrice
|
- type: StaticPrice
|
||||||
price: 40
|
price: 40
|
||||||
|
- type: Appearance
|
||||||
|
- type: GenericVisualizer
|
||||||
|
visuals:
|
||||||
|
enum.FlashVisuals.Burnt:
|
||||||
|
enum.FlashVisuals.BaseLayer:
|
||||||
|
True: {state: burnt}
|
||||||
|
enum.FlashVisuals.Flashing:
|
||||||
|
enum.FlashVisuals.LightLayer:
|
||||||
|
True: {visible: true}
|
||||||
|
False: {visible: false}
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
name: portable flasher
|
name: portable flasher
|
||||||
|
|||||||
Reference in New Issue
Block a user