75 lines
1.5 KiB
C++
75 lines
1.5 KiB
C++
#pragma once
|
|
|
|
#include "core/io/resource.h"
|
|
#include "core/variant/type_info.h"
|
|
#include "macros.h"
|
|
#include "scene/3d/node_3d.h"
|
|
#include "scene/resources/packed_scene.h"
|
|
|
|
class GunPart : public Resource {
|
|
GDCLASS(GunPart, Resource);
|
|
|
|
public:
|
|
static void _bind_methods();
|
|
|
|
public:
|
|
GDENUM(AmmoType,
|
|
AMMOTYPE_PISTOL,
|
|
AMMOTYPE_ASSAULT,
|
|
AMMOTYPE_RIFLE,
|
|
AMMOTYPE_ROCKET,
|
|
AMMOTYPE_ENERGY);
|
|
|
|
private:
|
|
Ref<PackedScene> scene{};
|
|
|
|
public:
|
|
GET_SET_FNS(Ref<PackedScene>, scene);
|
|
};
|
|
|
|
MAKE_TYPE_INFO(GunPart::AmmoType, Variant::INT);
|
|
|
|
class GunFiringMechanismPart : public GunPart {
|
|
GDCLASS(GunFiringMechanismPart, GunPart);
|
|
|
|
private:
|
|
AmmoType ammo{ AMMOTYPE_PISTOL };
|
|
|
|
public:
|
|
GET_SET_FNS(AmmoType, ammo);
|
|
};
|
|
|
|
class GunBarrelPart : public GunPart {};
|
|
|
|
class GunMuzzlePart : public GunPart {};
|
|
|
|
class GunScopePart : public GunPart {};
|
|
|
|
class GunStockPart : public GunPart {};
|
|
|
|
class GunSchematic : public Resource {
|
|
GDCLASS(GunSchematic, Resource);
|
|
static void _bind_methods();
|
|
|
|
public:
|
|
private:
|
|
Ref<GunPart> firing_mechanism{};
|
|
Ref<GunPart> barrel{};
|
|
Ref<GunPart> muzzle{};
|
|
Ref<GunPart> scope{};
|
|
Ref<GunPart> stock{};
|
|
|
|
public:
|
|
bool can_construct() const; // returns true if this gun has all parts required to construct it
|
|
Node3D construct() const;
|
|
GET_SET_FNS(Ref<GunPart>, firing_mechanism);
|
|
GET_SET_FNS(Ref<GunPart>, barrel);
|
|
GET_SET_FNS(Ref<GunPart>, muzzle);
|
|
GET_SET_FNS(Ref<GunPart>, scope);
|
|
GET_SET_FNS(Ref<GunPart>, stock);
|
|
};
|
|
|
|
class Gun : Node3D {
|
|
GDCLASS(Gun, Node3D);
|
|
static void _bind_methods();
|
|
};
|