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

#include <libultraship.h>
#include "engine/SpawnParams.h"
#include "engine/editor/EditorMath.h"

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

class AActor {
public:
    /* 0x00 */ s16 Type = 0;
    /* 0x02 */ s16 Flags;
    /* 0x04 */ s16 Unk_04;
    /* 0x06 */ s16 State;
    /* 0x08 */ f32 Unk_08;
    /* 0x0C */ f32 BoundingBoxSize;
    /* 0x10 */ Vec3s Rot = {0, 0, 0};
    /* 0x16 */ s16 Unk_16;
    /* 0x18 */ Vec3f Pos;
    /* 0x24 */ Vec3f Velocity = {0, 0, 0};
    /* 0x30 */ struct Collision Unk30;
    /* 0x   */ const char* Model = "";
    uint8_t uuid[16];
    const char* Name = "";
    const char* ResourceName = "";
    FVector SpawnPos = {0.0f, 0.0f, 0.0f};
    IRotator SpawnRot = {0, 0, 0};
    FVector SpawnScale = {1.0f, 1.0f, 1.0f};

    FVector Scale = {1, 1, 1};
    float Speed = 0.0f;
    std::vector<Triangle> Triangles;

    bool bPendingDestroy = false;

    virtual ~AActor() = default;  // Virtual destructor for proper cleanup in derived classes

    explicit AActor();
    explicit AActor(SpawnParams params);

    /**
     * Make sure you call this in derived classes!
     * Usage:
     * MyActor::SetSpawnParams(SetSpawnParams& params) {
     *     AActor::SetSpawnParams(params); // Calls default implementation
     * }
     */
    virtual void SetSpawnParams(SpawnParams& params);
    virtual void BeginPlay();
    virtual void Tick();
    virtual void Draw(Camera* camera);
    virtual void Collision(Player* player, AActor* actor);
    virtual void VehicleCollision(s32 playerId, Player* player);
    void SetLocation(FVector pos);

    virtual void Destroy();
    virtual bool IsMod();

    /** Editor functions **/
    FVector GetLocation() const;
    IRotator GetRotation() const;
    FVector GetScale() const;
    void Translate(FVector pos);
    void Rotate(IRotator rot);
    void SetScale(FVector scale);
    virtual void DrawEditorProperties() { DrawDefaultEditorProperties(); };
};