aboutsummaryrefslogtreecommitdiffstats
path: root/src/modelinfo/ModelInfo.h
blob: 60a5e98f9970b3f6b66e7abf0de3a4b97ec8186d (plain) (blame)
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
#pragma once

#include "2dEffect.h"
#include "SimpleModelInfo.h"
#include "MloModelInfo.h"
#include "TimeModelInfo.h"
#include "WeaponModelInfo.h"
#include "ClumpModelInfo.h"
#include "PedModelInfo.h"
#include "VehicleModelInfo.h"
#include "XtraCompsModelInfo.h"
#include "templates.h"

extern C2dEffect *gp2dEffects;

class CModelInfo
{
	static CBaseModelInfo **ms_modelInfoPtrs;
	static int32 msNumModelInfos;
	static CStore<CSimpleModelInfo, SIMPLEMODELSIZE> ms_simpleModelStore;
	static CStore<CTimeModelInfo, TIMEMODELSIZE> ms_timeModelStore;
	static CStore<CWeaponModelInfo, WEAPONMODELSIZE> ms_weaponModelStore;
	static CStore<CClumpModelInfo, CLUMPMODELSIZE> ms_clumpModelStore;
	static CStore<CPedModelInfo, PEDMODELSIZE> ms_pedModelStore;
	static CStore<CVehicleModelInfo, VEHICLEMODELSIZE> ms_vehicleModelStore;
	static CStore<C2dEffect, TWODFXSIZE> ms_2dEffectStore;

public:
	// these fields are in the resource image
	int32 resNumModelInfos;
	CBaseModelInfo **resModelInfoPtrs;

	static void Initialise(void);
	static void ShutDown(void);

	static CSimpleModelInfo *AddSimpleModel(int id);
	static CTimeModelInfo *AddTimeModel(int id);
	static CWeaponModelInfo *AddWeaponModel(int id);
	static CClumpModelInfo *AddClumpModel(int id);
	static CPedModelInfo *AddPedModel(int id);
	static CVehicleModelInfo *AddVehicleModel(int id);

	static CStore<C2dEffect, TWODFXSIZE> &Get2dEffectStore(void) { return ms_2dEffectStore; }
	static C2dEffect *Get2dEffect(int32 id) { return &gp2dEffects[id]; }
	static int32 Get2dEffectIndex(C2dEffect *effect) { return effect - gp2dEffects; }

	static int32 GetNumModelInfos(void) { return msNumModelInfos; }
	static CBaseModelInfo *GetModelInfo(const char *name, int *id);
	static CBaseModelInfo *GetModelInfo(int id){
		if(id < 0 || id >= msNumModelInfos)
			return nil;
		return ms_modelInfoPtrs[id];
	}
	static CBaseModelInfo *GetModelInfo(const char *name, int minIndex, int maxIndex);
	static CBaseModelInfo *GetModelInfoFromHashKey(uint32 hashKey, int *id);
	static CColModel *GetColModel(int id){
		return ms_modelInfoPtrs[id]->GetColModel();
	}

	static bool IsBoatModel(int32 id);
	static bool IsBikeModel(int32 id);
	static bool IsCarModel(int32 id);
	static bool IsTrainModel(int32 id);
	static bool IsHeliModel(int32 id);
	static bool IsPlaneModel(int32 id);
	static void ReInit2dEffects();

	static void Load(uint32 numModelInfos, CBaseModelInfo **modelInfos);
	static void Load2dEffects(uint32 numEffects, C2dEffect *effects);
	CModelInfo *Write(base::cRelocatableChunkWriter &writer);
};