@@ -13,48 +13,75 @@ public sealed class EntityWhitelistTest : GameTest
1313 private const string InvalidComponent = "Sprite" ;
1414 private const string ValidComponent = "Physics" ;
1515
16- [ TestPrototypes ]
17- private const string Prototypes = $@ "
18- - type: Tag
19- id: WhitelistTestValidTag
20- - type: Tag
21- id: WhitelistTestInvalidTag
22-
23- - type: entity
24- id: WhitelistDummy
25- components:
26- - type: ItemSlots
27- slots:
28- slotName:
29- whitelist:
30- prototypes:
31- - ValidPrototypeDummy
32- components:
33- - { ValidComponent }
34- tags:
35- - WhitelistTestValidTag
36-
37- - type: entity
38- id: InvalidComponentDummy
39- components:
40- - type: { InvalidComponent }
41- - type: entity
42- id: WhitelistTestInvalidTagDummy
43- components:
44- - type: Tag
45- tags:
46- - WhitelistTestInvalidTag
47-
48- - type: entity
49- id: ValidComponentDummy
50- components:
51- - type: { ValidComponent }
52- - type: entity
53- id: WhitelistTestValidTagDummy
54- components:
55- - type: Tag
56- tags:
57- - WhitelistTestValidTag" ;
16+ [ TestPrototypes ] // Starlight, I didn't want to have to modify this entire section, but editor config will yell at me if I don't.
17+ private const string Prototypes = $ """
18+ - type: Tag
19+ id: WhitelistTestValidTag
20+ - type: Tag
21+ id: WhitelistTestInvalidTag
22+
23+ - type: entity
24+ id: WhitelistDummy
25+ components:
26+ - type: ItemSlots
27+ slots:
28+ slotName:
29+ whitelist:
30+ prototypes:
31+ - ValidPrototypeDummy
32+ components:
33+ - { ValidComponent }
34+ tags:
35+ - WhitelistTestValidTag
36+ toolQuality:
37+ - Slicing
38+
39+ - type: entity
40+ id: InvalidComponentDummy
41+ components:
42+ - type: { InvalidComponent }
43+
44+ - type: entity
45+ id: WhitelistTestInvalidTagDummy
46+ components:
47+ - type: Tag
48+ tags:
49+ - WhitelistTestInvalidTag
50+
51+ - type: entity
52+ id: ValidComponentDummy
53+ components:
54+ - type: { ValidComponent }
55+
56+ - type: entity
57+ id: WhitelistTestValidTagDummy
58+ components:
59+ - type: Tag
60+ tags:
61+ - WhitelistTestValidTag
62+
63+ - type: entity
64+ id: WhitelistTestInvalidToolQualityDummy
65+ components:
66+ - type: Tool
67+ qualities:
68+ - Anchoring
69+
70+ - type: entity
71+ id: WhitelistTestValidToolQualityDummy
72+ components:
73+ - type: Tool
74+ qualities:
75+ - Slicing
76+
77+ - type: entity
78+ id: WhitelistTestAllToolQualitiesDummy
79+ components:
80+ - type: Tool
81+ qualities:
82+ - Cutting
83+ - Slicing
84+ """ ;
5885
5986 [ Test ]
6087 public async Task Test ( )
@@ -72,24 +99,44 @@ await server.WaitAssertion(() =>
7299 {
73100 var validComponent = sEntities . SpawnEntity ( "ValidComponentDummy" , mapCoordinates ) ;
74101 var WhitelistTestValidTag = sEntities . SpawnEntity ( "WhitelistTestValidTagDummy" , mapCoordinates ) ;
102+ var validToolQuality = sEntities . SpawnEntity ( "WhitelistTestValidToolQualityDummy" , mapCoordinates ) ; // Starlight
103+ var allToolQualities = sEntities . SpawnEntity ( "WhitelistTestAllToolQualitiesDummy" , mapCoordinates ) ; // Starlight
75104
76105 var invalidComponent = sEntities . SpawnEntity ( "InvalidComponentDummy" , mapCoordinates ) ;
77106 var WhitelistTestInvalidTag = sEntities . SpawnEntity ( "WhitelistTestInvalidTagDummy" , mapCoordinates ) ;
107+ var invalidToolQuality = sEntities . SpawnEntity ( "WhitelistTestInvalidToolQualityDummy" , mapCoordinates ) ; // Starlight
78108
79109 // Test instantiated on its own
80110 var whitelistInst = new EntityWhitelist
81111 {
82112 Components = new [ ] { $ "{ ValidComponent } " } ,
83- Tags = new ( ) { "WhitelistTestValidTag" }
113+ Tags = new ( ) { "WhitelistTestValidTag" } ,
114+ ToolQualities = new ( ) { "Slicing" } // Starlight
84115 } ;
85116
86117 Assert . Multiple ( ( ) =>
87118 {
88119 Assert . That ( sys . IsValid ( whitelistInst , validComponent ) , Is . True ) ;
89120 Assert . That ( sys . IsValid ( whitelistInst , WhitelistTestValidTag ) , Is . True ) ;
121+ Assert . That ( sys . IsValid ( whitelistInst , validToolQuality ) , Is . True ) ; // Starlight
90122
91123 Assert . That ( sys . IsValid ( whitelistInst , invalidComponent ) , Is . False ) ;
92124 Assert . That ( sys . IsValid ( whitelistInst , WhitelistTestInvalidTag ) , Is . False ) ;
125+ #region Starlight
126+ Assert . That ( sys . IsValid ( whitelistInst , invalidToolQuality ) , Is . False ) ;
127+ } ) ;
128+
129+ var requireAllToolQualities = new EntityWhitelist
130+ {
131+ RequireAll = true ,
132+ ToolQualities = new ( ) { "Cutting" , "Slicing" }
133+ } ;
134+
135+ Assert . Multiple ( ( ) =>
136+ {
137+ Assert . That ( sys . IsValid ( requireAllToolQualities , allToolQualities ) , Is . True ) ;
138+ Assert . That ( sys . IsValid ( requireAllToolQualities , validToolQuality ) , Is . False ) ;
139+ #endregion
93140 } ) ;
94141
95142 // Test from serialized
@@ -101,15 +148,18 @@ await server.WaitAssertion(() =>
101148 {
102149 Assert . That ( whitelistSer . Components , Is . Not . Null ) ;
103150 Assert . That ( whitelistSer . Tags , Is . Not . Null ) ;
151+ Assert . That ( whitelistSer . ToolQualities , Is . Not . Null ) ; // Starlight
104152 } ) ;
105153
106154 Assert . Multiple ( ( ) =>
107155 {
108156 Assert . That ( sys . IsValid ( whitelistSer , validComponent ) , Is . True ) ;
109157 Assert . That ( sys . IsValid ( whitelistSer , WhitelistTestValidTag ) , Is . True ) ;
158+ Assert . That ( sys . IsValid ( whitelistSer , validToolQuality ) , Is . True ) ; // Starlight
110159
111160 Assert . That ( sys . IsValid ( whitelistSer , invalidComponent ) , Is . False ) ;
112161 Assert . That ( sys . IsValid ( whitelistSer , WhitelistTestInvalidTag ) , Is . False ) ;
162+ Assert . That ( sys . IsValid ( whitelistSer , invalidToolQuality ) , Is . False ) ; // Starlight
113163 } ) ;
114164 } ) ;
115165 }
0 commit comments