convert line ends
[canaan.git] / prj / cam / src / shock / shkdmprp.cpp
blobd2198babbd132f817fa9fdadef90283520dc45f8
1 /*
2 @Copyright Looking Glass Studios, Inc.
3 1996,1997,1998,1999,2000 Unpublished Work.
4 */
6 // $Header: r:/t2repos/thief2/src/shock/shkdmprp.cpp,v 1.2 1998/06/30 12:09:47 TOML Exp $
8 //
9 // Death model name property
12 #include <shkdmprp.h>
14 #include <property.h>
15 #include <propface.h>
16 #include <propbase.h>
18 #include <osysbase.h>
20 #include <appagg.h>
22 #include <traitman.h>
23 #include <traitbas.h>
24 #include <objquery.h>
26 #include <objmodel.h>
27 #include <mprintf.h>
29 #include <dmgmodel.h>
30 #include <dmgbase.h>
31 #include <mnamprop.h>
33 #include <dbmem.h>
35 static ILabelProperty* pDeathModelNameProp = NULL;
37 ////////////////////////////////////////////////////////////
38 // DEATH MODEL NAME PROPERTY CREATION
41 #define DEATHMODELNAMEPROP_IMPL kPropertyImplSparse
43 static sPropertyConstraint deathmodelnameprop_const[] =
45 { kPropertyNullConstraint, NULL }
48 static sPropertyDesc deathmodelnameprop_desc =
50 PROP_DEATHMODELNAME_NAME,
52 deathmodelnameprop_const,
53 0,0, // verison
54 { "Shape", "Death Model Name" },
58 // called when the name is modified
59 static void LGAPI ModelNameListener(sPropertyListenMsg* msg, PropListenerData data)
61 if (msg->property != modelnameprop->GetID())
62 return;
64 // don't do this work here, it is done in NumProp::Notify
65 if (msg->type & kListenPropLoad)
66 return ;
68 if (msg->type & (kListenPropModify|kListenPropSet))
70 int dummy;
71 if (OBJ_IS_CONCRETE(msg->obj) || ObjGetModelNumber(msg->obj,&dummy))
72 ObjLoadModel(msg->obj);
73 else // load all descendents
75 AutoAppIPtr_(TraitManager,TraitMan);
76 IObjectQuery* query = TraitMan->Query(msg->obj,kTraitQueryAllDescendents);
77 for (; !query->Done(); query->Next())
79 ObjID obj = query->Object();
80 if (OBJ_IS_CONCRETE(obj))
81 ObjLoadModel(msg->obj);
83 SafeRelease(query);
89 eDamageResult LGAPI DeathModelDamageListener(const sDamageMsg* pMsg, tDamageCallbackData data)
91 Label name;
93 if (ObjGetDeathModelName(pMsg->victim, (char*)&name))
94 ObjSetModelName(pMsg->victim, (char*)&name);
95 return kDamageNoOpinion;
98 // Init the property
99 void DeathModelNamePropInit(void)
101 pDeathModelNameProp = CreateLabelProperty(&deathmodelnameprop_desc, DEATHMODELNAMEPROP_IMPL);
102 AutoAppIPtr_(DamageModel, pDamageModel);
103 pDamageModel->Listen(kDamageMsgSlay, &DeathModelDamageListener, NULL);
106 // get and set functions
107 BOOL ObjGetDeathModelName(ObjID obj, char *name)
109 Assert_(pDeathModelNameProp);
110 char *temp;
111 BOOL retval = pDeathModelNameProp->Get(obj, (Label**)&temp);
112 if (retval) // hope name long enough!
113 strcpy(name,temp);
114 return retval;
117 void ObjSetDeathModelName(ObjID obj, char *name)
119 Assert_(pDeathModelNameProp);
120 pDeathModelNameProp->Set(obj, (Label*)name);