Add hurt, die animation when taking damage
This commit is contained in:
@@ -381,6 +381,34 @@ class EnumWriter:
|
||||
writer.block_end()
|
||||
writer.empty_line()
|
||||
|
||||
|
||||
def output_anim_length(self, func_name):
|
||||
writer = self.writer
|
||||
writer.output(f"static f32 {func_name}({self.enum_type} entity, {self.anim_type} type) ")
|
||||
writer.block_start()
|
||||
|
||||
writer.output("switch (entity) ")
|
||||
writer.block_start()
|
||||
for entity, animation_types in self.anim_map.items():
|
||||
writer.output(f"case {entity}:\n")
|
||||
writer.indent()
|
||||
writer.output("switch (type) ")
|
||||
writer.block_start()
|
||||
for anim_type in animation_types:
|
||||
anim = self.anim_map[entity][anim_type]
|
||||
duration = sum([x['duration'] * 0.001 for x in anim])
|
||||
writer.output(f"case {anim_type}: return {duration}f;\n")
|
||||
writer.output("default: break;\n")
|
||||
writer.block_end()
|
||||
writer.unindent()
|
||||
writer.output("default: break;\n")
|
||||
writer.block_end()
|
||||
|
||||
writer.output("BZ_ASSERT(0);\n")
|
||||
writer.output("return 0.0f;\n")
|
||||
writer.block_end()
|
||||
writer.empty_line()
|
||||
|
||||
def output_anim_sequence(self, func_name):
|
||||
writer = self.writer
|
||||
writer.output(f"static AnimationSequence {func_name}({self.enum_type} entity, {self.anim_type} type) ")
|
||||
|
||||
@@ -90,6 +90,7 @@ anim_writer.output_enum_to_tile("getEntityTile")
|
||||
anim_writer.output_enum_to_str("getEntityStr")
|
||||
anim_writer.output_anim_enum_to_str("getEntityAnimationStr")
|
||||
anim_writer.output_has_anim("entityHasAnimation")
|
||||
anim_writer.output_anim_length("entityGetAnimationLength")
|
||||
anim_writer.output_anim_sequence("entityGetAnimationSequence")
|
||||
anim_writer.output_anim_frame("entityGetAnimationFrame")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user