Isle
Loading...
Searching...
No Matches
doors.cpp
Go to the documentation of this file.
1#include "doors.h"
2
3#include "legopathboundary.h"
4#include "mxmisc.h"
5#include "mxtimer.h"
6#include "roi/legoroi.h"
7#include "tgl/tglvector.h"
8
9#include <assert.h>
10
12
13// GLOBAL: LEGO1 0x100d8e7c
14// GLOBAL: BETA10 0x101b954c
16
17// GLOBAL: LEGO1 0x100d8e80
18// GLOBAL: BETA10 0x101b9550
20
21// GLOBAL: LEGO1 0x100d8e84
22// GLOBAL: BETA10 0x101b9554
24
25// FUNCTION: LEGO1 0x10066100
26// FUNCTION: BETA10 0x10026850
27MxResult Doors::HitActor(LegoPathActor* p_actor, MxBool p_bool)
28{
29 assert(m_ltDoor && m_rtDoor);
30
31 if (m_unk0x154 == 1) {
32 m_unk0x154 = 2;
33 m_unk0x158 = Timer()->GetTime();
34 m_ltDoorLocal = m_ltDoor->GetLocal2World();
35 m_rtDoorLocal = m_rtDoor->GetLocal2World();
36 }
37
38 return m_unk0x1f4 < 0.001 ? SUCCESS : FAILURE;
39}
40
41// FUNCTION: LEGO1 0x10066190
42// FUNCTION: BETA10 0x1002696b
44{
45 MxFloat fVar1;
46
47 fVar1 = p_time - m_unk0x158;
48
49 if (fVar1 <= 0.0f) {
50 return 0.0f;
51 }
52
53 if (fVar1 <= g_unk0x100d8e7c) {
54 return fVar1 * 1.570796 / g_unk0x100d8e7c;
55 }
56 else if (fVar1 <= g_unk0x100d8e7c + g_unk0x100d8e80) {
57 return 1.570796012878418; // Pi / 2
58 }
59 else if (fVar1 <= g_unk0x100d8e84) {
60 return (1.0 - ((fVar1 - g_unk0x100d8e80) - g_unk0x100d8e7c) / g_unk0x100d8e7c) * 1.570796;
61 }
62
63 return 0.0f;
64}
65
66// FUNCTION: LEGO1 0x10066250
67// FUNCTION: BETA10 0x10026a45
68void Doors::Animate(float p_time)
69{
70 assert(m_ltDoor && m_rtDoor);
71
72 // TODO: Match
74
75 switch (m_unk0x154) {
76 case 0:
77 m_unk0x154 = 1;
79 break;
80 case 1:
81 break;
82 case 2:
83 float local8 = VTable0xcc(p_time);
84
85 if (local8 > 0.0f) {
86 MxMatrix local58(m_ltDoorLocal);
87 Vector3 local10(local58[3]);
88
89 local10.Clear();
90 local58.RotateY(-local8);
91 local10 = m_ltDoorLocal[3];
92 m_ltDoor->FUN_100a58f0(local58);
93 m_ltDoor->VTable0x14();
94
95 local58 = m_rtDoorLocal;
96 local10.Clear();
97 local58.RotateY(local8);
98 local10 = m_rtDoorLocal[3];
99 m_rtDoor->FUN_100a58f0(local58);
100 m_rtDoor->VTable0x14();
101
102 m_unk0x1f4 = local8;
103 }
104
105 if (m_unk0x158 + g_unk0x100d8e84 < p_time) {
106 m_ltDoor->FUN_100a58f0(m_ltDoorLocal);
107 m_rtDoor->FUN_100a58f0(m_rtDoorLocal);
108 m_ltDoor->VTable0x14();
109 m_rtDoor->VTable0x14();
110 m_unk0x154 = 1;
112 m_unk0x1f4 = 0;
113 }
114 }
115}
116
117// FUNCTION: LEGO1 0x100664e0
118// FUNCTION: BETA10 0x10026ceb
119void Doors::ParseAction(char* p_extra)
120{
122
123 assert(m_ltDoor == NULL && m_rtDoor == NULL);
124 assert(m_roi);
125 assert(!strncmp(m_roi->GetName(), "rcdor", 5));
126
127 const CompoundObject* comp = m_roi->GetComp();
128
129 for (CompoundObject::const_iterator it = comp->begin(); it != comp->end(); it++) {
130 LegoROI* roi = (LegoROI*) *it;
131
132 if (roi && (!strnicmp(roi->GetName(), "dor-lt", 6) || !strnicmp(roi->GetName(), "dor-sl", 6))) {
133 m_ltDoor = roi;
134 }
135 else if (roi && (!strnicmp(roi->GetName(), "dor-rt", 6) || !strnicmp(roi->GetName(), "dor-sr", 6))) {
136 m_rtDoor = roi;
137 }
138 }
139
140 assert(m_ltDoor && m_rtDoor);
141}
[AI] Represents a special LegoPathActor controlling the animation and logic of a pair of doors,...
Definition: doors.h:17
void Animate(float p_time) override
[AI] Animates the doors based on current time, moving them through different animation states (closed...
Definition: doors.cpp:68
void ParseAction(char *p_extra) override
[AI] Parses action directives for the Doors, as well as identifying and associating left and right do...
Definition: doors.cpp:119
virtual MxFloat VTable0xcc(float p_time)
[AI] Calculates the normalized open-close position of the doors for the given time,...
Definition: doors.cpp:43
LegoROI * m_roi
[AI] Pointer to this entity's currently assigned ROI (3D instance in the world). [AI]
Definition: legoentity.h:215
[AI] An actor that moves along a predefined path, supporting boundary transitions,...
Definition: legopathactor.h:32
LegoPathBoundary * m_boundary
[AI] Current boundary the actor is navigating on. [AI]
MxU32 m_actorState
[AI] State and flags bitfield for path following logic. [AI]
void ParseAction(char *p_extra) override
[AI] Parses a set of key-value action commands and configures path navigation and collision for this ...
@ c_initial
[AI] Default state upon creation or reset. [AI]
Definition: legopathactor.h:37
[AI] Represents a Real-time Object Instance enriched with LEGO-specific functionality.
Definition: legoroi.h:43
const LegoChar * GetName() const
[AI] Gets this ROI's name.
Definition: legoroi.h:287
LegoU32 GetFlag0x10()
Returns TRUE if the 'disabled' flag is not set, otherwise FALSE.
Definition: legowegedge.h:57
void RotateY(const float &p_angle)
Applies a rotation (in radians or degrees, depending on implementation) about the Y axis.
[AI] Represents a 4x4 transformation matrix, specialized for the LEGO Island engine and derived from ...
Definition: mxmatrix.h:16
MxLong GetTime()
Returns the current timer value in ms, depending on running state.
Definition: mxtimer.h:50
virtual void VTable0x14()
[AI] Calls VTable0x1c().
Definition: orientableroi.h:64
void FUN_100a58f0(const Matrix4 &p_transform)
Assigns the given matrix as the local-to-world transformation and enables some internal flags.
void SetVisibility(unsigned char p_visible)
[AI] Sets the visibility flag to the provided value.
Definition: roi.h:235
const CompoundObject * GetComp() const
[AI] Returns the pointer to the compound object structure, or NULL if not present.
Definition: roi.h:222
[AI] 3D vector class, providing vector and cross-product operations in 3D space.
Definition: vector.h:249
void Clear() override
[AI] Sets every coordinate (x, y, z) to zero.
#define DECOMP_SIZE_ASSERT(T, S)
Definition: decomp.h:19
MxFloat g_unk0x100d8e7c
Definition: doors.cpp:15
MxFloat g_unk0x100d8e84
Definition: doors.cpp:23
MxFloat g_unk0x100d8e80
Definition: doors.cpp:19
#define NULL
[AI] Null pointer value (C/C++ semantics).
Definition: legotypes.h:26
#define FAILURE
[AI] Used to indicate a failed operation in result codes.
Definition: legotypes.h:34
#define SUCCESS
[AI] Used to indicate a successful operation in result codes.
Definition: legotypes.h:30
MxTimer * Timer()
[AI] Returns the global simulation timer.
Definition: mxmisc.cpp:33
MxU8 MxBool
[AI]
Definition: mxtypes.h:124
MxLong MxResult
[AI]
Definition: mxtypes.h:106
float MxFloat
[AI]
Definition: mxtypes.h:68
list< ROI * > CompoundObject
Definition: roi.h:135