Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[OoT] Fixed door upgrade #287

Merged
merged 6 commits into from
Jan 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 32 additions & 11 deletions fast64_internal/oot/oot_upgrade.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import bpy

from dataclasses import dataclass
from typing import TYPE_CHECKING
from bpy.types import Object, CollectionProperty
Expand Down Expand Up @@ -312,17 +314,36 @@ def upgradeActors(actorObj: Object):
entranceProp.tiedRoom = obj
break
elif actorObj.ootEmptyType == "Transition Actor":
# get room parent
roomParent = None
for obj in bpy.data.objects:
if obj.type == "EMPTY" and obj.ootEmptyType == "Room" and actorObj in obj.children_recursive:
roomParent = obj
break

# if it's ``None`` then this door actor is not parented to a room
if roomParent is None:
print("WARNING: Ignoring Door Actor not parented to a room")
return

transActorProp = actorObj.ootTransitionActorProperty
transActorProp.isRoomTransition = actorObj["ootTransitionActorProperty"]["dontTransition"] == False
del actorObj["ootTransitionActorProperty"]["dontTransition"]
if "dontTransition" in transActorProp or "roomIndex" in transActorProp:
# look for old data since we don't want to overwrite newer existing data
transActorProp.fromRoom = roomParent

# upgrade old props if present
if "dontTransition" in transActorProp:
transActorProp.isRoomTransition = transActorProp["dontTransition"] == False
del transActorProp["dontTransition"]

if transActorProp.isRoomTransition:
if "roomIndex" in transActorProp:
for obj in bpy.data.objects:
if obj.type == "EMPTY":
if obj.ootEmptyType == "Room":
if actorObj in obj.children_recursive:
transActorProp.fromRoom = obj

if obj.ootRoomHeader.roomIndex == actorObj["ootTransitionActorProperty"]["roomIndex"]:
transActorProp.toRoom = obj
del actorObj["ootTransitionActorProperty"]["roomIndex"]
if (
obj != transActorProp.fromRoom
and obj.type == "EMPTY"
and obj.ootEmptyType == "Room"
and obj.ootRoomHeader.roomIndex == transActorProp["roomIndex"]
):
transActorProp.toRoom = obj
del transActorProp["roomIndex"]
break
Loading