Revolutionaries (#18477)
Co-authored-by: coolmankid12345 <coolmankid12345@users.noreply.github.com> Co-authored-by: EmoGarbage404 <retron404@gmail.com>
This commit is contained in:
@@ -5,7 +5,6 @@ using Content.Server.Popups;
|
||||
using Content.Server.Stunnable;
|
||||
using Content.Shared.Charges.Components;
|
||||
using Content.Shared.Charges.Systems;
|
||||
using Content.Shared.Damage;
|
||||
using Content.Shared.Eye.Blinding.Components;
|
||||
using Content.Shared.Flash;
|
||||
using Content.Shared.IdentityManagement;
|
||||
@@ -13,7 +12,6 @@ using Content.Shared.Interaction;
|
||||
using Content.Shared.Interaction.Events;
|
||||
using Content.Shared.Inventory;
|
||||
using Content.Shared.Physics;
|
||||
using Content.Shared.Popups;
|
||||
using Content.Shared.Tag;
|
||||
using Content.Shared.Traits.Assorted;
|
||||
using Content.Shared.Weapons.Melee.Events;
|
||||
@@ -41,11 +39,11 @@ namespace Content.Server.Flash
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<FlashComponent, MeleeHitEvent>(OnFlashMeleeHit);
|
||||
// ran before toggling light for extra-bright lantern
|
||||
SubscribeLocalEvent<FlashComponent, UseInHandEvent>(OnFlashUseInHand, before: new []{ typeof(HandheldLightSystem) });
|
||||
SubscribeLocalEvent<InventoryComponent, FlashAttemptEvent>(OnInventoryFlashAttempt);
|
||||
|
||||
SubscribeLocalEvent<FlashImmunityComponent, FlashAttemptEvent>(OnFlashImmunityFlashAttempt);
|
||||
SubscribeLocalEvent<PermanentBlindnessComponent, FlashAttemptEvent>(OnPermanentBlindnessFlashAttempt);
|
||||
SubscribeLocalEvent<TemporaryBlindnessComponent, FlashAttemptEvent>(OnTemporaryBlindnessFlashAttempt);
|
||||
@@ -63,7 +61,7 @@ namespace Content.Server.Flash
|
||||
args.Handled = true;
|
||||
foreach (var e in args.HitEntities)
|
||||
{
|
||||
Flash(e, args.User, uid, comp.FlashDuration, comp.SlowTo);
|
||||
Flash(e, args.User, uid, comp.FlashDuration, comp.SlowTo, melee: true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,9 +104,17 @@ namespace Content.Server.Flash
|
||||
return true;
|
||||
}
|
||||
|
||||
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,
|
||||
bool melee = false)
|
||||
{
|
||||
if (!Resolve(target, ref flashable, false)) return;
|
||||
if (!Resolve(target, ref flashable, false))
|
||||
return;
|
||||
|
||||
var attempt = new FlashAttemptEvent(target, user, used);
|
||||
RaiseLocalEvent(target, attempt, true);
|
||||
@@ -116,18 +122,28 @@ namespace Content.Server.Flash
|
||||
if (attempt.Cancelled)
|
||||
return;
|
||||
|
||||
if (melee)
|
||||
{
|
||||
var ev = new AfterFlashedEvent(target, user, used);
|
||||
if (user != null)
|
||||
RaiseLocalEvent(user.Value, ref ev);
|
||||
if (used != null)
|
||||
RaiseLocalEvent(used.Value, ref ev);
|
||||
}
|
||||
|
||||
flashable.LastFlash = _timing.CurTime;
|
||||
flashable.Duration = flashDuration / 1000f; // TODO: Make this sane...
|
||||
Dirty(flashable);
|
||||
Dirty(target, flashable);
|
||||
|
||||
_stun.TrySlowdown(target, TimeSpan.FromSeconds(flashDuration/1000f), true,
|
||||
slowTo, slowTo);
|
||||
|
||||
if (displayPopup && user != null && target != user && EntityManager.EntityExists(user.Value))
|
||||
if (displayPopup && user != null && target != user && Exists(user.Value))
|
||||
{
|
||||
user.Value.PopupMessage(target, Loc.GetString("flash-component-user-blinds-you",
|
||||
("user", Identity.Entity(user.Value, EntityManager))));
|
||||
_popup.PopupEntity(Loc.GetString("flash-component-user-blinds-you",
|
||||
("user", Identity.Entity(user.Value, EntityManager))), target, target);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void FlashArea(EntityUid source, EntityUid? user, float range, float duration, float slowTo = 0.8f, bool displayPopup = false, SoundSpecifier? sound = null)
|
||||
@@ -201,4 +217,24 @@ namespace Content.Server.Flash
|
||||
Used = used;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Called after a flash is used via melee on another person to check for rev conversion.
|
||||
/// Raised on the user of the flash, the target hit by the flash, and the flash used.
|
||||
/// </summary>
|
||||
[ByRefEvent]
|
||||
public readonly struct AfterFlashedEvent
|
||||
{
|
||||
public readonly EntityUid Target;
|
||||
public readonly EntityUid? User;
|
||||
public readonly EntityUid? Used;
|
||||
|
||||
public AfterFlashedEvent(EntityUid target, EntityUid? user, EntityUid? used)
|
||||
{
|
||||
Target = target;
|
||||
User = user;
|
||||
Used = used;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user