Skip to content

Commit

Permalink
added sorting to object exports in sm64 (#336)
Browse files Browse the repository at this point in the history
Co-authored-by: scut <scut>
  • Loading branch information
jesusyoshi54 authored May 31, 2024
1 parent 38cda97 commit a062be6
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions fast64_internal/sm64/sm64_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,13 +262,14 @@ def __init__(


class SM64_Object:
def __init__(self, model, position, rotation, behaviour, bparam, acts):
def __init__(self, model, position, rotation, behaviour, bparam, acts, name):
self.model = model
self.behaviour = behaviour
self.bparam = bparam
self.acts = acts
self.position = position
self.rotation = rotation
self.name = name # to sort by when exporting

def to_c(self):
if self.acts == 0x1F:
Expand Down Expand Up @@ -325,6 +326,7 @@ def __init__(self, index, condition, strength, position):
self.condition = condition
self.strength = strength
self.position = position
self.name = "whirlpool" # for sorting

def to_c(self):
return (
Expand Down Expand Up @@ -453,6 +455,7 @@ def __init__(self, area, position, rotation):
self.area = area
self.position = position
self.rotation = rotation
self.name = "Mario" # for sorting

def to_c(self):
return (
Expand Down Expand Up @@ -500,7 +503,8 @@ def to_c_script(self, includeRooms, persistentBlockString: str = ""):
data += "\tAREA(" + str(self.index) + ", " + self.geolayout.name + "),\n"
for warpNode in self.warpNodes:
data += "\t\t" + warpNode + ",\n"
for obj in self.objects:
# export objects in name order
for obj in sorted(self.objects, key=(lambda obj: obj.name)):
data += "\t\t" + obj.to_c() + ",\n"
data += "\t\tTERRAIN(" + self.collision.name + "),\n"
if includeRooms:
Expand Down Expand Up @@ -840,6 +844,7 @@ def process_sm64_objects(obj, area, rootMatrix, transformMatrix, specialsOnly):
behaviour,
obj.fast64.sm64.game_object.get_behavior_params(),
get_act_string(obj),
obj.name,
)
)
elif obj.sm64_obj_type == "Macro":
Expand Down

0 comments on commit a062be6

Please sign in to comment.