Synchronized DDD's poles

This commit is contained in:
MysterD 2020-10-02 23:34:33 -07:00
parent ef8eaa8c87
commit 60580602a6
1 changed files with 19 additions and 0 deletions

View File

@ -1,10 +1,26 @@
void bhv_ddd_pole_override_ownership(u8* shouldOverride, u8* shouldOwn) {
*shouldOverride = TRUE;
*shouldOwn = (gNetworkType == NT_SERVER);
}
void bhv_ddd_pole_init(void) {
if (!(save_file_get_flags() & (SAVE_FLAG_HAVE_KEY_2 | SAVE_FLAG_UNLOCKED_UPSTAIRS_DOOR))) {
obj_mark_for_deletion(o);
} else {
o->hitboxDownOffset = 100.0f;
o->oDDDPoleMaxOffset = 100.0f * o->oBehParams2ndByte;
struct SyncObject* so = network_init_object(o, SYNC_DISTANCE_ONLY_EVENTS);
so->override_ownership = bhv_ddd_pole_override_ownership;
network_init_object_field(o, &o->oPosX);
network_init_object_field(o, &o->oPosY);
network_init_object_field(o, &o->oPosZ);
network_init_object_field(o, &o->oDDDPoleVel);
network_init_object_field(o, &o->oDDDPoleOffset);
network_init_object_field(o, &o->oAction);
network_init_object_field(o, &o->oPrevAction);
network_init_object_field(o, &o->oTimer);
}
}
@ -15,6 +31,9 @@ void bhv_ddd_pole_update(void) {
if (clamp_f32(&o->oDDDPoleOffset, 0.0f, o->oDDDPoleMaxOffset)) {
o->oDDDPoleVel = -o->oDDDPoleVel;
o->oTimer = 0;
if (network_owns_object(o)) {
network_send_object(o);
}
}
}