Add hurt, die animation when taking damage

This commit is contained in:
2024-02-07 17:14:17 +01:00
parent d6466b8f55
commit 6c1d0dfdb2
16 changed files with 251 additions and 24 deletions

View File

@@ -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) ")

View File

@@ -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")