add 蒙德清泉镇 5-1
This commit is contained in:
@@ -212,10 +212,10 @@ def generate_ley_line_data():
|
|||||||
# Second pass: Process all target points to create blossom nodes
|
# Second pass: Process all target points to create blossom nodes
|
||||||
# Also maintain a map from file info to target nodes
|
# Also maintain a map from file info to target nodes
|
||||||
region_area_num_to_target = {}
|
region_area_num_to_target = {}
|
||||||
|
|
||||||
for file_path, path_data in file_data.items():
|
for file_path, path_data in file_data.items():
|
||||||
_, last_pos = get_first_and_last_positions(path_data)
|
_, last_pos = get_first_and_last_positions(path_data)
|
||||||
if not last_pos or last_pos.get("type") != "target":
|
if not last_pos:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Extract region from filename
|
# Extract region from filename
|
||||||
@@ -228,18 +228,23 @@ def generate_ley_line_data():
|
|||||||
if not region or not area or not num:
|
if not region or not area or not num:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Process target points as blossom nodes
|
# Process last points as blossom nodes (regardless of type)
|
||||||
target_x = format_coord(float(last_pos["x"]))
|
target_x = format_coord(float(last_pos["x"]))
|
||||||
target_y = format_coord(float(last_pos["y"]))
|
target_y = format_coord(float(last_pos["y"]))
|
||||||
|
|
||||||
# Check if we already have a nearby blossom node
|
# Determine node type - default to blossom if type is not specified or is target
|
||||||
blossom_node = find_nearby_node(nodes, target_x, target_y, "blossom")
|
node_type = last_pos.get("type", "blossom")
|
||||||
|
if node_type == "target":
|
||||||
|
node_type = "blossom"
|
||||||
|
|
||||||
|
# Check if we already have a nearby node of the same type
|
||||||
|
blossom_node = find_nearby_node(nodes, target_x, target_y, node_type)
|
||||||
|
|
||||||
if not blossom_node:
|
if not blossom_node:
|
||||||
# Create new blossom node
|
# Create new node
|
||||||
blossom_node = {
|
blossom_node = {
|
||||||
"id": next_node_id,
|
"id": next_node_id,
|
||||||
"type": "blossom",
|
"type": node_type,
|
||||||
"region": region,
|
"region": region,
|
||||||
"position": {"x": target_x, "y": target_y},
|
"position": {"x": target_x, "y": target_y},
|
||||||
"prev": [],
|
"prev": [],
|
||||||
@@ -249,7 +254,7 @@ def generate_ley_line_data():
|
|||||||
node_map[next_node_id] = blossom_node
|
node_map[next_node_id] = blossom_node
|
||||||
next_node_id += 1
|
next_node_id += 1
|
||||||
|
|
||||||
# Store the blossom node in our region-area-num map
|
# Store the node in our region-area-num map
|
||||||
key = f"{region}-{area}"
|
key = f"{region}-{area}"
|
||||||
if key not in region_area_num_to_target:
|
if key not in region_area_num_to_target:
|
||||||
region_area_num_to_target[key] = {}
|
region_area_num_to_target[key] = {}
|
||||||
@@ -275,47 +280,47 @@ def generate_ley_line_data():
|
|||||||
target_data = read_pathing_file(target_path)
|
target_data = read_pathing_file(target_path)
|
||||||
|
|
||||||
if target_data and "positions" in target_data and target_data["positions"]:
|
if target_data and "positions" in target_data and target_data["positions"]:
|
||||||
# Create blossom node from the target file
|
# Create node from the target file
|
||||||
target_pos = target_data["positions"][0]
|
target_pos = target_data["positions"][0]
|
||||||
if target_pos.get("type") == "target":
|
# Determine node type - default to blossom if type is not specified or is target
|
||||||
target_x = format_coord(float(target_pos["x"]))
|
node_type = target_pos.get("type", "blossom")
|
||||||
target_y = format_coord(float(target_pos["y"]))
|
if node_type == "target":
|
||||||
|
node_type = "blossom"
|
||||||
# Check if we already have a nearby blossom node
|
|
||||||
blossom_node = find_nearby_node(nodes, target_x, target_y, "blossom")
|
target_x = format_coord(float(target_pos["x"]))
|
||||||
|
target_y = format_coord(float(target_pos["y"]))
|
||||||
if not blossom_node:
|
|
||||||
# Create new blossom node
|
# Check if we already have a nearby node of the same type
|
||||||
blossom_node = {
|
blossom_node = find_nearby_node(nodes, target_x, target_y, node_type)
|
||||||
"id": next_node_id,
|
|
||||||
"type": "blossom",
|
if not blossom_node:
|
||||||
"region": region,
|
# Create new node
|
||||||
"position": {"x": target_x, "y": target_y},
|
blossom_node = {
|
||||||
"prev": [],
|
"id": next_node_id,
|
||||||
"next": []
|
"type": node_type,
|
||||||
}
|
"region": region,
|
||||||
nodes.append(blossom_node)
|
"position": {"x": target_x, "y": target_y},
|
||||||
node_map[next_node_id] = blossom_node
|
"prev": [],
|
||||||
next_node_id += 1
|
"next": []
|
||||||
|
|
||||||
# Add to region_area_num_to_target map
|
|
||||||
if key not in region_area_num_to_target:
|
|
||||||
region_area_num_to_target[key] = {}
|
|
||||||
region_area_num_to_target[key][num] = {
|
|
||||||
"node": blossom_node,
|
|
||||||
"file_path": file_path
|
|
||||||
}
|
}
|
||||||
|
nodes.append(blossom_node)
|
||||||
|
node_map[next_node_id] = blossom_node
|
||||||
|
next_node_id += 1
|
||||||
|
|
||||||
|
# Add to region_area_num_to_target map
|
||||||
|
if key not in region_area_num_to_target:
|
||||||
|
region_area_num_to_target[key] = {}
|
||||||
|
region_area_num_to_target[key][num] = {
|
||||||
|
"node": blossom_node,
|
||||||
|
"file_path": file_path
|
||||||
|
}
|
||||||
|
|
||||||
# Third pass: Connect teleport points to their target blossoms
|
# Third pass: Connect teleport points to their destination nodes
|
||||||
for file_path, path_data in file_data.items():
|
for file_path, path_data in file_data.items():
|
||||||
first_pos, last_pos = get_first_and_last_positions(path_data)
|
first_pos, last_pos = get_first_and_last_positions(path_data)
|
||||||
if not first_pos or not last_pos:
|
if not first_pos or not last_pos:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Skip if this isn't a valid target
|
|
||||||
if last_pos.get("type") != "target":
|
|
||||||
continue
|
|
||||||
|
|
||||||
# Extract file info
|
# Extract file info
|
||||||
file_name = os.path.basename(file_path)
|
file_name = os.path.basename(file_path)
|
||||||
region, area, num = extract_route_number(file_name)
|
region, area, num = extract_route_number(file_name)
|
||||||
@@ -324,38 +329,44 @@ def generate_ley_line_data():
|
|||||||
if not region or not area or not num:
|
if not region or not area or not num:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# For teleport source type, connect to target
|
# For teleport source type, connect to destination
|
||||||
if first_pos.get("type") == "teleport":
|
if first_pos.get("type") == "teleport":
|
||||||
# Find teleport node
|
# Find teleport node
|
||||||
x = format_coord(float(first_pos["x"]))
|
x = format_coord(float(first_pos["x"]))
|
||||||
y = format_coord(float(first_pos["y"]))
|
y = format_coord(float(first_pos["y"]))
|
||||||
teleport_node = find_nearby_node(nodes, x, y, "teleport")
|
teleport_node = find_nearby_node(nodes, x, y, "teleport")
|
||||||
|
|
||||||
# Find target blossom node
|
# Find destination node
|
||||||
target_x = format_coord(float(last_pos["x"]))
|
dest_x = format_coord(float(last_pos["x"]))
|
||||||
target_y = format_coord(float(last_pos["y"]))
|
dest_y = format_coord(float(last_pos["y"]))
|
||||||
target_node = find_nearby_node(nodes, target_x, target_y, "blossom")
|
|
||||||
|
|
||||||
if teleport_node and target_node:
|
# Determine node type, default to blossom for target or if not specified
|
||||||
|
dest_type = last_pos.get("type", "blossom")
|
||||||
|
if dest_type == "target":
|
||||||
|
dest_type = "blossom"
|
||||||
|
|
||||||
|
dest_node = find_nearby_node(nodes, dest_x, dest_y, dest_type)
|
||||||
|
|
||||||
|
if teleport_node and dest_node:
|
||||||
# Add connection
|
# Add connection
|
||||||
relative_path = generate_relative_path(file_path, script_dir)
|
relative_path = generate_relative_path(file_path, script_dir)
|
||||||
|
|
||||||
# Add target to teleport's next array if not already there
|
# Add destination to teleport's next array if not already there
|
||||||
route_exists = False
|
route_exists = False
|
||||||
for route in teleport_node["next"]:
|
for route in teleport_node["next"]:
|
||||||
if route["target"] == target_node["id"]:
|
if route["target"] == dest_node["id"]:
|
||||||
route_exists = True
|
route_exists = True
|
||||||
break
|
break
|
||||||
|
|
||||||
if not route_exists:
|
if not route_exists:
|
||||||
teleport_node["next"].append({
|
teleport_node["next"].append({
|
||||||
"target": target_node["id"],
|
"target": dest_node["id"],
|
||||||
"route": relative_path
|
"route": relative_path
|
||||||
})
|
})
|
||||||
|
|
||||||
# Add teleport to target's prev array if not already there
|
# Add teleport to destination's prev array if not already there
|
||||||
if teleport_node["id"] not in target_node["prev"]:
|
if teleport_node["id"] not in dest_node["prev"]:
|
||||||
target_node["prev"].append(teleport_node["id"])
|
dest_node["prev"].append(teleport_node["id"])
|
||||||
|
|
||||||
# Fourth pass: Connect nodes based on numerical sequence and handle branch paths
|
# Fourth pass: Connect nodes based on numerical sequence and handle branch paths
|
||||||
for region_area, num_to_target in region_area_num_to_target.items():
|
for region_area, num_to_target in region_area_num_to_target.items():
|
||||||
@@ -433,14 +444,14 @@ def generate_ley_line_data():
|
|||||||
if current_node["id"] not in next_node["prev"]:
|
if current_node["id"] not in next_node["prev"]:
|
||||||
next_node["prev"].append(current_node["id"])
|
next_node["prev"].append(current_node["id"])
|
||||||
|
|
||||||
# Fifth pass: Connect "path" type sources to their targets
|
# Fifth pass: Connect "path" type sources to their destinations
|
||||||
for file_path, path_data in file_data.items():
|
for file_path, path_data in file_data.items():
|
||||||
first_pos, last_pos = get_first_and_last_positions(path_data)
|
first_pos, last_pos = get_first_and_last_positions(path_data)
|
||||||
if not first_pos or not last_pos:
|
if not first_pos or not last_pos:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Skip if not a path type or not a valid target
|
# Skip if not a path type
|
||||||
if first_pos.get("type") != "path" or last_pos.get("type") != "target":
|
if first_pos.get("type") != "path":
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Extract file info
|
# Extract file info
|
||||||
@@ -451,38 +462,44 @@ def generate_ley_line_data():
|
|||||||
if not region or not area or not num:
|
if not region or not area or not num:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Try to find the source in previous route target
|
# Try to find the source in previous route
|
||||||
prev_num = num - 1
|
prev_num = num - 1
|
||||||
key = f"{region}-{area}"
|
key = f"{region}-{area}"
|
||||||
if key in region_area_num_to_target and prev_num in region_area_num_to_target[key]:
|
if key in region_area_num_to_target and prev_num in region_area_num_to_target[key]:
|
||||||
prev_info = region_area_num_to_target[key][prev_num]
|
prev_info = region_area_num_to_target[key][prev_num]
|
||||||
prev_node = prev_info["node"]
|
prev_node = prev_info["node"]
|
||||||
|
|
||||||
# Find the current target node
|
# Find the current destination node
|
||||||
target_x = format_coord(float(last_pos["x"]))
|
dest_x = format_coord(float(last_pos["x"]))
|
||||||
target_y = format_coord(float(last_pos["y"]))
|
dest_y = format_coord(float(last_pos["y"]))
|
||||||
target_node = find_nearby_node(nodes, target_x, target_y, "blossom")
|
|
||||||
|
|
||||||
if prev_node and target_node:
|
# Determine node type, default to blossom for target or if not specified
|
||||||
# Add connection from previous target to current target
|
dest_type = last_pos.get("type", "blossom")
|
||||||
|
if dest_type == "target":
|
||||||
|
dest_type = "blossom"
|
||||||
|
|
||||||
|
dest_node = find_nearby_node(nodes, dest_x, dest_y, dest_type)
|
||||||
|
|
||||||
|
if prev_node and dest_node:
|
||||||
|
# Add connection from previous node to current destination
|
||||||
relative_path = generate_relative_path(file_path, script_dir)
|
relative_path = generate_relative_path(file_path, script_dir)
|
||||||
|
|
||||||
# Add target to previous node's next array if not already there
|
# Add destination to previous node's next array if not already there
|
||||||
route_exists = False
|
route_exists = False
|
||||||
for route in prev_node["next"]:
|
for route in prev_node["next"]:
|
||||||
if route["target"] == target_node["id"]:
|
if route["target"] == dest_node["id"]:
|
||||||
route_exists = True
|
route_exists = True
|
||||||
break
|
break
|
||||||
|
|
||||||
if not route_exists:
|
if not route_exists:
|
||||||
prev_node["next"].append({
|
prev_node["next"].append({
|
||||||
"target": target_node["id"],
|
"target": dest_node["id"],
|
||||||
"route": relative_path
|
"route": relative_path
|
||||||
})
|
})
|
||||||
|
|
||||||
# Add previous node to target's prev array if not already there
|
# Add previous node to destination's prev array if not already there
|
||||||
if prev_node["id"] not in target_node["prev"]:
|
if prev_node["id"] not in dest_node["prev"]:
|
||||||
target_node["prev"].append(prev_node["id"])
|
dest_node["prev"].append(prev_node["id"])
|
||||||
|
|
||||||
# Save to JSON file
|
# Save to JSON file
|
||||||
ley_line_data = {"node": nodes}
|
ley_line_data = {"node": nodes}
|
||||||
@@ -496,4 +513,4 @@ def generate_ley_line_data():
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
generate_ley_line_data()
|
generate_ley_line_data()
|
||||||
File diff suppressed because it is too large
Load Diff
49
repo/js/AutoLeyLineOutcrop/assets/pathing/蒙德2-清泉镇-5-1.json
Normal file
49
repo/js/AutoLeyLineOutcrop/assets/pathing/蒙德2-清泉镇-5-1.json
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
{
|
||||||
|
"info": {
|
||||||
|
"name": "蒙德2-清泉镇-5-2",
|
||||||
|
"type": "collect",
|
||||||
|
"author": "秋云",
|
||||||
|
"version": "1.0",
|
||||||
|
"description": "",
|
||||||
|
"map_name": "Teyvat",
|
||||||
|
"bgi_version": "0.45.0"
|
||||||
|
},
|
||||||
|
"positions": [
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"action": "",
|
||||||
|
"move_mode": "walk",
|
||||||
|
"type": "teleport",
|
||||||
|
"x": -251.6552734375,
|
||||||
|
"y": 2256.552490234375,
|
||||||
|
"action_params": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 2,
|
||||||
|
"x": -259.5361328125,
|
||||||
|
"y": 2253.7451171875,
|
||||||
|
"type": "path",
|
||||||
|
"move_mode": "walk",
|
||||||
|
"action": "",
|
||||||
|
"action_params": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3,
|
||||||
|
"x": -266.4140625,
|
||||||
|
"y": 2202.67431640625,
|
||||||
|
"type": "path",
|
||||||
|
"move_mode": "jump",
|
||||||
|
"action": "",
|
||||||
|
"action_params": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 4,
|
||||||
|
"x": -319.5712890625,
|
||||||
|
"y": 2156.478515625,
|
||||||
|
"type": "path",
|
||||||
|
"move_mode": "dash",
|
||||||
|
"action": "",
|
||||||
|
"action_params": ""
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user