summaryrefslogtreecommitdiff
path: root/src/engine/objects/Crab.h
blob: 6c2ef7de630b16b94814d4b94d07a0a14794c44c (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
#pragma once

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

extern "C" {
#include "macros.h"
#include "main.h"
#include "vehicles.h"
#include "waypoints.h"
#include "common_structs.h"
#include "objects.h"
#include "course_offsets.h"
#include "assets/textures/some_data.h"
}

/**
 * @arg start x and z spawn location
 * @arg end x and z patrol location
 * 
 * Crab patrols between start and end.
 * The game automatically places the actor on the surface of the tracks geometry.
 * Therefore, providing a Y height is unnecessary.
 * 
 * Crab appears to have a maximum patrolling distance and will patrol between
 * end --> max distance rather than start --> end or start --> max distance.
 */
class OCrab : public OObject {
public:
    // This is simply a helper function to keep Spawning code clean
    static inline OCrab* Spawn(const FVector2D& start, const FVector2D& end) {
        SpawnParams params = {
            .Name = "mk:crab",
            .PatrolStart = start,
            .PatrolEnd = end,
        };
        return static_cast<OCrab*>(AddObjectToWorld<OCrab>(params));
    }

    explicit OCrab(const SpawnParams& params);

    ~OCrab() {
        _count--;
    }

    virtual void Tick() override;
    virtual void Draw(s32 cameraId) override;
    virtual void SetSpawnParams(SpawnParams& params) override;
    virtual void DrawEditorProperties() override;

    void init_ktb_crab(s32 objectIndex);
    void func_80082B34(s32 objectIndex);
    void func_80082C30(s32 objectIndex);
    void func_80082E18(s32 objectIndex);

private:
    FVector2D _start;
    FVector2D _end;
    static size_t _count;
    s32 _idx;
};