convert line ends
[canaan.git] / prj / cam / src / deepc / game / dpcdmprp.cpp
blob3031d7f92263b60f7b29348e7578bdfad1a7e70f
1 /*
2 @Copyright Looking Glass Studios, Inc.
3 1996,1997,1998,1999,2000 Unpublished Work.
4 */
6 //
7 // Death model name property
8 //
10 #include <dpcdmprp.h>
12 #include <property.h>
13 #include <propface.h>
14 #include <propbase.h>
16 #include <osysbase.h>
18 #include <appagg.h>
20 #include <traitman.h>
21 #include <traitbas.h>
22 #include <objquery.h>
24 #include <objmodel.h>
25 #include <mprintf.h>
27 #include <dmgmodel.h>
28 #include <dmgbase.h>
29 #include <mnamprop.h>
31 #include <dbmem.h>
33 static ILabelProperty* pDeathModelNameProp = NULL;
35 ////////////////////////////////////////////////////////////
36 // DEATH MODEL NAME PROPERTY CREATION
39 #define DEATHMODELNAMEPROP_IMPL kPropertyImplSparse
41 static sPropertyConstraint deathmodelnameprop_const[] =
43 { kPropertyNullConstraint, NULL }
46 static sPropertyDesc deathmodelnameprop_desc =
48 PROP_DEATHMODELNAME_NAME,
50 deathmodelnameprop_const,
51 0,0, // verison
52 { "Shape", "Death Model Name" },
56 // called when the name is modified
57 static void LGAPI ModelNameListener(sPropertyListenMsg* msg, PropListenerData data)
59 if (msg->property != modelnameprop->GetID())
60 return;
62 // don't do this work here, it is done in NumProp::Notify
63 if (msg->type & kListenPropLoad)
64 return ;
66 if (msg->type & (kListenPropModify|kListenPropSet))
68 int dummy;
69 if (OBJ_IS_CONCRETE(msg->obj) || ObjGetModelNumber(msg->obj,&dummy))
70 ObjLoadModel(msg->obj);
71 else // load all descendents
73 AutoAppIPtr_(TraitManager,TraitMan);
74 IObjectQuery* query = TraitMan->Query(msg->obj,kTraitQueryAllDescendents);
75 for (; !query->Done(); query->Next())
77 ObjID obj = query->Object();
78 if (OBJ_IS_CONCRETE(obj))
79 ObjLoadModel(msg->obj);
81 SafeRelease(query);
87 eDamageResult LGAPI DeathModelDamageListener(const sDamageMsg* pMsg, tDamageCallbackData data)
89 Label name;
91 if (ObjGetDeathModelName(pMsg->victim, (char*)&name))
92 ObjSetModelName(pMsg->victim, (char*)&name);
93 return kDamageNoOpinion;
96 // Init the property
97 void DeathModelNamePropInit(void)
99 pDeathModelNameProp = CreateLabelProperty(&deathmodelnameprop_desc, DEATHMODELNAMEPROP_IMPL);
100 AutoAppIPtr_(DamageModel, pDamageModel);
101 pDamageModel->Listen(kDamageMsgSlay, &DeathModelDamageListener, NULL);
104 // get and set functions
105 BOOL ObjGetDeathModelName(ObjID obj, char *name)
107 Assert_(pDeathModelNameProp);
108 char *temp;
109 BOOL retval = pDeathModelNameProp->Get(obj, (Label**)&temp);
110 if (retval) // hope name long enough!
111 strcpy(name,temp);
112 return retval;
115 void ObjSetDeathModelName(ObjID obj, char *name)
117 Assert_(pDeathModelNameProp);
118 pDeathModelNameProp->Set(obj, (Label*)name);