1+ @file:Implement(PosMark .Service ::class )
2+
13package mapScript.shared
24
3- import mindustry.game.Team
45import mindustry.world.Tile
56
6- // 定义一种标记格式
7- // 放置世界信息版,每行可设置一个标记,形如
8- // @zone w=5 h=5
9- // 地图加载后,将存储在@zone类型信息中
10-
11- data class Pos (val type : String , val tile : Tile , val team : Team , val arg : Map <String , String >) {
12- fun error (msg : String , duration : Float = 10f) {
13- Call .labelReliable(msg, duration, tile.worldx(), tile.worldy())
14- }
15- }
16-
17- fun parse (tile : Tile ): List <Pos >? {
7+ fun parse (tile : Tile ): List <PosMark >? {
188 if (tile.block() != Blocks .worldMessage) return null
199 val lines = tile.build.config().toString().lines()
2010 if (lines.any { it.firstOrNull() != ' @' }) return null
2111 val team = tile.team()
2212 return lines.map { line ->
2313 val sp = line.split(" " ).filter { it.isNotBlank() }
24- Pos (sp[0 ], tile, team,
14+ PosMark (
15+ sp[0 ], tile, team,
2516 sp.drop(1 ).associate { it.substringBefore(' =' ) to it.substringAfter(' =' , " " ) })
2617 }
2718}
@@ -39,7 +30,7 @@ val posMap by autoInit {
3930 all.groupBy { it.type }
4031}
4132
42- fun getPoses (type : String ) = posMap[type].orEmpty()
33+ /* override */ fun getPoses (type : String ) = posMap[type].orEmpty()
4334
4435// 动态地图标记
4536listen<EventType .TileChangeEvent > { event ->
@@ -53,8 +44,8 @@ listen<EventType.TileChangeEvent> { event ->
5344 }
5445 }
5546}
56- val commands = mutableMapOf<String , (pos: Pos ) - > Unit > ()
47+ val commands = mutableMapOf<String , (pos: PosMark ) - > Unit > ()
5748onDisable { commands.clear() }
58- fun registerCommand (type : String , handler : (pos: Pos ) -> Unit ) {
49+ /* override */ fun registerCommand (type : String , handler : (pos: PosMark ) -> Unit ) {
5950 commands[type] = handler
6051}
0 commit comments