Skip to content

Commit

Permalink
[OoT] Fixed door upgrade (#287)
Browse files Browse the repository at this point in the history
* fix door upgrade issues

* fixed index issues

* minor code improvements

* check if any old props is present

* review

* proper fix
  • Loading branch information
Yanis002 authored Jan 27, 2024
1 parent 42eddfd commit 6c840f4
Showing 1 changed file with 32 additions and 11 deletions.
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

0 comments on commit 6c840f4

Please sign in to comment.