From 3ffd4d6b2ee45ff28d2ef91a881f69ff8f4c96ad Mon Sep 17 00:00:00 2001 From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Mon, 29 May 2023 15:11:52 +1000 Subject: [PATCH] More rules tweaks (#16918) --- Content.Shared/Random/RulesPrototype.cs | 2 +- Content.Shared/Random/RulesSystem.cs | 12 ++++++++---- Resources/Prototypes/audio.yml | 6 ++++-- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/Content.Shared/Random/RulesPrototype.cs b/Content.Shared/Random/RulesPrototype.cs index cfa78ecdb5..0541d503d8 100644 --- a/Content.Shared/Random/RulesPrototype.cs +++ b/Content.Shared/Random/RulesPrototype.cs @@ -58,7 +58,7 @@ public sealed class NearbyTilesPercentRule : RulesRule /// /// If there are anchored entities on the tile do we ignore the tile. /// - [DataField("anchored")] public bool Anchored; + [DataField("ignoreAnchored")] public bool IgnoreAnchored; [DataField("percent", required: true)] public float Percent; diff --git a/Content.Shared/Random/RulesSystem.cs b/Content.Shared/Random/RulesSystem.cs index 768aedf326..d4f2c6e9d1 100644 --- a/Content.Shared/Random/RulesSystem.cs +++ b/Content.Shared/Random/RulesSystem.cs @@ -2,6 +2,7 @@ using Content.Shared.Access.Components; using Content.Shared.Access.Systems; using Robust.Shared.Map; using Robust.Shared.Map.Components; +using Robust.Shared.Physics.Components; namespace Content.Shared.Random; @@ -72,8 +73,10 @@ public sealed class RulesSystem : EntitySystem foreach (var comp in _lookup.GetComponentsInRange(xform.MapID, worldPos, access.Range)) { - if (access.Anchored && !xformQuery.GetComponent(comp.Owner).Anchored || - !_reader.AreAccessTagsAllowed(access.Access, comp)) + if (!_reader.AreAccessTagsAllowed(access.Access, comp) || + access.Anchored && + (!xformQuery.TryGetComponent(comp.Owner, out var compXform) || + !compXform.Anchored)) { continue; } @@ -113,7 +116,8 @@ public sealed class RulesSystem : EntitySystem worldPos, nearbyComps.Range)) { if (nearbyComps.Anchored && - (!xformQuery.TryGetComponent(comp.Owner, out var compXform) || !compXform.Anchored)) + (!xformQuery.TryGetComponent(comp.Owner, out var compXform) || + !compXform.Anchored)) { continue; } @@ -186,7 +190,7 @@ public sealed class RulesSystem : EntitySystem if (!tiles.Tiles.Contains(_tileDef[tile.Tile.TypeId].ID)) continue; - if (tiles.Anchored && grid.GetAnchoredEntitiesEnumerator(tile.GridIndices).MoveNext(out _)) + if (tiles.IgnoreAnchored && grid.GetAnchoredEntitiesEnumerator(tile.GridIndices).MoveNext(out _)) continue; matchingTileCount++; diff --git a/Resources/Prototypes/audio.yml b/Resources/Prototypes/audio.yml index 93f3a5f3da..ecbb5884d1 100644 --- a/Resources/Prototypes/audio.yml +++ b/Resources/Prototypes/audio.yml @@ -225,7 +225,7 @@ id: NearMaintenance rules: - !type:NearbyTilesPercentRule - anchored: false + ignoreAnchored: true percent: 0.25 tiles: - Plating @@ -235,10 +235,11 @@ id: NearMedical rules: - !type:NearbyTilesPercentRule + ignoreAnchored: true percent: 0.5 tiles: - FloorWhite - range: 5 + range: 3 - type: rules id: NearPrayable @@ -253,6 +254,7 @@ id: NearMorgue rules: - !type:NearbyComponentsRule + anchored: true count: 2 components: - type: Morgue