mirror of
https://github.com/isledecomp/isle.git
synced 2025-10-25 09:24:17 +00:00
Implement/match Act3Ammo::Animate (#1221)
* Implement/match `Act3Ammo::Animate` * Match * Rename * Rename * Rename
This commit is contained in:
committed by
GitHub
parent
6da2faa48c
commit
1aeb458be1
@@ -1,5 +1,7 @@
|
||||
#include "act3ammo.h"
|
||||
|
||||
#include "act3.h"
|
||||
#include "act3actors.h"
|
||||
#include "legocachesoundmanager.h"
|
||||
#include "legocharactermanager.h"
|
||||
#include "legopathboundary.h"
|
||||
@@ -13,12 +15,16 @@
|
||||
|
||||
DECOMP_SIZE_ASSERT(Act3Ammo, 0x1a0)
|
||||
|
||||
// Initialized at LEGO1 0x100537c0
|
||||
// GLOBAL: LEGO1 0x10104f08
|
||||
Mx3DPointFloat Act3Ammo::g_unk0x10104f08 = Mx3DPointFloat(0.0, 5.0, 0.0);
|
||||
|
||||
// FUNCTION: LEGO1 0x100537f0
|
||||
// FUNCTION: BETA10 0x1001d648
|
||||
Act3Ammo::Act3Ammo()
|
||||
{
|
||||
m_ammoFlag = 0;
|
||||
m_a3 = NULL;
|
||||
m_world = NULL;
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100538a0
|
||||
@@ -62,7 +68,7 @@ MxResult Act3Ammo::Remove()
|
||||
|
||||
// FUNCTION: LEGO1 0x10053980
|
||||
// FUNCTION: BETA10 0x1001d8b3
|
||||
MxResult Act3Ammo::Create(Act3* p_a3, MxU32 p_isPizza, MxS32 p_index)
|
||||
MxResult Act3Ammo::Create(Act3* p_world, MxU32 p_isPizza, MxS32 p_index)
|
||||
{
|
||||
assert(m_ammoFlag);
|
||||
char name[12];
|
||||
@@ -96,7 +102,7 @@ MxResult Act3Ammo::Create(Act3* p_a3, MxU32 p_isPizza, MxS32 p_index)
|
||||
assert(m_roi);
|
||||
}
|
||||
|
||||
m_a3 = p_a3;
|
||||
m_world = p_world;
|
||||
SetValid(TRUE);
|
||||
return SUCCESS;
|
||||
}
|
||||
@@ -190,9 +196,245 @@ MxResult Act3Ammo::FUN_10053d30(LegoPathController* p_p, MxFloat p_unk0x19c)
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
// STUB: LEGO1 0x10054050
|
||||
// STUB: BETA10 0x1001e362
|
||||
void Act3Ammo::Animate(float p_time)
|
||||
// STUB: LEGO1 0x10053db0
|
||||
// STUB: BETA10 0x1001e0f0
|
||||
MxResult Act3Ammo::FUN_10053db0(float p_param1, const Matrix4& p_param2)
|
||||
{
|
||||
// TODO
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x10054050
|
||||
// FUNCTION: BETA10 0x1001e362
|
||||
void Act3Ammo::Animate(float p_time)
|
||||
{
|
||||
assert(IsValid());
|
||||
|
||||
switch (m_actorState & c_maxState) {
|
||||
case c_initial:
|
||||
case c_one:
|
||||
break;
|
||||
case c_two:
|
||||
m_unk0x158 = p_time + 2000.0f;
|
||||
m_actorState = c_three;
|
||||
return;
|
||||
case c_three:
|
||||
MxMatrix transform;
|
||||
Vector3 positionRef(transform[3]);
|
||||
|
||||
transform = m_roi->GetLocal2World();
|
||||
|
||||
if (m_unk0x158 > p_time) {
|
||||
Mx3DPointFloat position;
|
||||
|
||||
position = positionRef;
|
||||
positionRef.Clear();
|
||||
transform.RotateX(0.6);
|
||||
positionRef = position;
|
||||
m_roi->FUN_100a58f0(transform);
|
||||
m_roi->VTable0x14();
|
||||
return;
|
||||
}
|
||||
else {
|
||||
m_actorState = c_initial;
|
||||
m_unk0x158 = 0;
|
||||
|
||||
positionRef -= g_unk0x10104f08;
|
||||
m_roi->FUN_100a58f0(transform);
|
||||
m_roi->VTable0x14();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_worldSpeed <= 0.0f) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_lastTime < 0.0f) {
|
||||
m_lastTime = p_time;
|
||||
m_unk0x7c = 0.0f;
|
||||
}
|
||||
|
||||
MxMatrix local104;
|
||||
MxMatrix local60;
|
||||
|
||||
float f = (m_BADuration - m_unk0x7c) / m_worldSpeed + m_lastTime;
|
||||
|
||||
undefined4 localb4 = 0;
|
||||
undefined4 localbc = 0;
|
||||
MxU32 local14 = FALSE;
|
||||
MxU32 localb8 = FALSE;
|
||||
|
||||
if (f >= p_time) {
|
||||
m_actorTime = (p_time - m_lastTime) * m_worldSpeed + m_actorTime;
|
||||
m_unk0x7c = (p_time - m_lastTime) * m_worldSpeed + m_unk0x7c;
|
||||
m_lastTime = p_time;
|
||||
}
|
||||
else {
|
||||
localb8 = TRUE;
|
||||
m_unk0x7c = m_BADuration;
|
||||
m_lastTime = p_time;
|
||||
}
|
||||
|
||||
local104.SetIdentity();
|
||||
|
||||
MxResult r = FUN_10053db0((m_unk0x7c / m_BADuration) * m_unk0x19c, local104);
|
||||
assert(r == 0); // SUCCESS
|
||||
|
||||
local60.SetIdentity();
|
||||
|
||||
if (IsPizza()) {
|
||||
local60.Scale(2.0f, 2.0f, 2.0f);
|
||||
}
|
||||
else {
|
||||
local60.Scale(5.0f, 5.0f, 5.0f);
|
||||
}
|
||||
|
||||
if (localb8) {
|
||||
if (m_boundary != NULL) {
|
||||
Vector3 local17c(local104[0]);
|
||||
Vector3 local184(local104[1]);
|
||||
Vector3 local174(local104[2]);
|
||||
|
||||
if (IsPizza()) {
|
||||
local184 = *m_boundary->GetUnknown0x14();
|
||||
local17c[0] = 1.0f;
|
||||
local17c[1] = local17c[2] = 0.0f;
|
||||
local174.EqualsCross(&local17c, &local184);
|
||||
local174.Unitize();
|
||||
local17c.EqualsCross(&local184, &local174);
|
||||
}
|
||||
else {
|
||||
local17c = *m_boundary->GetUnknown0x14();
|
||||
local184[0] = 1.0f;
|
||||
local184[1] = local184[2] = 0.0f;
|
||||
local174.EqualsCross(&local17c, &local184);
|
||||
local174.Unitize();
|
||||
local184.EqualsCross(&local174, &local17c);
|
||||
}
|
||||
}
|
||||
|
||||
m_actorState = c_initial;
|
||||
}
|
||||
else {
|
||||
local60.RotateX(m_actorTime / 10.0f);
|
||||
local60.RotateY(m_actorTime / 6.0f);
|
||||
}
|
||||
|
||||
MxMatrix localb0(local104);
|
||||
local104.Product(local60, localb0);
|
||||
m_roi->FUN_100a58f0(local104);
|
||||
m_roi->VTable0x14();
|
||||
|
||||
if (m_BADuration <= m_unk0x7c) {
|
||||
m_worldSpeed = 0.0f;
|
||||
}
|
||||
|
||||
Vector3 local68(local104[3]);
|
||||
|
||||
if (localb8) {
|
||||
if (IsBit4()) {
|
||||
if (IsPizza()) {
|
||||
m_world->RemovePizza(*this);
|
||||
m_world->FUN_10072ad0(2);
|
||||
}
|
||||
else {
|
||||
m_world->RemoveDonut(*this);
|
||||
m_world->FUN_10072ad0(4);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (IsPizza()) {
|
||||
assert(SoundManager()->GetCacheSoundManager());
|
||||
SoundManager()->GetCacheSoundManager()->Play("stickpz", NULL, FALSE);
|
||||
}
|
||||
else {
|
||||
assert(SoundManager()->GetCacheSoundManager());
|
||||
SoundManager()->GetCacheSoundManager()->Play("stickdn", NULL, FALSE);
|
||||
}
|
||||
|
||||
LegoPathActorSet& plpas = m_boundary->GetActors();
|
||||
LegoPathActorSet lpas(plpas);
|
||||
|
||||
for (LegoPathActorSet::iterator itpa = lpas.begin(); itpa != lpas.end(); itpa++) {
|
||||
if (plpas.find(*itpa) != plpas.end() && this != *itpa) {
|
||||
LegoROI* r = (*itpa)->GetROI();
|
||||
assert(r);
|
||||
|
||||
if (!strncmp(r->GetName(), "pammo", 5)) {
|
||||
Mx3DPointFloat local1c8;
|
||||
Mx3DPointFloat local1b4;
|
||||
|
||||
local1c8 = r->GetLocal2World()[3];
|
||||
local1b4 = m_roi->GetLocal2World()[3];
|
||||
|
||||
local1b4 -= local1c8;
|
||||
|
||||
float radius = r->GetWorldBoundingSphere().Radius();
|
||||
if (local1b4.LenSquared() <= radius * radius) {
|
||||
MxS32 index = -1;
|
||||
if (sscanf(r->GetName(), "pammo%d", &index) != 1) {
|
||||
assert(0);
|
||||
}
|
||||
|
||||
assert(m_world);
|
||||
|
||||
if (m_world->m_pizzas[index].IsValid() && !m_world->m_pizzas[index].IsBit5()) {
|
||||
m_world->EatPizza(index);
|
||||
m_world->m_brickster->FUN_100417c0();
|
||||
}
|
||||
|
||||
if (IsDonut()) {
|
||||
assert(SoundManager()->GetCacheSoundManager());
|
||||
SoundManager()->GetCacheSoundManager()->Play("dnhitpz", NULL, FALSE);
|
||||
m_world->RemoveDonut(*this);
|
||||
local14 = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (!strncmp(r->GetName(), "dammo", 5)) {
|
||||
Mx3DPointFloat local1f8;
|
||||
Mx3DPointFloat local1e4;
|
||||
|
||||
local1f8 = r->GetLocal2World()[3];
|
||||
local1e4 = m_roi->GetLocal2World()[3];
|
||||
|
||||
local1e4 -= local1f8;
|
||||
|
||||
float radius = r->GetWorldBoundingSphere().Radius();
|
||||
if (local1e4.LenSquared() <= radius * radius) {
|
||||
MxS32 index = -1;
|
||||
if (sscanf(r->GetName(), "dammo%d", &index) != 1) {
|
||||
assert(0);
|
||||
}
|
||||
|
||||
assert(m_world);
|
||||
|
||||
m_world->EatDonut(index);
|
||||
|
||||
if (IsPizza()) {
|
||||
assert(SoundManager()->GetCacheSoundManager());
|
||||
SoundManager()->GetCacheSoundManager()->Play("pzhitdn", NULL, FALSE);
|
||||
m_world->RemovePizza(*this);
|
||||
local14 = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!local14) {
|
||||
if (IsPizza()) {
|
||||
m_world->FUN_10073360(*this, local68);
|
||||
}
|
||||
else {
|
||||
m_world->FUN_10073390(*this, local68);
|
||||
}
|
||||
|
||||
m_worldSpeed = -1.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user