More rules tweaks (#16918)

This commit is contained in:
metalgearsloth
2023-05-29 15:11:52 +10:00
committed by GitHub
parent 71d482d8ad
commit 3ffd4d6b2e
3 changed files with 13 additions and 7 deletions

View File

@@ -58,7 +58,7 @@ public sealed class NearbyTilesPercentRule : RulesRule
/// <summary>
/// If there are anchored entities on the tile do we ignore the tile.
/// </summary>
[DataField("anchored")] public bool Anchored;
[DataField("ignoreAnchored")] public bool IgnoreAnchored;
[DataField("percent", required: true)]
public float Percent;

View File

@@ -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<AccessReaderComponent>(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++;

View File

@@ -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