Kinoko
A reimplementation of Mario Kart Wii's physics engine in C++
Toggle main menu visibility
Loading...
Searching...
No Matches
ObjectHitTable.cc
1
#include "ObjectHitTable.hh"
2
3
#include "game/system/ResourceManager.hh"
4
5
#include <egg/util/Stream.hh>
6
7
namespace
Kinoko::Field
{
8
10
ObjectHitTable::ObjectHitTable(
const
char
*filename) {
11
size_t
size;
12
void
*file =
13
System::ResourceManager::Instance()->getFile(filename, &size, System::ArchiveId::Core);
14
15
EGG::RamStream stream = EGG::RamStream(file, size);
16
17
m_count = stream.read_s16();
18
m_fieldCount = stream.read_s16();
19
m_reactions = owning_span<s16>(m_count);
20
21
for
(
auto
&reaction : m_reactions) {
22
stream.skip(0x2);
23
reaction = stream.read_s16();
24
stream.skip(m_fieldCount * 2 - 2);
25
}
26
27
m_slots =
reinterpret_cast<
const
s16 *
>
(stream.dataAtIndex());
28
}
29
31
ObjectHitTable::~ObjectHitTable() =
default
;
32
33
Kart::Reaction ObjectHitTable::reaction(s16 i)
const
{
34
ASSERT(i != -1);
35
ASSERT(i < m_count);
36
return
static_cast<
Kart::Reaction
>
(m_reactions[i]);
37
}
38
39
s16 ObjectHitTable::slot(ObjectId
id
)
const
{
40
constexpr
size_t
SLOT_COUNT = 0x2f4;
41
42
size_t
i =
static_cast<
std::underlying_type_t<ObjectId>
>
(id);
43
return
i < SLOT_COUNT ? parse<s16>(m_slots[i]) : -1;
44
}
45
46
}
// namespace Kinoko::Field
Kinoko::Field
Pertains to collision.
Definition
BoxColManager.cc:10
game
field
ObjectHitTable.cc
Made by
Malleo
. Logo by
vabold
. Website generated by
Doxygen
1.17.0