DCDecomp
A decompilation of Dark Cloud for the PlayStation 2
Loading...
Searching...
No Matches
dranmapfield.cpp
1#include "dranmapfield.hpp"
2
3#include <cstdio>
4
5#include "boxvu0.hpp"
6#include "collision.hpp"
7#include "dataalloc.hpp"
8#include "dungeonparts.hpp"
9#include "frame.hpp"
10#include "mds.hpp"
11#include "snd.hpp"
12
13void CDranMapField::LoadModel(unsigned int *pack, CDataAlloc2<1> *arena) {
15
16 if (set->field_count < 12) {
17 (&this[set->field_count].character)->Initialize();
18 (&this[set->field_count].character)->LoadPackData(pack, info_cfg_literal, arena, arena);
19 (&this[set->field_count].character)->SetPosition(0.0f, 0.0f, 0.0f);
20 (&this[set->field_count].character)->SetRotation(0.0f, 0.0f, 0.0f);
21 set->field_count++;
22 } else {
23 printf(" ************* over!!\n");
24 }
25}
26
27int CDranMapField::AddCollision(CCPoly *poly, int count, CBoxVu0 box) {
28 int i;
30
31 if (set->collision_count == 0) {
32 return count;
33 }
34
35 for (i = 0; i < set->collision_count; i++) {
36 if (set->collision[i] != NULL && ((DRAN_MAP_FIELD_SET *) this)->state[i] > 1) {
37 count += set->collision[i]->PickUpNearPoly(&poly[count], box);
38 }
39 }
40
41 return count;
42}
43
44void CDranMapField::LoadCollision(unsigned int *pack, CDataAlloc2<1> *arena) {
46
47 if (set->collision_count < 12) {
48 set->collision[set->collision_count] = (CFrame *) LoadCollisionFile(pack, arena);
49 float coord = 0.0f;
50 set->collision[set->collision_count]->SetPosition(coord, coord, coord);
51 float angle = 0.0f;
52 set->collision[set->collision_count]->SetRotation(angle, angle, angle);
53 set->collision_count++;
54 } else {
55 printf(OverMessage);
56 }
57}
58
67 int i;
69
70 if (set->field_count != 0) {
71 for (i = 0; i < set->field_count; i++) {
72 if (set->field[i].character.frame != NULL && set->state[i] != 0) {
73 set->field[i].character.Draw();
74 }
75 }
76 }
77}
78
80 int i;
82
83 if (set->field_count != 0) {
84 for (i = 0; i < set->field_count; i++) {
85 if (this[i].character.frame == NULL) {
86 continue;
87 }
88
89 if (set->state[i] <= 0) {
90 continue;
91 }
92
93 // Two starts the model moving, and the motion runs while it stands at one.
94 if (set->state[i] == 2) {
95 SndSePlay(SE_DRAN_FIELD_START, -1, 0);
96 set->state[i]--;
97 }
98
99 if (set->state[i] == 1) {
100 this[i].character.Step();
101
102 if (!(this[i].character.GetNowTime() < 59.0f)) {
103 set->state[i]--;
104 }
105 }
106 }
107 }
108}
CFrame * frame
float GetNowTime()
virtual void Draw()
void SetRotation(float x, float y, float z)
void SetPosition(float x, float y, float z)
int AddCollision(CCPoly *poly, int count, CBoxVu0 box)
void LoadCollision(unsigned int *pack, CDataAlloc2< 1 > *arena)
void LoadPackData(unsigned int *pack, char *name, CDataAlloc2< 1 > *model_alloc, CDataAlloc2< 1 > *texture_alloc)
void LoadModel(unsigned int *pack, CDataAlloc2< 1 > *arena)
CCharacter character
CDranMapField field[12]
CFrame * collision[12]