예제 #1
0
BaseClass *SpawnObjectTemplate(const char *pszSpawn, const char *pName, const LTVector& vPos, const LTRotation& rRot)
{
    if (!g_pLTServer || !pszSpawn) return NULL;

    // Pull the class name out of the spawn string...
    const ObjectCreateStruct *pOCS = g_pGameServerShell->GetObjectTemplates()->FindTemplate(pszSpawn);
    if (!pOCS) return NULL;

    ObjectCreateStruct theStruct = *pOCS;

    HCLASS hClass = theStruct.m_hClass;
    if (!hClass) return NULL;

    theStruct.m_Pos = vPos;
    theStruct.m_Rotation = rRot;

    // Change the name of the object, we're assuming that these already exist and more room
    // doesn't need to be allocated for them
    theStruct.SetName(pName);
    theStruct.m_cProperties.AddProp("Name", GenericProp(pName, LT_PT_STRING));

    // Change the position and rotation
    theStruct.m_cProperties.AddProp("Pos", GenericProp(vPos, LT_PT_VECTOR));
    theStruct.m_cProperties.AddProp("Rotation", GenericProp(rRot, LT_PT_ROTATION));

    // Allocate an object...
    // Note : This has to use the CreateObjectProps function for purposes of backwards
    // compatibility.  Most of the game code assumes that if it's getting a PRECREATE_NORMAL
    // message that it doesn't have any properties available.
    return (BaseClass *)g_pLTServer->CreateObjectProps(hClass, &theStruct, "");
}
예제 #2
0
// ----------------------------------------------------------------------- //
//
//	ROUTINE:	CDebugLineFX::Spawn
//
//	PURPOSE:	Creates a new debug line system.
//
// ----------------------------------------------------------------------- //
DebugLineSystem * DebugLineSystem::Spawn(const char * name, bool bRelative)
{
	const HCLASS hClass = g_pLTServer->GetClass("DebugLineSystem");

	ObjectCreateStruct theStruct;

	theStruct.SetName(name);
	theStruct.m_Pos = LTVector(0.0f,0.0f,0.0f);

	theStruct.m_Flags = FLAG_FORCECLIENTUPDATE | FLAG_GOTHRUWORLD | FLAG_NOTINWORLDTREE;
	theStruct.m_ObjectType = OT_NORMAL;

	DebugLineSystem* pRV = (DebugLineSystem*)g_pLTServer->CreateObjectProps(hClass, &theStruct, "");
	if(!pRV)
		return NULL;

	pRV->m_bRelative = bRelative;
	return pRV;
}