feat: 更新 IntoHole 的球体、滑槽和环境资产
- 为铁球、陶瓷球和木球制作风格化材质,归档 CC0 原始参考 - 更新方形球洞和实心滑槽,统一 90° 弯槽并兼容旧存档 - 用顺流泡沫表示水流方向,为冰块制作三种交错的裂纹 - 同步 Blender 源资产、Godot 加载、工坊和试玩预览
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
extends RefCounted
|
||||
|
||||
const Chutes = preload("res://runtime/chute_types.gd")
|
||||
var lib
|
||||
var chutes: Array
|
||||
var entity_ids: Array=[]
|
||||
@@ -26,33 +27,34 @@ func validate(data: Variant) -> String:
|
||||
var version=data.get("schemaVersion")
|
||||
if not (version is int or version is float):return "缺少关卡版本"
|
||||
if (version!=1 and version!=2) or data.get("assetFamily")!="railbound_inspired":return "关卡版本或资产系列不匹配"
|
||||
if not data.get("pieces") is Array or not data.get("balls") is Array or not data.get("entities",[]) is Array:return "缺少积木、实体或铁球数据"
|
||||
if not data.get("pieces") is Array or not data.get("balls") is Array or not data.get("entities",[]) is Array:return "缺少积木、实体或小球数据"
|
||||
var legacy: bool=data.schemaVersion==1
|
||||
if legacy and (not valid_vector(data.get("goal")) or not data.get("entities",[]).is_empty()):return "旧版洞口或实体数据无效"
|
||||
var ids: Array=[];var decoded: Array=[]
|
||||
for group in ["pieces","entities"]:
|
||||
for r in data.get(group,[]):
|
||||
var allowed: Array=chutes if group=="pieces" else entity_ids
|
||||
if not r is Dictionary or r.get("kind") not in allowed or not valid_vector(r.get("position")):return "无效的方块类型或坐标"
|
||||
if not r is Dictionary or not r.get("kind") is String or Chutes.canonical_kind(r.kind) not in allowed or not valid_vector(r.get("position")):return "无效的方块类型或坐标"
|
||||
if not r.get("id") is String or r.id.is_empty() or r.id in ids:return "方块编号缺失或重复"
|
||||
if not (r.get("quarter") is float or r.get("quarter") is int):return "无效的旋转值"
|
||||
if r.quarter!=int(r.quarter) or r.quarter<0 or r.quarter>3:return "旋转必须为 0 / 90 / 180 / 270 度"
|
||||
if r.kind!="goal_hole" and (r.position[0]!=round(r.position[0]) or r.position[2]!=round(r.position[2]) or r.position[1]*2!=round(r.position[1]*2)):return "积木坐标必须对齐网格"
|
||||
var d={"id":r.id,"kind":r.kind,"position":lib.vector(r.position),"quarter":int(r.quarter)}
|
||||
# X/Z remain grid-based; exact Y is required for groove-to-flat joins.
|
||||
if r.kind!="goal_hole" and (r.position[0]!=round(r.position[0]) or r.position[2]!=round(r.position[2])):return "积木 X / Z 坐标必须对齐网格"
|
||||
var d={"id":r.id,"kind":Chutes.canonical_kind(r.kind),"position":lib.vector(r.position),"quarter":Chutes.canonical_quarter(r.kind,int(r.quarter))}
|
||||
for other in decoded:
|
||||
if overlaps(d,other):return "关卡中有重叠方块"
|
||||
decoded.append(d);ids.append(r.id)
|
||||
var ball_ids: Array=[]
|
||||
for b in data.balls:
|
||||
if not b is Dictionary or not b.get("id") is String or b.id.is_empty() or b.id in ball_ids:return "铁球编号缺失或重复"
|
||||
if not b is Dictionary or not b.get("id") is String or b.id.is_empty() or b.id in ball_ids:return "小球编号缺失或重复"
|
||||
if legacy:
|
||||
if b.get("pieceId") not in ids:return "旧版铁球起点引用无效"
|
||||
if b.get("pieceId") not in ids:return "旧版小球起点引用无效"
|
||||
if not (b.get("pathT") is float or b.get("pathT") is int) or not is_finite(float(b.pathT)) or b.pathT<0 or b.pathT>1:return "旧版起点位置必须位于槽内"
|
||||
var r: Dictionary=decoded[ids.find(b.pieceId)]
|
||||
if not (b.get("branch") is float or b.get("branch") is int) or b.branch!=int(b.branch) or b.branch<0 or b.branch>=lib.catalog[r.kind].upperPaths.size():return "旧版起点分支无效"
|
||||
else:
|
||||
if not valid_vector(b.get("position")):return "铁球球心坐标无效"
|
||||
if b.get("ballTypeId","iron_ball")!="iron_ball":return "未知的小球类型"
|
||||
if not valid_vector(b.get("position")):return "小球球心坐标无效"
|
||||
if b.get("ballTypeId","iron_ball") not in lib.ball_type_ids():return "未知的小球类型"
|
||||
if b.has("launchDirection") and not valid_vector(b.launchDirection):return "初速度方向无效"
|
||||
ball_ids.append(b.id)
|
||||
return ""
|
||||
@@ -63,7 +65,7 @@ func array_from(v: Vector3) -> Array:
|
||||
func normalize(data: Dictionary) -> Dictionary:
|
||||
var records: Array=[]
|
||||
for r in data.pieces+data.get("entities",[]):
|
||||
var record={"id":r.id,"kind":r.kind,"position":lib.vector(r.position),"quarter":int(r.quarter)}
|
||||
var record={"id":r.id,"kind":Chutes.canonical_kind(r.kind),"position":lib.vector(r.position),"quarter":Chutes.canonical_quarter(r.kind,int(r.quarter))}
|
||||
# Obsolete per-block speedGain fields are intentionally discarded on load.
|
||||
records.append(record)
|
||||
var balls: Array=[]
|
||||
@@ -73,8 +75,13 @@ func normalize(data: Dictionary) -> Dictionary:
|
||||
for r in records:
|
||||
if r.id==b.pieceId:record=r;break
|
||||
var basis:=Basis(Vector3.UP,-int(record.quarter)*PI/2)
|
||||
var position: Vector3=lib.record_center(record)+basis*lib.ball_on_surface(record.kind,float(b.pathT),int(b.branch))
|
||||
var direction: Vector3=basis*lib.path_tangent(record.kind,float(b.pathT),int(b.branch))
|
||||
var old_kind:String=""
|
||||
for original in data.pieces:
|
||||
if original.id==b.pieceId:old_kind=original.kind;break
|
||||
var path_t:float=1.0-float(b.pathT) if old_kind=="turn_ccw" else float(b.pathT)
|
||||
var position: Vector3=lib.record_center(record)+basis*lib.ball_on_surface(record.kind,path_t,int(b.branch))
|
||||
var direction: Vector3=basis*lib.path_tangent(record.kind,path_t,int(b.branch))
|
||||
if old_kind=="turn_ccw":direction=-direction
|
||||
if direction.y>0:direction=-direction
|
||||
balls.append({"id":b.id,"ballTypeId":"iron_ball","position":array_from(position),"launchDirection":array_from(direction.normalized())})
|
||||
var goal_id: String="legacy_goal"
|
||||
@@ -82,13 +89,13 @@ func normalize(data: Dictionary) -> Dictionary:
|
||||
records.append({"id":goal_id,"kind":"goal_hole","position":lib.vector(data.goal),"quarter":0})
|
||||
else:
|
||||
for b in data.balls:
|
||||
balls.append({"id":b.id,"ballTypeId":"iron_ball","position":array_from(lib.vector(b.position)),"launchDirection":array_from(lib.vector(b.get("launchDirection",[1,0,0])))})
|
||||
balls.append({"id":b.id,"ballTypeId":b.get("ballTypeId","iron_ball"),"position":array_from(lib.vector(b.position)),"launchDirection":array_from(lib.vector(b.get("launchDirection",[1,0,0])))})
|
||||
return {"records":records,"balls":balls}
|
||||
|
||||
func encode(records: Array,balls: Array,title: String) -> Dictionary:
|
||||
var pieces: Array=[];var entities: Array=[]
|
||||
for r in records:
|
||||
var item={"id":r.id,"kind":r.kind,"position":array_from(r.position),"quarter":r.quarter}
|
||||
if r.kind in chutes:pieces.append(item)
|
||||
var item={"id":r.id,"kind":Chutes.canonical_kind(r.kind),"position":array_from(r.position),"quarter":Chutes.canonical_quarter(r.kind,int(r.quarter))}
|
||||
if item.kind in chutes:pieces.append(item)
|
||||
else:entities.append(item)
|
||||
return {"schemaVersion":2,"assetFamily":"railbound_inspired","title":title,"pieces":pieces,"entities":entities,"balls":balls.duplicate(true)}
|
||||
|
||||
Reference in New Issue
Block a user