Mario Kart 64
Loading...
Searching...
No Matches
Truck.h
Go to the documentation of this file.
1#pragma once
2
3#include <libultraship.h>
4#include "Actor.h"
5#include <vector>
7#include "engine/CoreMath.h"
8#include "engine/World.h"
9
10extern "C" {
11#include "main.h"
12#include "vehicles.h"
13#include "waypoints.h"
14#include "sounds.h"
15}
16
17class ATruck : public AActor {
18 public:
19 enum SpawnMode : uint16_t {
20 POINT, // Spawn car at a specific path point
21 AUTO, // Automatically distribute cars based on a specific path point
22 };
23
24 const char* Type;
25 size_t Index;
26 f32 Speed;
34 s8 SomeFlags = 0;
36
37 f32 SomeArg3 = 55.0f;
38 f32 SomeArg4 = 12.5f;
39 u32 SoundBits = SOUND_ARG_LOAD(0x51, 0x01, 0x80, 0x03);
40
41 float SpeedB = 0.0f;
43 uint32_t PathIndex = 0;
44 uint32_t PathPoint = 0;
45
46 // This is simply a helper function to keep Spawning code clean
47 static inline ATruck* Spawn(f32 speedA, f32 speedB, uint32_t pathIndex, uint32_t pathPoint, ATruck::SpawnMode spawnMode) {
48 SpawnParams params = {
49 .Name = "mk:truck",
50 .Type = static_cast<uint16_t>(spawnMode),
51 .PathIndex = pathIndex,
52 .PathPoint = pathPoint,
53 .Speed = speedA,
54 .SpeedB = speedB
55 };
56 return static_cast<ATruck*>(gWorldInstance.AddActor(new ATruck(params)));
57 }
58
59 explicit ATruck(const SpawnParams& params);
60
62 _count--;
63 }
64
65 static size_t GetCount() {
66 return _count;
67 }
68
69 virtual void SetSpawnParams(SpawnParams& params) override;
70 virtual void Tick() override;
71 virtual void Draw(Camera* camera) override;
72 virtual void VehicleCollision(s32 playerId, Player* player) override;
73 virtual bool IsMod() override;
74 virtual void DrawEditorProperties() override;
75
76 private:
77 static size_t _count;
78 static std::map<uint32_t, std::vector<uint32_t>> TruckCounts;
79};
World gWorldInstance
Definition Game.cpp:74
AActor()
Definition Actor.cpp:13
s16 SomeType
Definition Truck.h:35
uint32_t PathIndex
Definition Truck.h:43
Vec3f Position
Definition Truck.h:28
float SpeedB
Definition Truck.h:41
virtual void Tick() override
Definition Truck.cpp:118
size_t Index
Definition Truck.h:25
Vec3s Rotation
Definition Truck.h:30
virtual void DrawEditorProperties() override
Definition Truck.cpp:314
s16 ActorIndex
Definition Truck.h:27
f32 SomeArg3
Definition Truck.h:37
static size_t GetCount()
Definition Truck.h:65
~ATruck()
Definition Truck.h:61
virtual void SetSpawnParams(SpawnParams &params) override
Definition Truck.cpp:86
s8 SomeFlagsTheSequel
Definition Truck.h:32
virtual bool IsMod() override
Definition Truck.cpp:95
virtual void VehicleCollision(s32 playerId, Player *player) override
Definition Truck.cpp:181
u32 SoundBits
Definition Truck.h:39
Vec3f Velocity
Definition Truck.h:29
ATruck(const SpawnParams &params)
Definition Truck.cpp:24
SpawnMode
Definition Truck.h:19
@ POINT
Definition Truck.h:20
@ AUTO
Definition Truck.h:21
u16 WaypointIndex
Definition Truck.h:33
static size_t _count
Definition Truck.h:77
virtual void Draw(Camera *camera) override
Definition Truck.cpp:99
ATruck::SpawnMode SpawnType
Definition Truck.h:42
const char * Type
Definition Truck.h:24
f32 SomeMultiplierTheSequel
Definition Truck.h:31
f32 SomeArg4
Definition Truck.h:38
s8 SomeFlags
Definition Truck.h:34
f32 Speed
Definition Truck.h:26
static std::map< uint32_t, std::vector< uint32_t > > TruckCounts
Definition Truck.h:78
uint32_t PathPoint
Definition Truck.h:44
static ATruck * Spawn(f32 speedA, f32 speedB, uint32_t pathIndex, uint32_t pathPoint, ATruck::SpawnMode spawnMode)
Definition Truck.h:47
f32 Vec3f[3]
Definition common_structs.h:10
s16 Vec3s[3]
Definition common_structs.h:15
#define SOUND_ARG_LOAD(sound_bank, byte2, byte3, sound_id)
Definition sounds.h:14
Definition camera.h:35
Definition common_structs.h:264
Definition SpawnParams.h:30