File tree Expand file tree Collapse file tree
Moder.Core/Services/GameResources Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ using System . Collections . Frozen ;
2+ using MethodTimer ;
3+ using Moder . Core . Services . GameResources . Base ;
4+ using ParadoxPower . Process ;
5+
6+ namespace Moder . Core . Services . GameResources ;
7+
8+ /// <summary>
9+ /// 地形资源服务, 在 common/terrain 目录下
10+ /// </summary>
11+ public sealed class TerrainService : CommonResourcesService < TerrainService , FrozenSet < string > >
12+ {
13+ private Dictionary < string , FrozenSet < string > > . ValueCollection Terrains => Resources . Values ;
14+
15+ [ Time ( "加载地形资源" ) ]
16+ public TerrainService ( )
17+ : base ( Path . Combine ( Keywords . Common , "terrain" ) , WatcherFilter . Text ) { }
18+
19+ public bool Contains ( string terrainName )
20+ {
21+ foreach ( var terrain in Terrains )
22+ {
23+ if ( terrain . Contains ( terrainName ) )
24+ {
25+ return true ;
26+ }
27+ }
28+
29+ return false ;
30+ }
31+
32+ protected override FrozenSet < string > ? ParseFileToContent ( Node rootNode )
33+ {
34+ var terrainSet = new HashSet < string > ( 16 , StringComparer . OrdinalIgnoreCase ) ;
35+ foreach ( var child in rootNode . AllArray )
36+ {
37+ if ( ! child . IsNodeChild )
38+ {
39+ continue ;
40+ }
41+
42+ var node = child . node ;
43+ if ( StringComparer . OrdinalIgnoreCase . Equals ( node . Key , "categories" ) )
44+ {
45+ foreach ( var terrainCategory in node . Nodes )
46+ {
47+ terrainSet . Add ( terrainCategory . Key ) ;
48+ }
49+ return terrainSet . ToFrozenSet ( StringComparer . OrdinalIgnoreCase ) ;
50+ }
51+ }
52+
53+ return null ;
54+ }
55+ }
You can’t perform that action at this time.
0 commit comments