Fixes hitscan weapons not respecting reflectTypes (#34203)
* removes otherwise unused events that broke reflectType * that last one broke everything. this actually fixes it * minor cleanup * move some stuff around for optimisation --------- Co-authored-by: Ruddygreat <ruddygreat1@gmail.com>
This commit is contained in:
@@ -62,7 +62,7 @@ public sealed class ReflectSystem : EntitySystem
|
||||
|
||||
foreach (var ent in _inventorySystem.GetHandOrInventoryEntities(uid, SlotFlags.All & ~SlotFlags.POCKET))
|
||||
{
|
||||
if (!TryReflectHitscan(uid, ent, args.Shooter, args.SourceItem, args.Direction, out var dir))
|
||||
if (!TryReflectHitscan(uid, ent, args.Shooter, args.SourceItem, args.Direction, args.Reflective, out var dir))
|
||||
continue;
|
||||
|
||||
args.Direction = dir.Value;
|
||||
@@ -95,9 +95,9 @@ public sealed class ReflectSystem : EntitySystem
|
||||
private bool TryReflectProjectile(EntityUid user, EntityUid reflector, EntityUid projectile, ProjectileComponent? projectileComp = null, ReflectComponent? reflect = null)
|
||||
{
|
||||
if (!Resolve(reflector, ref reflect, false) ||
|
||||
!_toggle.IsActivated(reflector) ||
|
||||
!TryComp<ReflectiveComponent>(projectile, out var reflective) ||
|
||||
(reflect.Reflects & reflective.Reflective) == 0x0 ||
|
||||
!_toggle.IsActivated(reflector) ||
|
||||
!_random.Prob(reflect.ReflectProb) ||
|
||||
!TryComp<PhysicsComponent>(projectile, out var physics))
|
||||
{
|
||||
@@ -142,13 +142,12 @@ public sealed class ReflectSystem : EntitySystem
|
||||
|
||||
private void OnReflectHitscan(EntityUid uid, ReflectComponent component, ref HitScanReflectAttemptEvent args)
|
||||
{
|
||||
if (args.Reflected ||
|
||||
(component.Reflects & args.Reflective) == 0x0)
|
||||
if (args.Reflected)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (TryReflectHitscan(uid, uid, args.Shooter, args.SourceItem, args.Direction, out var dir))
|
||||
if (TryReflectHitscan(uid, uid, args.Shooter, args.SourceItem, args.Direction, args.Reflective, out var dir))
|
||||
{
|
||||
args.Direction = dir.Value;
|
||||
args.Reflected = true;
|
||||
@@ -161,9 +160,11 @@ public sealed class ReflectSystem : EntitySystem
|
||||
EntityUid? shooter,
|
||||
EntityUid shotSource,
|
||||
Vector2 direction,
|
||||
ReflectType hitscanReflectType,
|
||||
[NotNullWhen(true)] out Vector2? newDirection)
|
||||
{
|
||||
if (!TryComp<ReflectComponent>(reflector, out var reflect) ||
|
||||
(reflect.Reflects & hitscanReflectType) == 0x0 ||
|
||||
!_toggle.IsActivated(reflector) ||
|
||||
!_random.Prob(reflect.ReflectProb))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user