Files
fs2open.github.com/code/scripting/api/objs/model.h
T
Goober5000 592eefb60f scripting refactor to compose handle types
Several handle types in the scripting API used inheritance where composition would be more appropriate.  This refactors those types, as well as removing the various handle types that were just aliases for `model_h`.  These are just the C++-side types; all the Lua types remain as-is.

This also refactors `sound_h` to move the previous `isSoundValid` to `isValid` so that `ade_set_args` will work properly for sounds with the `Lua_API_returns_nil_instead_of_invalid_object` flag.  The subclassing from `sound_entry_h` was removed and the "full validity check" was moved to `isValidWithEntry`.  The Lua side remains unaffected, but additional documentation was added to clarify the usage.

Follow-up to #6009 and prerequisite to #6006 due to the `isValid` refactor for `sound_h`.
2024-02-28 02:51:08 -05:00

117 lines
1.7 KiB
C++

#pragma once
#include "scripting/ade_api.h"
#include "model/model.h"
namespace scripting {
namespace api {
//**********HANDLE: model
class model_h
{
protected:
polymodel *model;
public:
explicit model_h(int n_modelnum);
explicit model_h(polymodel *n_model);
model_h();
polymodel *Get() const;
int GetID() const;
bool isValid() const;
};
DECLARE_ADE_OBJ(l_Model, model_h);
class submodel_h
{
protected:
polymodel *model;
int submodel_num;
public:
explicit submodel_h(int n_modelnum, int n_submodelnum);
explicit submodel_h(polymodel *n_model, int n_submodelnum);
submodel_h();
polymodel *GetModel() const;
int GetModelID() const;
bsp_info *GetSubmodel() const;
int GetSubmodelIndex() const;
bool isValid() const;
};
DECLARE_ADE_OBJ(l_Submodel, submodel_h);
DECLARE_ADE_OBJ(l_ModelSubmodels, model_h);
DECLARE_ADE_OBJ(l_ModelTextures, model_h);
DECLARE_ADE_OBJ(l_ModelEyepoints, model_h);
// Thrusters:
DECLARE_ADE_OBJ(l_ModelThrusters, model_h);
// Thrusterbank:
struct thrusterbank_h
{
thruster_bank *bank;
thrusterbank_h();
thrusterbank_h(thruster_bank* ba);
thruster_bank *Get() const;
bool isValid() const;
};
DECLARE_ADE_OBJ(l_Thrusterbank, thrusterbank_h);
// Glowpoint:
struct glowpoint_h
{
glow_point *point;
glowpoint_h();
glowpoint_h(glow_point* np);
glow_point* Get() const;
bool isValid() const;
};
DECLARE_ADE_OBJ(l_Glowpoint, glowpoint_h);
// Docking bays:
DECLARE_ADE_OBJ(l_ModelDockingbays, model_h);
class dockingbay_h
{
private:
model_h modelh;
int dock_id;
public:
dockingbay_h(polymodel *pm, int dock_idx);
dockingbay_h();
bool isValid() const;
model_h* getModelH() const;
dock_bay* getDockingBay() const;
};
DECLARE_ADE_OBJ(l_Dockingbay, dockingbay_h);
}
}