From 233f5cd35c769110e0045c8ab0137c537f8d9eca Mon Sep 17 00:00:00 2001 From: Dentristan Date: Tue, 13 Aug 2024 23:49:11 +0300 Subject: [PATCH] =?UTF-8?q?=D0=97=D0=B0=D0=BC=D0=B5=D0=BD=D0=B0=20projecti?= =?UTF-8?q?leReflectorList=20=D0=BD=D0=B0=20whitelist=20/=20blacklist?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Reflectors/EmitterRefrectorSystem.cs | 21 +++++++++++-------- .../Reflectors/EmitterRefrectorComponent.cs | 10 +++++---- .../Structures/Machines/refrectors.yml | 15 +++++-------- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/Content.Server/Stories/Reflectors/EmitterRefrectorSystem.cs b/Content.Server/Stories/Reflectors/EmitterRefrectorSystem.cs index 2238a60c98..70429e990e 100644 --- a/Content.Server/Stories/Reflectors/EmitterRefrectorSystem.cs +++ b/Content.Server/Stories/Reflectors/EmitterRefrectorSystem.cs @@ -7,6 +7,7 @@ using Robust.Shared.Map; using Direction = Robust.Shared.Maths.Direction; using Content.Shared.Stories.Reflectors; +using Content.Shared.Whitelist; namespace Content.Server.Stories.Reflectors; public sealed class EmitterReflectorSystem : EntitySystem @@ -14,6 +15,7 @@ public sealed class EmitterReflectorSystem : EntitySystem [Dependency] private readonly ProjectileSystem _projectile = default!; [Dependency] private readonly GunSystem _gun = default!; [Dependency] private readonly SharedTransformSystem _transformSystem = default!; + [Dependency] private readonly EntityWhitelistSystem _whitelistSystem = default!; public override void Initialize() { @@ -28,18 +30,19 @@ private void OnEmitterReflectorCollide(EntityUid uid, EmitterReflectorComponent if (args.OtherFixtureId != component.SourceFixtureId) return; + if (_whitelistSystem.IsBlacklistPass(component.Blacklist, args.OtherEntity) || + _whitelistSystem.IsWhitelistFail(component.Whitelist, args.OtherEntity)) + return; + + var collisionDirection = CalculateCollisionDirection(uid, args.WorldPoint); + if (component.BlockedDirections.Contains(collisionDirection.ToString())) + return; + if (!TryComp(args.OtherEntity, out MetaDataComponent? metadata) || metadata.EntityPrototype == null) return; - var projectileType = metadata.EntityPrototype.ID; + ReflectProjectile(uid, component, metadata.EntityPrototype.ID, args.OtherEntity); - if (component.ProjectileReflectorList.Contains(projectileType)) - { - var collisionDirection = CalculateCollisionDirection(uid, args.WorldPoint); - if (component.BlockedDirections.Contains(collisionDirection.ToString())) - return; - ReflectProjectile(uid, component, projectileType, args.OtherEntity); - } } private Direction CalculateCollisionDirection(EntityUid uid, Vector2 worldPoint) @@ -48,7 +51,7 @@ private Direction CalculateCollisionDirection(EntityUid uid, Vector2 worldPoint) return (localCollisionPoint - Vector2.Zero).ToAngle().GetCardinalDir(); } - private void ReflectProjectile(EntityUid uid, EmitterReflectorComponent component, string projectileType, EntityUid otherEntity) + private void ReflectProjectile(EntityUid uid, EmitterReflectorComponent component, string projectileType, EntityUid otherEntity) { if (!TryComp(uid, out GunComponent? gunComponent)) return; diff --git a/Content.Shared/Stories/Reflectors/EmitterRefrectorComponent.cs b/Content.Shared/Stories/Reflectors/EmitterRefrectorComponent.cs index 484ff4a29e..e2cbdb3056 100644 --- a/Content.Shared/Stories/Reflectors/EmitterRefrectorComponent.cs +++ b/Content.Shared/Stories/Reflectors/EmitterRefrectorComponent.cs @@ -1,6 +1,5 @@ +using Content.Shared.Whitelist; using Robust.Shared.GameStates; -using Robust.Shared.Prototypes; -using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.List; namespace Content.Shared.Stories.Reflectors; @@ -10,8 +9,11 @@ public sealed partial class EmitterReflectorComponent : Component [DataField] public string SourceFixtureId = "projectile"; - [DataField(customTypeSerializer: typeof(PrototypeIdListSerializer))] - public List ProjectileReflectorList = new(); + [DataField] + public EntityWhitelist? Whitelist; + + [DataField] + public EntityWhitelist? Blacklist; [DataField] public List BlockedDirections = new(); // "East", "West", "North", "South" diff --git a/Resources/Prototypes/Stories/Entities/Structures/Machines/refrectors.yml b/Resources/Prototypes/Stories/Entities/Structures/Machines/refrectors.yml index 6ddb5a88bf..c841a50bb1 100644 --- a/Resources/Prototypes/Stories/Entities/Structures/Machines/refrectors.yml +++ b/Resources/Prototypes/Stories/Entities/Structures/Machines/refrectors.yml @@ -8,16 +8,11 @@ - type: Sprite sprite: Stories/Structures/Machines/reflectors.rsi - type: EmitterReflector - projectileReflectorList: - - EmitterBolt - - AnomalousParticleDelta - - AnomalousParticleDeltaStrong - - AnomalousParticleEpsilon - - AnomalousParticleEpsilonStrong - - AnomalousParticleZeta - - AnomalousParticleZetaStrong - - AnomalousParticleSigma - - AnomalousParticleSigmaStrong + whitelist: + tags: + - EmitterBolt + components: + - AnomalousParticle - type: Gun projectileSpeed: 15 fireRate: 10