Example #1
0
/***********************************************************
save to lua file
***********************************************************/
void DisplayInfoHandler::SaveToLuaFile(std::ostream & file, const std::string & name)
{
	file<<"\t"<<name<<" = DisplayInfoHandler()"<<std::endl;

	file<<"\t\t"<<name<<":SetRenderType("<<GetRenderType()<<")"<<std::endl;
	file<<"\t\t"<<name<<".Dinfo.ModelId = "<<Dinfo.ModelId<<std::endl;
	file<<"\t\t"<<name<<".Dinfo.ModelName = \""<<Dinfo.ModelName<<"\""<<std::endl;
	file<<"\t\t"<<name<<".Dinfo.Outfit = \""<<Dinfo.Outfit<<"\""<<std::endl;
	file<<"\t\t"<<name<<".Dinfo.Weapon = \""<<Dinfo.Weapon<<"\""<<std::endl;
	file<<"\t\t"<<name<<".Dinfo.Mode = \""<<Dinfo.Mode<<"\""<<std::endl;
	file<<"\t\t"<<name<<".Dinfo.UseLight = "<<(Dinfo.UseLight?"true":"false")<<std::endl;
	file<<"\t\t"<<name<<".Dinfo.CastShadow = "<<(Dinfo.CastShadow?"true":"false")<<std::endl;
	file<<"\t\t"<<name<<".Dinfo.ColorR = "<<Dinfo.ColorR<<std::endl;
	file<<"\t\t"<<name<<".Dinfo.ColorG = "<<Dinfo.ColorG<<std::endl;
	file<<"\t\t"<<name<<".Dinfo.ColorB = "<<Dinfo.ColorB<<std::endl;
	file<<"\t\t"<<name<<".Dinfo.ColorA = "<<Dinfo.ColorA<<std::endl;
	file<<"\t\t"<<name<<".Dinfo.TransX = "<<Dinfo.TransX<<std::endl;
	file<<"\t\t"<<name<<".Dinfo.TransY = "<<Dinfo.TransY<<std::endl;
	file<<"\t\t"<<name<<".Dinfo.TransZ = "<<Dinfo.TransZ<<std::endl;
	file<<"\t\t"<<name<<".Dinfo.ScaleX = "<<Dinfo.ScaleX<<std::endl;
	file<<"\t\t"<<name<<".Dinfo.ScaleY = "<<Dinfo.ScaleY<<std::endl;
	file<<"\t\t"<<name<<".Dinfo.ScaleZ = "<<Dinfo.ScaleZ<<std::endl;
	file<<"\t\t"<<name<<".Dinfo.RotX = "<<Dinfo.RotX<<std::endl;
	file<<"\t\t"<<name<<".Dinfo.RotY = "<<Dinfo.RotY<<std::endl;
	file<<"\t\t"<<name<<".Dinfo.RotZ = "<<Dinfo.RotZ<<std::endl;
	file<<"\t\t"<<name<<".Dinfo.UseBillboard = "<<(Dinfo.UseBillboard?"true":"false")<<std::endl;
	
	if(Dinfo.UseTransparentMaterial)
	{
		file<<"\t\t"<<name<<".Dinfo.UseTransparentMaterial = true"<<std::endl;
		file<<"\t\t"<<name<<".Dinfo.MatAlpha = "<<Dinfo.MatAlpha<<std::endl;
	}

	if(Dinfo.ColorMaterialType > 0)
	{
		file<<"\t\t"<<name<<".Dinfo.ColorMaterialType = "<<Dinfo.ColorMaterialType<<std::endl;
		file<<"\t\t"<<name<<".Dinfo.MatAmbientColorR = "<<Dinfo.MatAmbientColorR<<std::endl;
		file<<"\t\t"<<name<<".Dinfo.MatAmbientColorG = "<<Dinfo.MatAmbientColorG<<std::endl;
		file<<"\t\t"<<name<<".Dinfo.MatAmbientColorB = "<<Dinfo.MatAmbientColorB<<std::endl;
		file<<"\t\t"<<name<<".Dinfo.MatAmbientColorA = "<<Dinfo.MatAmbientColorA<<std::endl;
		file<<"\t\t"<<name<<".Dinfo.MatDiffuseColorR = "<<Dinfo.MatDiffuseColorR<<std::endl;
		file<<"\t\t"<<name<<".Dinfo.MatDiffuseColorG = "<<Dinfo.MatDiffuseColorG<<std::endl;
		file<<"\t\t"<<name<<".Dinfo.MatDiffuseColorB = "<<Dinfo.MatDiffuseColorB<<std::endl;
		file<<"\t\t"<<name<<".Dinfo.MatDiffuseColorA = "<<Dinfo.MatDiffuseColorA<<std::endl;
		file<<"\t\t"<<name<<".Dinfo.MatSpecularColorR = "<<Dinfo.MatSpecularColorR<<std::endl;
		file<<"\t\t"<<name<<".Dinfo.MatSpecularColorG = "<<Dinfo.MatSpecularColorG<<std::endl;
		file<<"\t\t"<<name<<".Dinfo.MatSpecularColorB = "<<Dinfo.MatSpecularColorB<<std::endl;
		file<<"\t\t"<<name<<".Dinfo.MatSpecularColorA = "<<Dinfo.MatSpecularColorA<<std::endl;
		file<<"\t\t"<<name<<".Dinfo.MatEmissionColorR = "<<Dinfo.MatEmissionColorR<<std::endl;
		file<<"\t\t"<<name<<".Dinfo.MatEmissionColorG = "<<Dinfo.MatEmissionColorG<<std::endl;
		file<<"\t\t"<<name<<".Dinfo.MatEmissionColorB = "<<Dinfo.MatEmissionColorB<<std::endl;
		file<<"\t\t"<<name<<".Dinfo.MatEmissionColorA = "<<Dinfo.MatEmissionColorA<<std::endl;
		file<<"\t\t"<<name<<".Dinfo.MatShininess = "<<Dinfo.MatShininess<<std::endl;
	}
}
int CObject::Create (ubyte nType, ubyte nId, short nCreator, short nSegment,
							const CFixVector& vPos, const CFixMatrix& mOrient,
							fix xSize, ubyte cType, ubyte mType, ubyte rType)
{
#if DBG
if (nType == OBJ_WEAPON) {
	nType = nType;
	if ((nCreator >= 0) && (OBJECTS [nCreator].info.nType == OBJ_ROBOT))
		nType = nType;
	if (nId == FLARE_ID)
		nType = nType;
	if (gameData.objs.bIsMissile [(int) nId])
		nType = nType;
	}
else if (nType == OBJ_ROBOT) {
#if 0
	if (ROBOTINFO ((int) nId).bossFlag && (BOSS_COUNT >= MAX_BOSS_COUNT))
		return -1;
#endif
	}
else if (nType == OBJ_HOSTAGE)
	nType = nType;
else if (nType == OBJ_FIREBALL)
	nType = nType;
else if (nType == OBJ_REACTOR)
	nType = nType;
else if (nType == OBJ_DEBRIS)
	nType = nType;
else if (nType == OBJ_MARKER)
	nType = nType;
else if (nType == OBJ_PLAYER)
	nType = nType;
else if (nType == OBJ_POWERUP)
	nType = nType;
#endif

SetSegment (FindSegByPos (vPos, nSegment, 1, 0));
if ((Segment () < 0) || (Segment () > gameData.segs.nLastSegment))
	return -1;

if (nType == OBJ_DEBRIS) {
	if (gameData.objs.nDebris >= gameStates.render.detail.nMaxDebrisObjects)
		return -1;
	}

// Zero out object structure to keep weird bugs from happening in uninitialized fields.
m_nId = OBJ_IDX (this);
SetSignature (gameData.objs.nNextSignature++);
SetType (nType);
SetId (nId);
SetLastPos (vPos);
SetPos (&vPos);
SetSize (xSize);
SetCreator ((sbyte) nCreator);
SetOrient (&mOrient);
SetControlType (cType);
SetMovementType (mType);
SetRenderType (rType);
SetContainsType (-1);
SetLifeLeft (
	((gameData.app.nGameMode & GM_ENTROPY) && (nType == OBJ_POWERUP) && (nId == POW_HOARD_ORB) && (extraGameInfo [1].entropy.nVirusLifespan > 0)) ?
	I2X (extraGameInfo [1].entropy.nVirusLifespan) : IMMORTAL_TIME);
SetAttachedObj (-1);
m_xCreationTime = gameData.time.xGame;
#if 0
if (GetControlType () == CT_POWERUP)
	CPowerupInfo::SetCount (1);
// Init physics info for this CObject
if (GetMovementType () == MT_PHYSICS)
	m_vStartVel.SetZero ();
if (GetRenderType () == RT_POLYOBJ)
	CPolyObjInfo::SetTexOverride (-1);

if (GetType () == OBJ_WEAPON) {
	CPhysicsInfo::SetFlags (CPhysInfo.GetFlags () | WI_persistent (m_info.nId) * PF_PERSISTENT);
	CLaserInfo::SetCreationTime (gameData.time.xGame);
	CLaserInfo::SetLastHitObj (0);
	CLaserInfo::SetScale (I2X (1));
	}
else if (GetType () == OBJ_DEBRIS)
	gameData.objs.nDebris++;
if (GetControlType () == CT_POWERUP)
	CPowerupInfo::SetCreationTime (gameData.time.xGame);
else if (GetControlType () == CT_EXPLOSION) {
	CAttachedInfo::SetPrev (-1);
	CAttachedInfo::SetNext (-1);
	CAttachedInfo::SetParent (-1);
	}
#endif
Link ();
LinkToSeg (nSegment);
return m_nId;
}