12#ifndef TT_INCLUDE__BUILDINGGAMEOBJ_H
13#define TT_INCLUDE__BUILDINGGAMEOBJ_H
16#include "engine_common.h"
17#include "engine_threading.h"
18#include "engine_string.h"
19#include "engine_vector.h"
20#include "SphereClass.h"
21#include "BuildingAggregateClass.h"
22#include "LightPhysClass.h"
23#include "DamageableGameObj.h"
24#include "BuildingGameObjDef.h"
25class BuildingMonitorClass;
26class PowerPlantGameObj;
27class SoldierFactoryGameObj;
28class VehicleFactoryGameObj;
30class WarFactoryGameObj;
32class ComCenterGameObj;
33class RepairBayGameObj;
34class AudibleSoundClass;
35class BaseControllerClass;
36class ConstructionYardGameObj;
37class AirFactoryGameObj;
38class NavalFactoryGameObj;
39class SuperweaponGameObj;
40class BuildingGameObj :
public DamageableGameObj,
public CombatPhysObserverClass
43 BuildingGameObj(
void );
44 virtual ~BuildingGameObj(
void );
45 virtual void Init(
void );
46 void Init(
const BuildingGameObjDef & definition );
47 const BuildingGameObjDef SCRIPTS_API & Get_Definition(
void )
const ;
48 virtual bool Save( ChunkSaveClass & csave );
49 virtual bool Load( ChunkLoadClass & cload );
50 virtual const PersistFactoryClass & Get_Factory(
void )
const;
51 virtual BuildingGameObj * As_BuildingGameObj(
void ) {
return this; }
52 virtual DamageableGameObj * As_DamageableGameObj(
void ) {
return this; }
53 virtual PowerPlantGameObj * As_PowerPlantGameObj (
void) {
return NULL; }
54 virtual SoldierFactoryGameObj * As_SoldierFactoryGameObj (
void) {
return NULL; }
55 virtual VehicleFactoryGameObj * As_VehicleFactoryGameObj (
void) {
return NULL; }
56 virtual AirStripGameObj * As_AirStripGameObj (
void) {
return NULL; }
57 virtual WarFactoryGameObj * As_WarFactoryGameObj (
void) {
return NULL; }
58 virtual RefineryGameObj * As_RefineryGameObj (
void) {
return NULL; }
59 virtual ComCenterGameObj * As_ComCenterGameObj (
void) {
return NULL; }
60 virtual RepairBayGameObj * As_RepairBayGameObj (
void) {
return NULL; }
61 void Get_Position(Vector3 * pos)
const { *pos = Position; }
62 void Set_Position(
const Vector3 & pos) { Position = pos; CollectionSphere.Center = pos; }
63 virtual void Apply_Damage(
const OffenseObjectClass & damager,
65 int alternate_skin = -1 );
66 void Apply_Damage_Building(
const OffenseObjectClass & offense,
67 StaticPhysClass * component );
68 void Apply_Damage_Building(
const OffenseObjectClass & offense,
70 void Set_Normalized_Health (
float health);
71 void Enable_Power(
bool onoff);
72 bool Is_Power_Enabled(
void)
const {
return IsPowerOn; }
73 void Play_Announcement(
int text_id,
bool broadcast );
74 void Stop_Current_Announcement(
void );
75 bool Name_Prefix_Matches_This_Building(
const char * name);
76 static bool Is_Interior_Mesh_Name(
const char * name);
77 static bool Is_Exterior_Mesh_Name(
const char * name);
78 const char * Get_Name_Prefix (
void)
const {
return Get_Definition().MeshPrefix; }
79 void Collect_Building_Components (
void);
80 void Get_Collection_Sphere (SphereClass *sphere)
const { *sphere = CollectionSphere; }
81 void Set_Collection_Sphere (
const SphereClass &sphere) { CollectionSphere = sphere; }
82 virtual void CnC_Initialize (BaseControllerClass *base);
83 virtual void On_Destroyed (
void);
84 virtual void On_Damaged (
void);
85 virtual void On_Revived (
void);
86 bool Is_Destroyed (
void)
const {
return IsDestroyed; }
87 void Set_Is_Destroyed(
const bool _IsDestroyed) { IsDestroyed = _IsDestroyed; }
88 bool Is_Spy_Disabled()
const {
return IsSpyDisabled; }
89 void Set_Is_Spy_Disabled(
const bool _IsSpyDisabled) {IsSpyDisabled = _IsSpyDisabled; }
90 virtual void Import_Rare (BitStreamClass &packet);
91 virtual void Export_Rare (BitStreamClass &packet);
92 virtual void Export_Creation (BitStreamClass &packet);
93 virtual void Import_Creation (BitStreamClass &packet);
94 static void Set_Precision (
void);
95 virtual bool Get_World_Position (Vector3 &pos)
const { pos = Position;
return true; }
96 virtual void Get_Description( StringClass & description );
97 virtual bool Is_Tagged(
void) {
return false; }
98 SCRIPTS_API BuildingAggregateClass * Find_MCT();
99 bool Is_GDI(
void ) {
return Get_Player_Type() == PLAYERTYPE_GDI; }
100 bool Is_Nod(
void ) {
return Get_Player_Type() == PLAYERTYPE_NOD; }
103 const AABoxClass& Get_Bounds() {
return BoundingBox; }
104 static void Set_Can_Repair_Buildings(
bool flag) {CanRepairBuildings = flag;}
105 static bool Get_Can_Repair_Buildings(
void) {
return CanRepairBuildings;}
108 SCRIPTS_API
void Find_Closest_Poly (
const Vector3 &pos,
float *distance2);
109 float Find_Closest_Poly(
const Vector3 &pos) {
float distance2; Find_Closest_Poly(pos,&distance2);
return distance2; }
110 void Find_Closest_Poly(
const Vector3& pos,
float* distance2, Vector3* polyPos);
111 int Building_In_Range(
const Vector3 &point,
float range);
112 bool Is_In_Range_Coarse(
const Vector3& point,
float range_sq);
113 bool Cast_Ray(RayCollisionTestClass& raytest);
115 virtual ConstructionYardGameObj * As_ConstructionYardGameObj (
void) {
return NULL; }
116 virtual AirFactoryGameObj * As_AirFactoryGameObj (
void) {
return NULL; }
117 virtual NavalFactoryGameObj * As_NavalFactoryGameObj (
void) {
return NULL; }
118 virtual SuperweaponGameObj * As_SuperweaponGameObj (
void) {
return NULL; }
121 BuildingMonitorClass * BuildingMonitor;
122 BaseControllerClass * BaseController;
128 AudibleSoundClass * CurrentAnnouncement;
129 SphereClass AnnouncementSphere;
130 SphereClass CollectionSphere;
131 RefMultiListClass<StaticPhysClass> InteriorMeshes;
132 RefMultiListClass<StaticPhysClass> ExteriorMeshes;
133 RefMultiListClass<BuildingAggregateClass> Aggregates;
134 RefMultiListClass<LightPhysClass> PowerOnLights;
135 RefMultiListClass<LightPhysClass> PowerOffLights;
138 AABoxClass BoundingBox;
139 static REF_DECL(
bool, CanRepairBuildings);
142 void Initialize_Building(
void);
143 void Reset_Components(
void);
144 void Add_Mesh(StaticPhysClass * terrain);
145 void Remove_Mesh(StaticPhysClass * terrain);
146 void Add_Aggregate(BuildingAggregateClass * aggregate);
147 void Remove_Aggregate(BuildingAggregateClass * aggregate);
148 void Add_Light(LightPhysClass * light);
149 void Find_Closest_Poly_For_Model (RenderObjClass *model,
const Vector3 &pos,
float *distance2, Vector3* polyPos = NULL);
150 void Update_State(
bool force_update =
false);
151 void Enable_Alternate_Materials(RefMultiListClass<StaticPhysClass> & models,
bool onoff);
152 void Enable_Alternate_Materials(RenderObjClass * model,
bool onoff);
153 friend class GameObjManager;