Skip to content

Commit

Permalink
Замена projectileReflectorList на whitelist / blacklist
Browse files Browse the repository at this point in the history
  • Loading branch information
NikitosAseev committed Aug 13, 2024
1 parent a8717b4 commit 233f5cd
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 23 deletions.
21 changes: 12 additions & 9 deletions Content.Server/Stories/Reflectors/EmitterRefrectorSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@
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
{
[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()
{
Expand All @@ -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)
Expand All @@ -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;
Expand Down
10 changes: 6 additions & 4 deletions Content.Shared/Stories/Reflectors/EmitterRefrectorComponent.cs
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -10,8 +9,11 @@ public sealed partial class EmitterReflectorComponent : Component
[DataField]
public string SourceFixtureId = "projectile";

[DataField(customTypeSerializer: typeof(PrototypeIdListSerializer<EntityPrototype>))]
public List<string> ProjectileReflectorList = new();
[DataField]
public EntityWhitelist? Whitelist;

[DataField]
public EntityWhitelist? Blacklist;

[DataField]
public List<string> BlockedDirections = new(); // "East", "West", "North", "South"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 233f5cd

Please sign in to comment.