summaryrefslogtreecommitdiff
path: root/src/engine/objects/BombKart.h
blob: a1bb88c176a8c550d7028a23d517051b5c883a8f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#pragma once

#include <libultraship.h>
#include "engine/registry/RegisterContent.h"
#include "engine/objects/Object.h"

#include "World.h"

extern "C" {
#include "common_structs.h"
}

/**
 * Used in VS mode
 *
 * This differs from the other vehicle classes in that it does not get added to the standard actor list
 * So this is sort of its own thing. Draw call in different place too.
 */
class OBombKart : public OObject {
  public:
    enum States : uint16_t { // 0,1,3,5
        DISABLED,
        COUNTERCLOCKWISE,
        CLOCKWISE,
        STATIONARY,
        CHASE,
        EXPLODE,
        PODIUM_CEREMONY,
    };

    const char* Type;

    Vec3f Pos;
    Vec3f WheelPos[4]; //! @todo Turn WheelPos into a struct
    f32 Unk_3C;
    u16 SomeRot;       // Some angle
    u16 WaypointIndex; // The waypoint the kart circles
    States State = States::DISABLED;
    u16 BounceTimer = 0;
    u16 CircleTimer = 0;
    u16 Unk_4A = 0;
    s16 Unk_4C = 1;
    f32 CenterY; // Center of the circle
    Collision _Collision;


    // This is simply a helper function to keep Spawning code clean
    // Spawn object at a position
    static OBombKart* Spawn(FVector pos, uint16_t behaviour, f32 unk_3C) {
        SpawnParams params = {
            .Name = "mk:bomb_kart",
            .Behaviour = behaviour,
            .Location = pos,
            .Speed = unk_3C, // Only used for podium ceremony. Arbitrarily chose Speed for this
            .SpeedB = 2.7f, // Chase speed
        };
        return dynamic_cast<OBombKart*>(AddObjectToWorld<OBombKart>(params));
    }

    // Spawn object at a point along the tracks path
    static OBombKart* Spawn(uint32_t pathIndex, uint32_t pathPoint, uint16_t behaviour, f32 unk_3C) {
        SpawnParams params = {
            .Name = "mk:bomb_kart",
            .Behaviour = behaviour,
            .PathIndex = pathIndex,
            .PathPoint = pathPoint,
            .Speed = unk_3C, // Only used for podium ceremony. Arbitrarily chose Speed for this
        };
        return dynamic_cast<OBombKart*>(AddObjectToWorld<OBombKart>(params));
    }

    // Set waypoint to NULL if using a spawn position and not a waypoint.
    explicit OBombKart(const SpawnParams& params);

    ~OBombKart() {
        _count--;
    }

    static size_t GetCount() {
        return _count;
    }

    virtual void Tick() override;
    virtual void Draw(s32 cameraId) override;
    virtual void Translate(FVector pos) override;
    virtual void DrawEditorProperties() override;
    void DrawBattle(s32 cameraId);
    void func_800563DC(s32 cameraId, s32 arg2);
    void func_800562E4(s32 cameraId, s32 arg0, s32 arg1, s32 arg2, s32 id);
    void SomeRender(s32 cameraId, Vec3f arg1);
    void LoadMtx(s32 cameraId);
    void Waypoint(s32 screenId);

    OBombKart::States Behaviour = OBombKart::States::COUNTERCLOCKWISE;
    float SpeedB = 2.7f;
  private:
    static u32 vec[3][3];
    static size_t _count;
    s32 _idx;
    Player* FindTarget();
    void Chase(Player*, Vec3f pos);

    Player* _target = NULL;
};