Prevent fly-by fixture from powering containment field generator (#29225)

* Prevent fly-by fixture from powering containment field generator

* Update according to review
This commit is contained in:
Alice "Arimah" Heurlin
2024-06-20 01:51:07 +02:00
committed by GitHub
parent 67cc089dd0
commit 2b92ec79f7
2 changed files with 9 additions and 1 deletions

View File

@@ -65,7 +65,8 @@ public sealed class ContainmentFieldGeneratorSystem : EntitySystem
/// </summary>
private void HandleGeneratorCollide(Entity<ContainmentFieldGeneratorComponent> generator, ref StartCollideEvent args)
{
if (_tags.HasTag(args.OtherEntity, generator.Comp.IDTag))
if (args.OtherFixtureId == generator.Comp.SourceFixtureId &&
_tags.HasTag(args.OtherEntity, generator.Comp.IDTag))
{
ReceivePower(generator.Comp.PowerReceived, generator);
generator.Comp.Accumulator = 0f;

View File

@@ -69,6 +69,13 @@ public sealed partial class ContainmentFieldGeneratorComponent : Component
[DataField("idTag", customTypeSerializer: typeof(PrototypeIdSerializer<TagPrototype>))]
public string IDTag = "EmitterBolt";
/// <summary>
/// Which fixture ID should test collision with from the entity that powers the generator?
/// Prevents the generator from being powered by fly-by fixtures.
/// </summary>
[DataField]
public string SourceFixtureId = "projectile";
/// <summary>
/// Is the generator toggled on?
/// </summary>