Repository for mbEditorPro 2.0
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

90 lines
4.6 KiB

# • ▌ ▄ ·. ▄▄▄▄· ▄▄▄ .·▄▄▄▄ ▪ ▄▄▄▄▄ ▄▄▄ ▄▄▄·▄▄▄
# ·██ ▐███▪▐█ ▀█▪ ▀▄.▀·██▪ ██ ██ •██ ▪ ▀▄ █· ▐█ ▄█▀▄ █·▪
# ▐█ ▌▐▌▐█·▐█▀▀█▄ ▐▀▀▪▄▐█· ▐█▌▐█· ▐█.▪ ▄█▀▄ ▐▀▀▄ ██▀·▐▀▀▄ ▄█▀▄
# ██ ██▌▐█▌██▄▪▐█ ▐█▄▄▌██. ██ ▐█▌ ▐█▌·▐█▌.▐▌▐█•█▌ ▐█▪·•▐█•█▌▐█▌.▐▌
# ▀▀ █▪▀▀▀·▀▀▀▀ ▀▀▀ ▀▀▀▀▀• ▀▀▀ ▀▀▀ ▀█▄▀▪.▀ ▀ .▀ .▀ ▀ ▀█▄▀▪
# Magicbane Emulator Project © 2013 - 2022
# www.magicbane.com
from collections import OrderedDict
from arcane.util import ResStream
class ArcMotion:
def load_binary(self, stream: ResStream):
self.motion_file = stream.read_string()
self.motion_smoothed_count = stream.read_dword()
self.motion_smoothed_value = stream.read_dword()
self.motion_smoothed_factor = stream.read_float()
self.motion_sound = stream.read_qword()
self.motion_sheath = stream.read_dword()
self.motion_reset_loc = stream.read_bool()
self.motion_leave_ground = stream.read_bool()
self.motion_force = stream.read_float()
self.motion_disable_blend = stream.read_bool()
num_parts = stream.read_dword()
self.motion_parts = [stream.read_string() for _ in range(num_parts)]
num_smoothing = stream.read_dword()
self.motion_smoothing = [
[
stream.read_float() for _ in range(10)
] for _ in range(num_smoothing)
]
num_target_frames = stream.read_dword()
self.motion_target_frames = [stream.read_dword() for _ in range(num_target_frames)]
def save_binary(self, stream: ResStream):
stream.write_string(self.motion_file)
stream.write_dword(self.motion_smoothed_count)
stream.write_dword(self.motion_smoothed_value)
stream.write_float(self.motion_smoothed_factor)
stream.write_qword(self.motion_sound)
stream.write_dword(self.motion_sheath)
stream.write_bool(self.motion_reset_loc)
stream.write_bool(self.motion_leave_ground)
stream.write_float(self.motion_force)
stream.write_bool(self.motion_disable_blend)
stream.write_dword(len(self.motion_parts))
for i in range(len(self.motion_parts)):
stream.write_string(self.motion_parts[i])
stream.write_dword(len(self.motion_smoothing))
for i in range(len(self.motion_smoothing)):
for j in range(10):
stream.write_float(self.motion_smoothing[i][j])
stream.write_dword(len(self.motion_target_frames))
for i in range(len(self.motion_target_frames)):
stream.write_dword(self.motion_target_frames[i])
def load_json(self, data):
self.motion_file = data['motion_file']
self.motion_smoothed_count = data['motion_smoothed_count']
self.motion_smoothed_value = data['motion_smoothed_value']
self.motion_smoothed_factor = data['motion_smoothed_factor']
self.motion_sound = data['motion_sound']
self.motion_sheath = data['motion_sheath']
self.motion_reset_loc = data['motion_reset_loc']
self.motion_leave_ground = data['motion_leave_ground']
self.motion_force = data['motion_force']
self.motion_disable_blend = data['motion_disable_blend']
self.motion_parts = data['motion_parts']
self.motion_smoothing = data['motion_smoothing']
self.motion_target_frames = data['motion_target_frames']
def save_json(self):
data = OrderedDict()
data['motion_file'] = self.motion_file
data['motion_smoothed_count'] = self.motion_smoothed_count
data['motion_smoothed_value'] = self.motion_smoothed_value
data['motion_smoothed_factor'] = self.motion_smoothed_factor
data['motion_sound'] = self.motion_sound
data['motion_sheath'] = self.motion_sheath
data['motion_reset_loc'] = self.motion_reset_loc
data['motion_leave_ground'] = self.motion_leave_ground
data['motion_force'] = self.motion_force
data['motion_disable_blend'] = self.motion_disable_blend
data['motion_parts'] = self.motion_parts
data['motion_smoothing'] = self.motion_smoothing
data['motion_target_frames'] = self.motion_target_frames
return data