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] Use Room objects to set which room to use for entrances #255

Merged
merged 6 commits into from
Dec 26, 2023
Merged
Show file tree
Hide file tree
Changes from 4 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
18 changes: 12 additions & 6 deletions fast64_internal/oot/actor/properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,23 +206,29 @@ def draw_props(


class OOTEntranceProperty(PropertyGroup):
# This is also used in entrance list, and roomIndex is obtained from the room this empty is parented to.
# This is also used in entrance list.
spawnIndex: IntProperty(min=0)
customActor: BoolProperty(name="Use Custom Actor")
actor: PointerProperty(type=OOTActorProperty)

tiedRoom: PointerProperty(
type=Object,
poll=lambda self, object: self.isRoomEmptyObject(object),
description="Used to set the room index",
)

def isRoomEmptyObject(self, obj: Object):
return obj.type == "EMPTY" and obj.ootEmptyType == "Room"

def draw_props(self, layout: UILayout, obj: Object, altSceneProp: OOTAlternateSceneHeaderProperty, objName: str):
box = layout.column()
# box.box().label(text = "Properties")
roomObj = getRoomObj(obj)
if roomObj is not None:
split = box.split(factor=0.5)
split.label(text="Room Index")
split.label(text=str(roomObj.ootRoomHeader.roomIndex))
else:
if roomObj is None:
box.label(text="This must be part of a Room empty's hierarchy.", icon="OUTLINER")

entranceProp = obj.ootEntranceProperty
prop_split(box, entranceProp, "tiedRoom", "Room")
prop_split(box, entranceProp, "spawnIndex", "Spawn Index")
prop_split(box, entranceProp.actor, "actorParam", "Actor Param")
box.prop(entranceProp, "customActor")
Expand Down
1 change: 1 addition & 0 deletions fast64_internal/oot/oot_level_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,7 @@ def parseSpawnList(
spawnObj.ootEmptyType = "Entrance"
spawnObj.name = "Entrance"
spawnProp = spawnObj.ootEntranceProperty
spawnProp.tiedRoom = roomObjs[roomIndex]
spawnProp.spawnIndex = spawnIndex
spawnProp.customActor = actorID != "ACTOR_PLAYER"
actorProp = spawnProp.actor
Expand Down
10 changes: 8 additions & 2 deletions fast64_internal/oot/oot_level_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -819,8 +819,14 @@ def ootProcessEmpties(scene, room, sceneObj, obj, transformMatrix):
)
elif obj.ootEmptyType == "Entrance":
entranceProp = obj.ootEntranceProperty
spawnIndex = obj.ootEntranceProperty.spawnIndex
addActor(scene, OOTEntrance(room.roomIndex, spawnIndex), entranceProp.actor, "entranceList", obj.name)
spawnIndex = entranceProp.spawnIndex

if entranceProp.tiedRoom is not None:
roomIndex = entranceProp.tiedRoom.ootRoomHeader.roomIndex
else:
raise PluginError("ERROR: The room isn't set!")
Yanis42 marked this conversation as resolved.
Show resolved Hide resolved

addActor(scene, OOTEntrance(roomIndex, spawnIndex), entranceProp.actor, "entranceList", obj.name)
addStartPosition(
scene,
spawnIndex,
Expand Down
10 changes: 9 additions & 1 deletion fast64_internal/oot/oot_upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,15 @@ def upgradeRoomHeaders(roomObj: Object, objData: OoT_ObjectData):


def upgradeActors(actorObj: Object):
if actorObj.ootEmptyType == "Transition Actor":
if actorObj.ootEmptyType == "Entrance":
entranceProp = actorObj.ootEntranceProperty

for obj in bpy.data.objects:
if obj.type == "EMPTY" and obj.ootEmptyType == "Room":
if actorObj in obj.children_recursive:
entranceProp.tiedRoom = obj
break
elif actorObj.ootEmptyType == "Transition Actor":
transActorProp = actorObj.ootTransitionActorProperty
transActorProp.isRoomTransition = actorObj["ootTransitionActorProperty"]["dontTransition"] == False
del actorObj["ootTransitionActorProperty"]["dontTransition"]
Expand Down
2 changes: 1 addition & 1 deletion fast64_internal/oot/props_panel_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ def upgrade_changed_props():
if obj.type == "EMPTY":
if obj.ootEmptyType == "Room":
OOTObjectProperty.upgrade_object(obj)
if obj.ootEmptyType == "Transition Actor":
if obj.ootEmptyType in {"Entrance", "Transition Actor"}:
OOTActorProperty.upgrade_object(obj)
if any(obj.name.startswith(elem) for elem in ["ActionList.", "Point.", "Preview."]):
OOTCutsceneMotionProperty.upgrade_object(obj)
Expand Down
1 change: 1 addition & 0 deletions fast64_internal/oot/tools/operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ def execute(self, context):
roomObj = context.view_layer.objects.active
roomObj.ootEmptyType = "Room"
roomObj.name = "Room"
entranceObj.ootEntranceProperty.tiedRoom = roomObj
parentObject(roomObj, planeObj)

location += Vector([0, 0, 2])
Expand Down