@@ -10,7 +10,6 @@ using Content.Server.Botany;
|
||||
using Content.Server.Chat.Systems;
|
||||
using Content.Server.Emp;
|
||||
using Content.Server.Explosion.EntitySystems;
|
||||
using Content.Server.Flash;
|
||||
using Content.Server.Fluids.EntitySystems;
|
||||
using Content.Server.Ghost.Roles.Components;
|
||||
using Content.Server.Medical;
|
||||
@@ -23,13 +22,12 @@ using Content.Server.Temperature.Systems;
|
||||
using Content.Server.Traits.Assorted;
|
||||
using Content.Server.Zombies;
|
||||
using Content.Shared.Atmos;
|
||||
using Content.Shared.Audio;
|
||||
using Content.Shared.Coordinates.Helpers;
|
||||
using Content.Shared.EntityEffects.EffectConditions;
|
||||
using Content.Shared.EntityEffects.Effects.PlantMetabolism;
|
||||
using Content.Shared.EntityEffects.Effects.StatusEffects;
|
||||
using Content.Shared.EntityEffects.Effects;
|
||||
using Content.Shared.EntityEffects;
|
||||
using Content.Shared.Flash;
|
||||
using Content.Shared.Maps;
|
||||
using Content.Shared.Mind.Components;
|
||||
using Content.Shared.Popups;
|
||||
@@ -38,7 +36,6 @@ using Content.Shared.Zombies;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Audio.Systems;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Random;
|
||||
@@ -56,7 +53,7 @@ public sealed class EntityEffectSystem : EntitySystem
|
||||
[Dependency] private readonly EmpSystem _emp = default!;
|
||||
[Dependency] private readonly ExplosionSystem _explosion = default!;
|
||||
[Dependency] private readonly FlammableSystem _flammable = default!;
|
||||
[Dependency] private readonly FlashSystem _flash = default!;
|
||||
[Dependency] private readonly SharedFlashSystem _flash = default!;
|
||||
[Dependency] private readonly IMapManager _mapManager = default!;
|
||||
[Dependency] private readonly IPrototypeManager _protoManager = default!;
|
||||
[Dependency] private readonly IRobustRandom _random = default!;
|
||||
@@ -711,7 +708,7 @@ public sealed class EntityEffectSystem : EntitySystem
|
||||
args.Args.TargetEntity,
|
||||
null,
|
||||
range,
|
||||
args.Effect.Duration * 1000,
|
||||
args.Effect.Duration,
|
||||
slowTo: args.Effect.SlowTo,
|
||||
sound: args.Effect.Sound);
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using Content.Server.Administration.Logs;
|
||||
using Content.Server.Body.Systems;
|
||||
using Content.Server.Explosion.Components;
|
||||
using Content.Server.Flash;
|
||||
using Content.Shared.Flash;
|
||||
using Content.Server.Electrocution;
|
||||
using Content.Server.Pinpointer;
|
||||
using Content.Shared.Chemistry.EntitySystems;
|
||||
@@ -69,7 +69,7 @@ namespace Content.Server.Explosion.EntitySystems
|
||||
{
|
||||
[Dependency] private readonly ExplosionSystem _explosions = default!;
|
||||
[Dependency] private readonly FixtureSystem _fixtures = default!;
|
||||
[Dependency] private readonly FlashSystem _flashSystem = default!;
|
||||
[Dependency] private readonly SharedFlashSystem _flashSystem = default!;
|
||||
[Dependency] private readonly SharedBroadphaseSystem _broadphase = default!;
|
||||
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
|
||||
[Dependency] private readonly SharedContainerSystem _container = default!;
|
||||
@@ -196,8 +196,7 @@ namespace Content.Server.Explosion.EntitySystems
|
||||
|
||||
private void HandleFlashTrigger(EntityUid uid, FlashOnTriggerComponent component, TriggerEvent args)
|
||||
{
|
||||
// TODO Make flash durations sane ffs.
|
||||
_flashSystem.FlashArea(uid, args.User, component.Range, component.Duration * 1000f, probability: component.Probability);
|
||||
_flashSystem.FlashArea(uid, args.User, component.Range, component.Duration, probability: component.Probability);
|
||||
args.Handled = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
using Content.Shared.Damage;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Server.Flash.Components;
|
||||
|
||||
[RegisterComponent, Access(typeof(DamagedByFlashingSystem))]
|
||||
public sealed partial class DamagedByFlashingComponent : Component
|
||||
{
|
||||
/// <summary>
|
||||
/// damage from flashing
|
||||
/// </summary>
|
||||
[DataField(required: true), ViewVariables(VVAccess.ReadWrite)]
|
||||
public DamageSpecifier FlashDamage = new();
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
namespace Content.Server.Flash.Components;
|
||||
|
||||
/// <summary>
|
||||
/// Makes the entity immune to being flashed.
|
||||
/// When given to clothes in the "head", "eyes" or "mask" slot it protects the wearer.
|
||||
/// </summary>
|
||||
[RegisterComponent, Access(typeof(FlashSystem))]
|
||||
public sealed partial class FlashImmunityComponent : Component
|
||||
{
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
[DataField("enabled")]
|
||||
public bool Enabled { get; set; } = true;
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
using Content.Server.Flash.Components;
|
||||
using Content.Shared.Damage;
|
||||
|
||||
namespace Content.Server.Flash;
|
||||
public sealed class DamagedByFlashingSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly DamageableSystem _damageable = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<DamagedByFlashingComponent, FlashAttemptEvent>(OnFlashAttempt);
|
||||
}
|
||||
private void OnFlashAttempt(Entity<DamagedByFlashingComponent> ent, ref FlashAttemptEvent args)
|
||||
{
|
||||
_damageable.TryChangeDamage(ent, ent.Comp.FlashDamage);
|
||||
|
||||
//TODO: It would be more logical if different flashes had different power,
|
||||
//and the damage would be inflicted depending on the strength of the flash.
|
||||
}
|
||||
}
|
||||
@@ -1,257 +1,5 @@
|
||||
using System.Linq;
|
||||
using Content.Server.Flash.Components;
|
||||
using Content.Shared.Flash.Components;
|
||||
using Content.Server.Light.EntitySystems;
|
||||
using Content.Server.Popups;
|
||||
using Content.Server.Stunnable;
|
||||
using Content.Shared.Charges.Components;
|
||||
using Content.Shared.Charges.Systems;
|
||||
using Content.Shared.Eye.Blinding.Components;
|
||||
using Content.Shared.Flash;
|
||||
using Content.Shared.IdentityManagement;
|
||||
using Content.Shared.Interaction.Events;
|
||||
using Content.Shared.Inventory;
|
||||
using Content.Shared.Tag;
|
||||
using Content.Shared.Traits.Assorted;
|
||||
using Content.Shared.Weapons.Melee.Events;
|
||||
using Content.Shared.StatusEffect;
|
||||
using Content.Shared.Examine;
|
||||
using Robust.Server.Audio;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Random;
|
||||
using InventoryComponent = Content.Shared.Inventory.InventoryComponent;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Server.Flash
|
||||
{
|
||||
internal sealed class FlashSystem : SharedFlashSystem
|
||||
{
|
||||
[Dependency] private readonly AppearanceSystem _appearance = default!;
|
||||
[Dependency] private readonly AudioSystem _audio = default!;
|
||||
[Dependency] private readonly SharedChargesSystem _sharedCharges = default!;
|
||||
[Dependency] private readonly EntityLookupSystem _entityLookup = default!;
|
||||
[Dependency] private readonly SharedTransformSystem _transform = default!;
|
||||
[Dependency] private readonly ExamineSystemShared _examine = 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!;
|
||||
[Dependency] private readonly IRobustRandom _random = default!;
|
||||
[Dependency] private readonly StatusEffectsSystem _statusEffectsSystem = default!;
|
||||
namespace Content.Server.Flash;
|
||||
|
||||
private static readonly ProtoId<TagPrototype> TrashTag = "Trash";
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
SubscribeLocalEvent<FlashImmunityComponent, ExaminedEvent>(OnExamine);
|
||||
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);
|
||||
}
|
||||
|
||||
private void OnExamine(Entity<FlashImmunityComponent> ent, ref ExaminedEvent args)
|
||||
|
||||
{
|
||||
args.PushMarkup(Loc.GetString("flash-protection"));
|
||||
}
|
||||
|
||||
private void OnFlashMeleeHit(EntityUid uid, FlashComponent comp, MeleeHitEvent args)
|
||||
{
|
||||
if (!args.IsHit ||
|
||||
!args.HitEntities.Any() ||
|
||||
!UseFlash(uid, comp, args.User))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
args.Handled = true;
|
||||
foreach (var e in args.HitEntities)
|
||||
{
|
||||
Flash(e, args.User, uid, comp.FlashDuration, comp.SlowTo, melee: true, stunDuration: comp.MeleeStunDuration);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnFlashUseInHand(EntityUid uid, FlashComponent comp, UseInHandEvent args)
|
||||
{
|
||||
if (args.Handled || !UseFlash(uid, comp, args.User))
|
||||
return;
|
||||
|
||||
args.Handled = true;
|
||||
FlashArea(uid, args.User, comp.Range, comp.AoeFlashDuration, comp.SlowTo, true, comp.Probability);
|
||||
}
|
||||
|
||||
private bool UseFlash(EntityUid uid, FlashComponent comp, EntityUid user)
|
||||
{
|
||||
if (comp.Flashing)
|
||||
return false;
|
||||
|
||||
TryComp<LimitedChargesComponent>(uid, out var charges);
|
||||
if (_sharedCharges.IsEmpty((uid, charges)))
|
||||
return false;
|
||||
|
||||
_sharedCharges.TryUseCharge((uid, charges));
|
||||
_audio.PlayPvs(comp.Sound, uid);
|
||||
comp.Flashing = true;
|
||||
_appearance.SetData(uid, FlashVisuals.Flashing, true);
|
||||
|
||||
if (_sharedCharges.IsEmpty((uid, charges)))
|
||||
{
|
||||
_appearance.SetData(uid, FlashVisuals.Burnt, true);
|
||||
_tag.AddTag(uid, TrashTag);
|
||||
_popup.PopupEntity(Loc.GetString("flash-component-becomes-empty"), user);
|
||||
}
|
||||
|
||||
uid.SpawnTimer(400, () =>
|
||||
{
|
||||
_appearance.SetData(uid, FlashVisuals.Flashing, false);
|
||||
comp.Flashing = false;
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void Flash(EntityUid target,
|
||||
EntityUid? user,
|
||||
EntityUid? used,
|
||||
float flashDuration,
|
||||
float slowTo,
|
||||
bool displayPopup = true,
|
||||
bool melee = false,
|
||||
TimeSpan? stunDuration = null)
|
||||
{
|
||||
var attempt = new FlashAttemptEvent(target, user, used);
|
||||
RaiseLocalEvent(target, attempt, true);
|
||||
|
||||
if (attempt.Cancelled)
|
||||
return;
|
||||
|
||||
// don't paralyze, slowdown or convert to rev if the target is immune to flashes
|
||||
if (!_statusEffectsSystem.TryAddStatusEffect<FlashedComponent>(target, FlashedKey, TimeSpan.FromSeconds(flashDuration / 1000f), true))
|
||||
return;
|
||||
|
||||
if (stunDuration != null)
|
||||
{
|
||||
_stun.TryParalyze(target, stunDuration.Value, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
_stun.TrySlowdown(target, TimeSpan.FromSeconds(flashDuration / 1000f), true,
|
||||
slowTo, slowTo);
|
||||
}
|
||||
|
||||
if (displayPopup && user != null && target != user && Exists(user.Value))
|
||||
{
|
||||
_popup.PopupEntity(Loc.GetString("flash-component-user-blinds-you",
|
||||
("user", Identity.Entity(user.Value, EntityManager))), target, target);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
public override void FlashArea(Entity<FlashComponent?> source, EntityUid? user, float range, float duration, float slowTo = 0.8f, bool displayPopup = false, float probability = 1f, SoundSpecifier? sound = null)
|
||||
{
|
||||
var transform = Transform(source);
|
||||
var mapPosition = _transform.GetMapCoordinates(transform);
|
||||
var statusEffectsQuery = GetEntityQuery<StatusEffectsComponent>();
|
||||
var damagedByFlashingQuery = GetEntityQuery<DamagedByFlashingComponent>();
|
||||
|
||||
foreach (var entity in _entityLookup.GetEntitiesInRange(transform.Coordinates, range))
|
||||
{
|
||||
if (!_random.Prob(probability))
|
||||
continue;
|
||||
|
||||
// Is the entity affected by the flash either through status effects or by taking damage?
|
||||
if (!statusEffectsQuery.HasComponent(entity) && !damagedByFlashingQuery.HasComponent(entity))
|
||||
continue;
|
||||
|
||||
// Check for entites in view
|
||||
// put damagedByFlashingComponent in the predicate because shadow anomalies block vision.
|
||||
if (!_examine.InRangeUnOccluded(entity, mapPosition, range, predicate: (e) => damagedByFlashingQuery.HasComponent(e)))
|
||||
continue;
|
||||
|
||||
// They shouldn't have flash removed in between right?
|
||||
Flash(entity, user, source, duration, slowTo, displayPopup);
|
||||
}
|
||||
|
||||
_audio.PlayPvs(sound, source, AudioParams.Default.WithVolume(1f).WithMaxDistance(3f));
|
||||
}
|
||||
|
||||
private void OnInventoryFlashAttempt(EntityUid uid, InventoryComponent component, FlashAttemptEvent args)
|
||||
{
|
||||
foreach (var slot in new[] { "head", "eyes", "mask" })
|
||||
{
|
||||
if (args.Cancelled)
|
||||
break;
|
||||
if (_inventory.TryGetSlotEntity(uid, slot, out var item, component))
|
||||
RaiseLocalEvent(item.Value, args, true);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnFlashImmunityFlashAttempt(EntityUid uid, FlashImmunityComponent component, FlashAttemptEvent args)
|
||||
{
|
||||
if (component.Enabled)
|
||||
args.Cancel();
|
||||
}
|
||||
|
||||
private void OnPermanentBlindnessFlashAttempt(EntityUid uid, PermanentBlindnessComponent component, FlashAttemptEvent args)
|
||||
{
|
||||
// check for total blindness
|
||||
if (component.Blindness == 0)
|
||||
args.Cancel();
|
||||
}
|
||||
|
||||
private void OnTemporaryBlindnessFlashAttempt(EntityUid uid, TemporaryBlindnessComponent component, FlashAttemptEvent args)
|
||||
{
|
||||
args.Cancel();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called before a flash is used to check if the attempt is cancelled by blindness, items or FlashImmunityComponent.
|
||||
/// Raised on the target hit by the flash, the user of the flash and the flash used.
|
||||
/// </summary>
|
||||
public sealed class FlashAttemptEvent : CancellableEntityEventArgs
|
||||
{
|
||||
public readonly EntityUid Target;
|
||||
public readonly EntityUid? User;
|
||||
public readonly EntityUid? Used;
|
||||
|
||||
public FlashAttemptEvent(EntityUid target, EntityUid? user, EntityUid? used)
|
||||
{
|
||||
Target = target;
|
||||
User = user;
|
||||
Used = used;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Called after a flash is used via melee on another person to check for rev conversion.
|
||||
/// Raised on the target hit by the flash, the user of 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
public sealed class FlashSystem : SharedFlashSystem;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using Content.Server.Administration.Logs;
|
||||
using Content.Server.Antag;
|
||||
using Content.Server.EUI;
|
||||
using Content.Server.Flash;
|
||||
using Content.Server.GameTicking.Rules.Components;
|
||||
using Content.Server.Mind;
|
||||
using Content.Server.Popups;
|
||||
@@ -12,6 +11,7 @@ using Content.Server.RoundEnd;
|
||||
using Content.Server.Shuttles.Systems;
|
||||
using Content.Server.Station.Systems;
|
||||
using Content.Shared.Database;
|
||||
using Content.Shared.Flash;
|
||||
using Content.Shared.GameTicking.Components;
|
||||
using Content.Shared.Humanoid;
|
||||
using Content.Shared.IdentityManagement;
|
||||
@@ -131,6 +131,9 @@ public sealed class RevolutionaryRuleSystem : GameRuleSystem<RevolutionaryRuleCo
|
||||
/// </summary>
|
||||
private void OnPostFlash(EntityUid uid, HeadRevolutionaryComponent comp, ref AfterFlashedEvent ev)
|
||||
{
|
||||
if (uid != ev.User || !ev.Melee)
|
||||
return;
|
||||
|
||||
var alwaysConvertible = HasComp<AlwaysRevolutionaryConvertibleComponent>(ev.Target);
|
||||
|
||||
if (!_mind.TryGetMind(ev.Target, out var mindId, out var mind) && !alwaysConvertible)
|
||||
|
||||
Reference in New Issue
Block a user