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 3 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
24 changes: 18 additions & 6 deletions fast64_internal/oot/actor/properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from bpy.props import EnumProperty, StringProperty, IntProperty, BoolProperty, CollectionProperty, PointerProperty
from ...utility import prop_split, label_split
from ..oot_constants import ootData, ootEnumSceneSetupPreset, ootEnumCamTransition
from ..oot_upgrade import upgradeActors
from ..scene.properties import OOTAlternateSceneHeaderProperty
from ..room.properties import OOTAlternateRoomHeaderProperty
from .operators import OOT_SearchActorIDEnumOperator
Expand Down Expand Up @@ -110,6 +111,11 @@ class OOTActorProperty(PropertyGroup):
rotOverrideZ: StringProperty(name="Rot Z", default="0")
headerSettings: PointerProperty(type=OOTActorHeaderProperty)

@staticmethod
def upgrade_object(obj: Object):
print(f"Processing '{obj.name}'...")
upgradeActors(obj)

def draw_props(self, layout: UILayout, altRoomProp: OOTAlternateRoomHeaderProperty, objName: str):
# prop_split(layout, actorProp, 'actorID', 'Actor')
actorIDBox = layout.column()
Expand Down Expand Up @@ -188,23 +194,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 @@ -820,6 +820,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 @@ -816,8 +816,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
11 changes: 11 additions & 0 deletions fast64_internal/oot/oot_upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,17 @@ def upgradeRoomHeaders(roomObj: Object, objData: OoT_ObjectData):
upgradeObjectList(altHeaders.cutsceneHeaders[i].objectList, objData)


def upgradeActors(actorObj: Object):
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


def upgradeCutsceneMotion(csMotionObj: Object):
"""Main upgrade logic for Cutscene Motion data from zcamedit"""
objName = csMotionObj.name
Expand Down
2 changes: 2 additions & 0 deletions fast64_internal/oot/props_panel_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@ def upgrade_changed_props():
if obj.type == "EMPTY":
if obj.ootEmptyType == "Room":
OOTObjectProperty.upgrade_object(obj)
if obj.ootEmptyType == "Entrance":
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 @@ -95,6 +95,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