Skip to content

Commit 4dacf3b

Browse files
feat: expose player facility zones in properties and filters
1 parent 81018d3 commit 4dacf3b

4 files changed

Lines changed: 22 additions & 13 deletions

File tree

‎Code/ValueSystem/PlayerValue.cs‎

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System.Collections;
22
using CustomPlayerEffects;
33
using LabApi.Features.Wrappers;
4+
using MapGeneration;
45
using PlayerRoles;
56
using PlayerRoles.FirstPersonControl;
67
using PlayerRoles.FirstPersonControl.Thirdperson.Subcontrollers;
@@ -28,7 +29,7 @@ public PlayerValue(IEnumerable<Player> players)
2829
{
2930
Players = players.ToArray();
3031
}
31-
32+
3233
public PlayerValue()
3334
{
3435
Players = [];
@@ -44,9 +45,9 @@ public PlayerValue()
4445
public new static string FriendlyName => "player value";
4546

4647
private static Dictionary<string, IValueWithProperties.PropInfo>? _properties;
47-
public Dictionary<string, IValueWithProperties.PropInfo> Properties => _properties ??=
48+
public Dictionary<string, IValueWithProperties.PropInfo> Properties => _properties ??=
4849
PropertyInfoMap.ToDictionary(pair => pair.Key.ToString().LowerFirst(), pair => pair.Value, StringComparer.OrdinalIgnoreCase)
49-
.Append(new KeyValuePair<string, IValueWithProperties.PropInfo>("valType",
50+
.Append(new KeyValuePair<string, IValueWithProperties.PropInfo>("valType",
5051
new IValueWithProperties.PropInfo<PlayerValue, EnumValue<ValueType>>(_ => ValueType.Player, "The type of the value")))
5152
.ToDictionary(pair => pair.Key, pair => pair.Value, StringComparer.OrdinalIgnoreCase);
5253

@@ -116,13 +117,14 @@ public enum PlayerProperty
116117
Unit,
117118
CRole,
118119
IsTransmitting,
119-
HasRemoteAdminAccess
120+
HasRemoteAdminAccess,
121+
Zone
120122
}
121123

122124
private class Info<T>(Func<Player, T> handler, string? description)
123125
: IValueWithProperties.PropInfo<Player, T>(handler, description) where T : Value
124126
{
125-
protected override Func<object, object>? Translator { get; } =
127+
protected override Func<object, object>? Translator { get; } =
126128
obj => obj is PlayerValue { Players.Length: 1 } val ? val.Players[0] : obj;
127129
}
128130

@@ -235,7 +237,8 @@ private class Info<T>(Func<Player, T> handler, string? description)
235237
[PlayerProperty.Unit] = new Info<TextValue>(plr => NamingRulesManager.ClientFetchReceived(plr.Team, plr.UnitId).ToStaticTextValue(), "Returns the player's unit (e.g FOXTROT-03) if player is NTF or Facility Guard, otherwise returns an empty text value."),
236238
[PlayerProperty.CRole] = new Info<ReferenceValue<CRole>>(plr => CRole.LifeIdAssignedRoles.TryGetValue(plr.LifeId, out var role) ? role : null, "Returns the player's CRole if player has a Custom Role, otherwise returns an invalid reference."),
237239
[PlayerProperty.IsTransmitting] = new Info<BoolValue>(plr => PersonalRadioPlayback.IsTransmitting(plr.ReferenceHub), "Returns true if player is speaking through a radio, otherwise false."),
238-
[PlayerProperty.HasRemoteAdminAccess] = new Info<BoolValue>(plr => plr.RemoteAdminAccess, null)
240+
[PlayerProperty.HasRemoteAdminAccess] = new Info<BoolValue>(plr => plr.RemoteAdminAccess, null),
241+
[PlayerProperty.Zone] = new Info<EnumValue<FacilityZone>>(plr => plr.Zone, "The facility zone the player is in.")
239242
};
240243

241244
public override TryGet<object> ToCSharpObject(Type? targetType)
@@ -263,4 +266,4 @@ IEnumerator IEnumerable.GetEnumerator()
263266
{
264267
return GetEnumerator();
265268
}
266-
}
269+
}

‎VS Code Extension/out/ser-language.json‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2515,7 +2515,8 @@
25152515
"Unit",
25162516
"CRole",
25172517
"IsTransmitting",
2518-
"HasRemoteAdminAccess"
2518+
"HasRemoteAdminAccess",
2519+
"Zone"
25192520
],
25202521
"enumDescription": null,
25212522
"enumDescriptions": null,
@@ -3904,7 +3905,8 @@
39043905
"Unit",
39053906
"CRole",
39063907
"IsTransmitting",
3907-
"HasRemoteAdminAccess"
3908+
"HasRemoteAdminAccess",
3909+
"Zone"
39083910
],
39093911
"enumDescription": null,
39103912
"enumDescriptions": null,

‎VS Code Extension/out/visual-editor.html‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6156,7 +6156,8 @@ <h1 id="recipeTitle">What do you want to make?</h1>
61566156
"Unit",
61576157
"CRole",
61586158
"IsTransmitting",
6159-
"HasRemoteAdminAccess"
6159+
"HasRemoteAdminAccess",
6160+
"Zone"
61606161
],
61616162
"enumDescription": null,
61626163
"enumDescriptions": null,
@@ -7545,7 +7546,8 @@ <h1 id="recipeTitle">What do you want to make?</h1>
75457546
"Unit",
75467547
"CRole",
75477548
"IsTransmitting",
7548-
"HasRemoteAdminAccess"
7549+
"HasRemoteAdminAccess",
7550+
"Zone"
75497551
],
75507552
"enumDescription": null,
75517553
"enumDescriptions": null,

‎website/data/ser-truth-table.json‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2515,7 +2515,8 @@
25152515
"Unit",
25162516
"CRole",
25172517
"IsTransmitting",
2518-
"HasRemoteAdminAccess"
2518+
"HasRemoteAdminAccess",
2519+
"Zone"
25192520
],
25202521
"enumDescription": null,
25212522
"enumDescriptions": null,
@@ -3904,7 +3905,8 @@
39043905
"Unit",
39053906
"CRole",
39063907
"IsTransmitting",
3907-
"HasRemoteAdminAccess"
3908+
"HasRemoteAdminAccess",
3909+
"Zone"
39083910
],
39093911
"enumDescription": null,
39103912
"enumDescriptions": null,

0 commit comments

Comments
 (0)