flash uses charges system now (#15898)
Co-authored-by: deltanedas <@deltanedas:kde.org>
This commit is contained in:
@@ -9,10 +9,6 @@ namespace Content.Server.Flash.Components
|
|||||||
[ViewVariables(VVAccess.ReadWrite)]
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
public int FlashDuration { get; set; } = 5000;
|
public int FlashDuration { get; set; } = 5000;
|
||||||
|
|
||||||
[DataField("uses")]
|
|
||||||
[ViewVariables(VVAccess.ReadWrite)]
|
|
||||||
public int Uses { get; set; } = 5;
|
|
||||||
|
|
||||||
[DataField("range")]
|
[DataField("range")]
|
||||||
[ViewVariables(VVAccess.ReadWrite)]
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
public float Range { get; set; } = 7f;
|
public float Range { get; set; } = 7f;
|
||||||
@@ -30,7 +26,5 @@ namespace Content.Server.Flash.Components
|
|||||||
public SoundSpecifier Sound { get; set; } = new SoundPathSpecifier("/Audio/Weapons/flash.ogg");
|
public SoundSpecifier Sound { get; set; } = new SoundPathSpecifier("/Audio/Weapons/flash.ogg");
|
||||||
|
|
||||||
public bool Flashing;
|
public bool Flashing;
|
||||||
|
|
||||||
public bool HasUses => Uses > 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,8 @@ using Content.Server.Flash.Components;
|
|||||||
using Content.Server.Light.EntitySystems;
|
using Content.Server.Light.EntitySystems;
|
||||||
using Content.Server.Popups;
|
using Content.Server.Popups;
|
||||||
using Content.Server.Stunnable;
|
using Content.Server.Stunnable;
|
||||||
using Content.Shared.Examine;
|
using Content.Shared.Charges.Components;
|
||||||
|
using Content.Shared.Charges.Systems;
|
||||||
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;
|
||||||
@@ -25,22 +26,23 @@ namespace Content.Server.Flash
|
|||||||
{
|
{
|
||||||
internal sealed class FlashSystem : SharedFlashSystem
|
internal sealed class FlashSystem : SharedFlashSystem
|
||||||
{
|
{
|
||||||
[Dependency] private readonly EntityLookupSystem _entityLookup = default!;
|
|
||||||
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
|
||||||
[Dependency] private readonly StunSystem _stunSystem = default!;
|
|
||||||
[Dependency] private readonly InventorySystem _inventorySystem = default!;
|
|
||||||
[Dependency] private readonly AudioSystem _audio = default!;
|
|
||||||
[Dependency] private readonly SharedInteractionSystem _interactionSystem = default!;
|
|
||||||
[Dependency] private readonly TagSystem _tagSystem = default!;
|
|
||||||
[Dependency] private readonly PopupSystem _popup = default!;
|
|
||||||
[Dependency] private readonly AppearanceSystem _appearance = default!;
|
[Dependency] private readonly AppearanceSystem _appearance = default!;
|
||||||
|
[Dependency] private readonly AudioSystem _audio = default!;
|
||||||
|
[Dependency] private readonly SharedChargesSystem _charges = default!;
|
||||||
|
[Dependency] private readonly EntityLookupSystem _entityLookup = default!;
|
||||||
|
[Dependency] private readonly IGameTiming _timing = default!;
|
||||||
|
[Dependency] private readonly SharedInteractionSystem _interaction = default!;
|
||||||
|
[Dependency] private readonly InventorySystem _inventory = default!;
|
||||||
|
[Dependency] private readonly PopupSystem _popup = default!;
|
||||||
|
[Dependency] private readonly StunSystem _stun = default!;
|
||||||
|
[Dependency] private readonly TagSystem _tag = default!;
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
base.Initialize();
|
base.Initialize();
|
||||||
SubscribeLocalEvent<FlashComponent, MeleeHitEvent>(OnFlashMeleeHit);
|
SubscribeLocalEvent<FlashComponent, MeleeHitEvent>(OnFlashMeleeHit);
|
||||||
|
// ran before toggling light for extra-bright lantern
|
||||||
SubscribeLocalEvent<FlashComponent, UseInHandEvent>(OnFlashUseInHand, before: new []{ typeof(HandheldLightSystem) });
|
SubscribeLocalEvent<FlashComponent, UseInHandEvent>(OnFlashUseInHand, before: new []{ typeof(HandheldLightSystem) });
|
||||||
SubscribeLocalEvent<FlashComponent, ExaminedEvent>(OnFlashExamined);
|
|
||||||
|
|
||||||
SubscribeLocalEvent<InventoryComponent, FlashAttemptEvent>(OnInventoryFlashAttempt);
|
SubscribeLocalEvent<InventoryComponent, FlashAttemptEvent>(OnInventoryFlashAttempt);
|
||||||
|
|
||||||
@@ -76,18 +78,22 @@ namespace Content.Server.Flash
|
|||||||
|
|
||||||
private bool UseFlash(EntityUid uid, FlashComponent comp, EntityUid user)
|
private bool UseFlash(EntityUid uid, FlashComponent comp, EntityUid user)
|
||||||
{
|
{
|
||||||
if (!comp.HasUses || comp.Flashing)
|
if (comp.Flashing)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
comp.Uses--;
|
TryComp<LimitedChargesComponent>(uid, out var charges);
|
||||||
|
if (_charges.IsEmpty(uid, charges))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
_charges.UseCharge(uid, charges);
|
||||||
_audio.PlayPvs(comp.Sound, uid);
|
_audio.PlayPvs(comp.Sound, uid);
|
||||||
comp.Flashing = true;
|
comp.Flashing = true;
|
||||||
_appearance.SetData(uid, FlashVisuals.Flashing, true);
|
_appearance.SetData(uid, FlashVisuals.Flashing, true);
|
||||||
|
|
||||||
if (comp.Uses == 0)
|
if (_charges.IsEmpty(uid, charges))
|
||||||
{
|
{
|
||||||
_appearance.SetData(uid, FlashVisuals.Burnt, true);
|
_appearance.SetData(uid, FlashVisuals.Burnt, true);
|
||||||
_tagSystem.AddTag(uid, "Trash");
|
_tag.AddTag(uid, "Trash");
|
||||||
_popup.PopupEntity(Loc.GetString("flash-component-becomes-empty"), user);
|
_popup.PopupEntity(Loc.GetString("flash-component-becomes-empty"), user);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,11 +116,11 @@ namespace Content.Server.Flash
|
|||||||
if (attempt.Cancelled)
|
if (attempt.Cancelled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
flashable.LastFlash = _gameTiming.CurTime;
|
flashable.LastFlash = _timing.CurTime;
|
||||||
flashable.Duration = flashDuration / 1000f; // TODO: Make this sane...
|
flashable.Duration = flashDuration / 1000f; // TODO: Make this sane...
|
||||||
Dirty(flashable);
|
Dirty(flashable);
|
||||||
|
|
||||||
_stunSystem.TrySlowdown(target, TimeSpan.FromSeconds(flashDuration/1000f), true,
|
_stun.TrySlowdown(target, TimeSpan.FromSeconds(flashDuration/1000f), true,
|
||||||
slowTo, slowTo);
|
slowTo, slowTo);
|
||||||
|
|
||||||
if (displayPopup && user != null && target != user && EntityManager.EntityExists(user.Value))
|
if (displayPopup && user != null && target != user && EntityManager.EntityExists(user.Value))
|
||||||
@@ -142,7 +148,7 @@ namespace Content.Server.Flash
|
|||||||
foreach (var entity in flashableEntities)
|
foreach (var entity in flashableEntities)
|
||||||
{
|
{
|
||||||
// Check for unobstructed entities while ignoring the mobs with flashable components.
|
// Check for unobstructed entities while ignoring the mobs with flashable components.
|
||||||
if (!_interactionSystem.InRangeUnobstructed(entity, mapPosition, range, CollisionGroup.Opaque, (e) => flashableEntities.Contains(e) || e == source))
|
if (!_interaction.InRangeUnobstructed(entity, mapPosition, range, CollisionGroup.Opaque, (e) => flashableEntities.Contains(e) || e == source))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// They shouldn't have flash removed in between right?
|
// They shouldn't have flash removed in between right?
|
||||||
@@ -154,33 +160,13 @@ namespace Content.Server.Flash
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnFlashExamined(EntityUid uid, FlashComponent comp, ExaminedEvent args)
|
|
||||||
{
|
|
||||||
if (!comp.HasUses)
|
|
||||||
{
|
|
||||||
args.PushText(Loc.GetString("flash-component-examine-empty"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.IsInDetailsRange)
|
|
||||||
{
|
|
||||||
args.PushMarkup(
|
|
||||||
Loc.GetString(
|
|
||||||
"flash-component-examine-detail-count",
|
|
||||||
("count", comp.Uses),
|
|
||||||
("markupCountColor", "green")
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnInventoryFlashAttempt(EntityUid uid, InventoryComponent component, FlashAttemptEvent args)
|
private void OnInventoryFlashAttempt(EntityUid uid, InventoryComponent component, FlashAttemptEvent args)
|
||||||
{
|
{
|
||||||
foreach (var slot in new[] { "head", "eyes", "mask" })
|
foreach (var slot in new[] { "head", "eyes", "mask" })
|
||||||
{
|
{
|
||||||
if (args.Cancelled)
|
if (args.Cancelled)
|
||||||
break;
|
break;
|
||||||
if (_inventorySystem.TryGetSlotEntity(uid, slot, out var item, component))
|
if (_inventory.TryGetSlotEntity(uid, slot, out var item, component))
|
||||||
RaiseLocalEvent(item.Value, args, true);
|
RaiseLocalEvent(item.Value, args, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +1,3 @@
|
|||||||
|
|
||||||
### UI
|
|
||||||
|
|
||||||
# Shown when an empty flash is examined at any range
|
|
||||||
flash-component-examine-empty = It's burnt out!
|
|
||||||
|
|
||||||
# Shown when a flash is examined in details range
|
|
||||||
flash-component-examine-detail-count = The flash has [color={$markupCountColor}]{$count}[/color] {$count ->
|
|
||||||
[one] use
|
|
||||||
*[other] uses
|
|
||||||
} remaining.
|
|
||||||
|
|
||||||
### Interaction Messages
|
### Interaction Messages
|
||||||
|
|
||||||
# Shown when someone flashes you with a flash
|
# Shown when someone flashes you with a flash
|
||||||
|
|||||||
@@ -83,7 +83,13 @@
|
|||||||
energy: 10
|
energy: 10
|
||||||
color: "#FFC458"
|
color: "#FFC458"
|
||||||
- type: Flash
|
- type: Flash
|
||||||
uses: 15
|
- type: LimitedCharges
|
||||||
|
maxCharges: 15
|
||||||
|
charges: 15
|
||||||
|
- type: MeleeWeapon
|
||||||
|
damage:
|
||||||
|
types:
|
||||||
|
Blunt: 0 # melee weapon to allow flashing individual targets
|
||||||
- type: Appearance
|
- type: Appearance
|
||||||
- type: GenericVisualizer
|
- type: GenericVisualizer
|
||||||
visuals:
|
visuals:
|
||||||
|
|||||||
@@ -61,10 +61,13 @@
|
|||||||
visible: false
|
visible: false
|
||||||
shader: unshaded
|
shader: unshaded
|
||||||
- type: Flash
|
- type: Flash
|
||||||
|
- type: LimitedCharges
|
||||||
|
maxCharges: 5
|
||||||
|
charges: 5
|
||||||
- type: MeleeWeapon
|
- type: MeleeWeapon
|
||||||
damage:
|
damage:
|
||||||
types:
|
types:
|
||||||
Blunt: 0 # why is this classed as a melee weapon? Is it needed for some interaction?
|
Blunt: 0 # melee weapon to allow flashing individual targets
|
||||||
angle: 10
|
angle: 10
|
||||||
- type: Item
|
- type: Item
|
||||||
size: 5
|
size: 5
|
||||||
@@ -127,4 +130,3 @@
|
|||||||
radius: 0
|
radius: 0
|
||||||
softness: 0
|
softness: 0
|
||||||
enabled: true
|
enabled: true
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user