summaryrefslogtreecommitdiff
path: root/src/engine/actors/Finishline.h
blob: 9f117dbaecdf0ffdab80d003179978c1d73c6ff3 (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
#pragma once

#include <libultraship.h>
#include "engine/CoreMath.h"
#include "engine/registry/RegisterContent.h"
#include "engine/Actor.h"

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

class AFinishline : public AActor {
public:
    /**
     * Default behaviour places the finishline at the first waypoint.
     * @arg pos, optional. Sets a custom position
     */
    AFinishline(const SpawnParams& params);

    ~AFinishline() {
        _count--;
    }

    // This is simply a helper function to keep Spawning code clean
    static AFinishline* Spawn(FVector pos, IRotator rot) {
        SpawnParams params = {
            .Name = "mk:finishline",
            .Location = pos,
            .Rotation = rot,
        };
        return dynamic_cast<AFinishline*>(AddActorToWorld<AFinishline>(params));
    }

    static AFinishline* Spawn() {
        SpawnParams params = {
            .Name = "mk:finishline",
        };
        return dynamic_cast<AFinishline*>(AddActorToWorld<AFinishline>(params));
    }

    // Virtual functions to be overridden by derived classes
    virtual void Tick() override;
    virtual void Draw(Camera*) override;
    virtual void BeginPlay() override;
    virtual void Collision(Player* player, AActor* actor) override;
    virtual bool IsMod() override;

    bool bIsFinishline = false;

    static size_t _count;
    size_t _idx;
    bool PickedUp = false;
    uint32_t Timer = 0;
    
    Player* _player = NULL;
    
    f32 Hop = 3.0f;
    f32 Gravity = 200.0f;

    f32 OldHop = 0;
    f32 OldGravity = 0;

};