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> /// <summary>
/// If there are anchored entities on the tile do we ignore the tile. /// If there are anchored entities on the tile do we ignore the tile.
/// </summary> /// </summary>
[DataField("anchored")] public bool Anchored; [DataField("ignoreAnchored")] public bool IgnoreAnchored;
[DataField("percent", required: true)] [DataField("percent", required: true)]
public float Percent; public float Percent;

View File

@@ -2,6 +2,7 @@ using Content.Shared.Access.Components;
using Content.Shared.Access.Systems; using Content.Shared.Access.Systems;
using Robust.Shared.Map; using Robust.Shared.Map;
using Robust.Shared.Map.Components; using Robust.Shared.Map.Components;
using Robust.Shared.Physics.Components;
namespace Content.Shared.Random; namespace Content.Shared.Random;
@@ -72,8 +73,10 @@ public sealed class RulesSystem : EntitySystem
foreach (var comp in _lookup.GetComponentsInRange<AccessReaderComponent>(xform.MapID, foreach (var comp in _lookup.GetComponentsInRange<AccessReaderComponent>(xform.MapID,
worldPos, access.Range)) worldPos, access.Range))
{ {
if (access.Anchored && !xformQuery.GetComponent(comp.Owner).Anchored || if (!_reader.AreAccessTagsAllowed(access.Access, comp) ||
!_reader.AreAccessTagsAllowed(access.Access, comp)) access.Anchored &&
(!xformQuery.TryGetComponent(comp.Owner, out var compXform) ||
!compXform.Anchored))
{ {
continue; continue;
} }
@@ -113,7 +116,8 @@ public sealed class RulesSystem : EntitySystem
worldPos, nearbyComps.Range)) worldPos, nearbyComps.Range))
{ {
if (nearbyComps.Anchored && if (nearbyComps.Anchored &&
(!xformQuery.TryGetComponent(comp.Owner, out var compXform) || !compXform.Anchored)) (!xformQuery.TryGetComponent(comp.Owner, out var compXform) ||
!compXform.Anchored))
{ {
continue; continue;
} }
@@ -186,7 +190,7 @@ public sealed class RulesSystem : EntitySystem
if (!tiles.Tiles.Contains(_tileDef[tile.Tile.TypeId].ID)) if (!tiles.Tiles.Contains(_tileDef[tile.Tile.TypeId].ID))
continue; continue;
if (tiles.Anchored && grid.GetAnchoredEntitiesEnumerator(tile.GridIndices).MoveNext(out _)) if (tiles.IgnoreAnchored && grid.GetAnchoredEntitiesEnumerator(tile.GridIndices).MoveNext(out _))
continue; continue;
matchingTileCount++; matchingTileCount++;

View File

@@ -225,7 +225,7 @@
id: NearMaintenance id: NearMaintenance
rules: rules:
- !type:NearbyTilesPercentRule - !type:NearbyTilesPercentRule
anchored: false ignoreAnchored: true
percent: 0.25 percent: 0.25
tiles: tiles:
- Plating - Plating
@@ -235,10 +235,11 @@
id: NearMedical id: NearMedical
rules: rules:
- !type:NearbyTilesPercentRule - !type:NearbyTilesPercentRule
ignoreAnchored: true
percent: 0.5 percent: 0.5
tiles: tiles:
- FloorWhite - FloorWhite
range: 5 range: 3
- type: rules - type: rules
id: NearPrayable id: NearPrayable
@@ -253,6 +254,7 @@
id: NearMorgue id: NearMorgue
rules: rules:
- !type:NearbyComponentsRule - !type:NearbyComponentsRule
anchored: true
count: 2 count: 2
components: components:
- type: Morgue - type: Morgue