11using System ;
2- using System . Linq ;
32using System . Threading ;
4- using AET . ModVerify . Reporting ;
53using AET . ModVerify . Settings ;
6- using AnakinRaW . CommonUtilities . Collections ;
74using PG . StarWarsGame . Engine ;
8- using PG . StarWarsGame . Engine . CommandBar ;
9- using PG . StarWarsGame . Engine . CommandBar . Components ;
105
116namespace AET . ModVerify . Verifiers ;
127
@@ -27,135 +22,4 @@ public override void Verify(CancellationToken token)
2722 VerifyCommandBarShellsGroups ( ) ;
2823 VerifyCommandBarComponents ( ) ;
2924 }
30-
31- private void VerifySingleComponent ( CommandBarBaseComponent component )
32- {
33- VerifyCommandBarModel ( component ) ;
34- VerifyComponentBone ( component ) ;
35- }
36- }
37-
38- partial class CommandBarVerifier
39- {
40- private void VerifyCommandBarModel ( CommandBarBaseComponent component )
41- {
42- if ( component is not CommandBarShellComponent shellComponent )
43- return ;
44-
45- if ( shellComponent . ModelPath is null )
46- {
47- AddError ( VerificationError . Create ( VerifierChain ,
48- CommandBarShellNoModel , $ "The CommandBarShellComponent '{ component . Name } ' has no model specified.",
49- VerificationSeverity . Error , shellComponent . Name ) ) ;
50- return ;
51- }
52-
53- var model = GameEngine . PGRender . LoadModelAndAnimations ( shellComponent . ModelPath . AsSpan ( ) , null ) ;
54- if ( model is null )
55- {
56- AddError ( VerificationError . Create ( VerifierChain ,
57- CommandBarShellNoModel , $ "Could not find model '{ shellComponent . ModelPath } ' for CommandBarShellComponent '{ component . Name } '.",
58- VerificationSeverity . Error , [ shellComponent . Name ] , shellComponent . ModelPath ) ) ;
59- return ;
60- }
61- }
62-
63- private void VerifyComponentBone ( CommandBarBaseComponent component )
64- {
65- if ( component is CommandBarShellComponent )
66- return ;
67-
68- if ( component . Bone == - 1 )
69- {
70- AddError ( VerificationError . Create ( VerifierChain ,
71- CommandBarShellNoModel , $ "The CommandBar component '{ component . Name } ' is not connected to a shell component.",
72- VerificationSeverity . Warning , component . Name ) ) ;
73- }
74- }
75- }
76-
77- partial class CommandBarVerifier
78- {
79- private void VerifyCommandBarComponents ( )
80- {
81- var occupiedComponentIds = SupportedCommandBarComponentData . GetComponentIdsForEngine ( Repository . EngineType ) . Keys
82- . ToDictionary ( value => value , _ => false ) ;
83-
84- foreach ( var component in GameEngine . CommandBar . Components )
85- {
86- if ( ! occupiedComponentIds . TryGetValue ( component . Id , out var alreadyOccupied ) )
87- {
88- AddError ( VerificationError . Create (
89- VerifierChain ,
90- CommandBarUnsupportedComponent ,
91- $ "The CommandBar component '{ component . Name } ' is not supported by the game.",
92- VerificationSeverity . Information ,
93- component . Name ) ) ;
94- }
95- else
96- {
97- occupiedComponentIds [ component . Id ] = true ;
98- }
99-
100- if ( alreadyOccupied )
101- {
102- AddError ( VerificationError . Create ( VerifierChain ,
103- CommandBarDuplicateComponent ,
104- $ "The CommandBar component '{ component . Name } ' with ID '{ component . Id } ' already exists.",
105- VerificationSeverity . Warning ,
106- component . Name ) ) ;
107- }
108-
109- VerifySingleComponent ( component ) ;
110- }
111- }
112- }
113-
114- partial class CommandBarVerifier
115- {
116- private void VerifyCommandBarShellsGroups ( )
117- {
118- var shellGroups = new FrugalList < string > ( ) ;
119- foreach ( var groupPair in GameEngine . CommandBar . Groups )
120- {
121- if ( groupPair . Key == CommandBarConstants . ShellGroupName )
122- {
123- shellGroups . Add ( groupPair . Key ) ;
124- VerifyShellGroup ( groupPair . Value ) ;
125- }
126- else if ( groupPair . Key . Equals ( CommandBarConstants . ShellGroupName , StringComparison . OrdinalIgnoreCase ) )
127- {
128- shellGroups . Add ( groupPair . Key ) ;
129- }
130- }
131-
132- if ( shellGroups . Count == 0 )
133- AddError ( VerificationError . Create ( VerifierChain ,
134- CommandBarNoShellsGroup ,
135- $ "No CommandBarGroup '{ CommandBarConstants . ShellGroupName } ' found.",
136- VerificationSeverity . Error ,
137- "GameCommandBar" ) ) ;
138-
139- if ( shellGroups . Count > 1 )
140- AddError ( VerificationError . Create ( VerifierChain ,
141- CommandBarManyShellsGroup ,
142- $ "Found more than one Shells CommandBarGroup. Mind that group names are case-sensitive. Correct name is '{ CommandBarConstants . ShellGroupName } '",
143- VerificationSeverity . Warning ,
144- shellGroups , "GameCommandBar" ) ) ;
145- }
146-
147- private void VerifyShellGroup ( CommandBarComponentGroup shellGroup )
148- {
149- foreach ( var component in shellGroup . Components )
150- {
151- var shellComponent = component as CommandBarShellComponent ;
152- if ( shellComponent ? . Type is not CommandBarComponentType . Shell )
153- {
154- AddError ( VerificationError . Create ( VerifierChain ,
155- CommandBarNoShellsComponentInShellGroup ,
156- $ "The CommandBar component '{ component . Name } ' is not a shell component, but part of the '{ CommandBarConstants . ShellGroupName } ' group.",
157- VerificationSeverity . Warning , component . Name ) ) ;
158- }
159- }
160- }
16125}
0 commit comments