当前位置: 首页>>代码示例>>C++>>正文


C++ SmartScriptTable类代码示例

本文整理汇总了C++中SmartScriptTable的典型用法代码示例。如果您正苦于以下问题:C++ SmartScriptTable类的具体用法?C++ SmartScriptTable怎么用?C++ SmartScriptTable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了SmartScriptTable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: CheckVirtualInventoryRestrictions

//------------------------------------------------------------------------
int CScriptBind_Actor::CheckVirtualInventoryRestrictions(IFunctionHandler *pH, SmartScriptTable inventory, const char *itemClassName)
{
	CActor *pActor = GetActor(pH);
	if (!pActor)
		return pH->EndFunction();

	static std::vector<string> virtualInventory;
	virtualInventory.reserve(inventory->Count());

	IScriptTable::Iterator it=inventory->BeginIteration();
	while(inventory->MoveNext(it))
	{
		const char *itemClass=0;
		it.value.CopyTo(itemClass);

		if (itemClass && itemClass[0])
			virtualInventory.push_back(itemClass);
	}

	inventory->EndIteration(it);

	bool result=pActor->CheckVirtualInventoryRestrictions(virtualInventory, itemClassName);
	virtualInventory.resize(0);

	if (result)
		return pH->EndFunction(1);

	return pH->EndFunction();
}
开发者ID:mrwonko,项目名称:CrysisVR,代码行数:30,代码来源:ScriptBind_Actor.cpp

示例2: DelegateServerHit

//------------------------------------------------------------------------
void CGameRulesMPDamageHandling::DelegateServerHit(IScriptTable* victimScript, const HitInfo& hit, CActor* pVictimActor)
{
	SmartScriptTable victimServerScript;
	if (victimScript->GetValue("Server", victimServerScript))
	{
		HSCRIPTFUNCTION pfnOnHit = 0;
		if (victimServerScript->GetValue("OnHit", pfnOnHit))
		{
			bool diedAfterHit = false;
			m_pGameRules->CreateScriptHitInfo(m_scriptHitInfo, hit);
			if (Script::CallReturn(gEnv->pScriptSystem, pfnOnHit, victimScript, m_scriptHitInfo, diedAfterHit))
			{
				if (diedAfterHit)
				{
					// Hit was deadly
					if (pVictimActor)
					{
						ProcessDeath(hit, *pVictimActor);
					}
					else
					{
						m_pGameRules->OnEntityKilled(hit);
					}
				}

				if (g_pGameCVars->g_debugHits > 0)
				{
					LogHit(hit, (g_pGameCVars->g_debugHits > 1), diedAfterHit);
				}
			}

			gEnv->pScriptSystem->ReleaseFunc(pfnOnHit);
		}
	}
}
开发者ID:aronarts,项目名称:FireNET,代码行数:36,代码来源:GameRulesMPDamageHandling.cpp

示例3: SetDrop

// NOTE Mrz 21, 2007: <pvl> might need to handle the params the way SetGrab()
// does (separate param table for each of the grabbed objects).
// UPDATE Mrz 26, 2007: <pvl> done
bool CMultipleGrabHandler::SetDrop(SmartScriptTable &rParams)
{
	SmartScriptTable dropParamsTable;
	if (rParams->GetValue("params",dropParamsTable))
	{
		bool result = true;

		IScriptTable::Iterator iter = dropParamsTable->BeginIteration();
		int numGrabHandlers = m_handlers.size();

		for (int i=0; dropParamsTable->MoveNext(iter) && i < numGrabHandlers; ++i)
		{
			SmartScriptTable params;
			iter.value.CopyTo (params);
			result = m_handlers[i]->SetDrop(params) & result;
		}

		dropParamsTable->EndIteration(iter);

		return result;
	}
	else
	{
		bool result = true;

		std::vector <CAnimatedGrabHandler*>::iterator it = m_handlers.begin();
		std::vector <CAnimatedGrabHandler*>::iterator end = m_handlers.end();
		for ( ; it != end; ++it)
			result = (*it)->SetDrop(rParams) & result;

		return result;
	}
}
开发者ID:AiYong,项目名称:CryGame,代码行数:36,代码来源:GrabHandler.cpp

示例4: GetEntity

const char *CAnimatedCharacterSample::GetCharacterModelNameFromScriptTable() const
{
	IEntity *pEntity = GetEntity();

	IScriptTable *pScriptTable = pEntity->GetScriptTable();

	if(pScriptTable == NULL)
	{
		return NULL;
	}

	SmartScriptTable propertiesTable;
	const bool hasPropertiesTable = pScriptTable->GetValue("Properties", propertiesTable);

	if(! hasPropertiesTable)
	{
		return NULL;
	}

	const char *modelName = NULL;
	const bool hasModelName = propertiesTable->GetValue("objModel", modelName);

	if(! hasModelName)
	{
		return NULL;
	}

	return modelName;
}
开发者ID:Hellraiser666,项目名称:CryGame,代码行数:29,代码来源:AnimatedCharacterSample.cpp

示例5: SynchedNewIndexFunction

int CScriptRMI::SynchedNewIndexFunction( IFunctionHandler* pH )
{
	if (!m_pThis->m_pParent)
	{
		pH->GetIScriptSystem()->RaiseError( "Trying to set a synchronized variable with no game started... failing" );
		return pH->EndFunction();
	}

	SmartScriptTable table;
	SmartScriptTable hidden;
	const char * key;
	ScriptAnyValue value;

	if (!pH->GetParam( 1, table ))
		return pH->EndFunction(false);

	ScriptHandle id;
	if (!table->GetValue( ID_FIELD, id ))
		return pH->EndFunction(false);
	if (!table->GetValue( HIDDEN_FIELD, hidden ))
		return pH->EndFunction(false);

	if (!pH->GetParam( 2, key ))
		return pH->EndFunction(false);
	if (!pH->GetParamAny( 3, value ))
		return pH->EndFunction(false);

	hidden->SetValueAny( key, value );

	m_pThis->m_pParent->ChangedScript((EntityId) id.n );

	return pH->EndFunction( true );
}
开发者ID:aronarts,项目名称:FireNET,代码行数:33,代码来源:ScriptRMI.cpp

示例6: Init

//------------------------------------------------------------------------
bool CVehicleActionEntityAttachment::Init(IVehicle* pVehicle, const SmartScriptTable &table)
{
	m_pVehicle = pVehicle;

	SmartScriptTable entityAttachmentTable;
	if (!table->GetValue("EntityAttachment", entityAttachmentTable))
		return false;

	char* pHelperName;
	if (entityAttachmentTable->GetValue("helper", pHelperName))
		m_pHelper = m_pVehicle->GetHelper(pHelperName);

	char* pEntityClassName;
	if (entityAttachmentTable->GetValue("class", pEntityClassName))
	{
		IEntityClassRegistry* pClassRegistry = gEnv->pEntitySystem->GetClassRegistry();
		assert(pClassRegistry);

		if (IEntityClass* pEntityClass = pClassRegistry->FindClass(pEntityClassName))
		{
			m_entityClassName = pEntityClassName;

			SpawnEntity();

			return true;
		}
	}

	return false;
}
开发者ID:mrwonko,项目名称:CrysisVR,代码行数:31,代码来源:VehicleActionEntityAttachment.cpp

示例7: SerializeFunction

int CScriptRMI::SerializeFunction( IFunctionHandler * pH, void * pBuffer, int nSize )
{
	SmartScriptTable serTable;
	ScriptHandle hdl;
	pH->GetParam( 1, serTable );
	pH->GetParam( 2, hdl );
	SSerializeFunctionParams * p = (SSerializeFunctionParams *) hdl.ptr;

	SSynchedPropertyInfo * pInfo = (SSynchedPropertyInfo *) pBuffer;
	int nProperties = nSize / sizeof(SSynchedPropertyInfo);

	if (p->ser.IsReading())
	{
		for (int i=0; i < nProperties; i++)
			if (!m_pThis->ReadValue( pInfo[i].name, pInfo[i].type, p->ser, serTable.GetPtr() ))
				return pH->EndFunction(false);
	}
	else
	{
		for (int i=0; i < nProperties; i++)
			if (!m_pThis->WriteValue( pInfo[i].name, pInfo[i].type, p->ser, serTable.GetPtr() ))
				return pH->EndFunction(false);
	}
	return pH->EndFunction(true);
}
开发者ID:aronarts,项目名称:FireNET,代码行数:25,代码来源:ScriptRMI.cpp

示例8: Init

//------------------------------------------------------------------------
bool CVehicleMovementWarrior::Init(IVehicle* pVehicle, const SmartScriptTable &table)
{
  SmartScriptTable hovercraftTable;
  if (!table->GetValue("Hovercraft", hovercraftTable))
    return false;

  if (!CVehicleMovementHovercraft::Init(pVehicle, hovercraftTable))
    return false;

  table->GetValue("maxThrustersDamaged", m_maxThrustersDamaged);
  table->GetValue("collapsedFeetAngle", m_collapsedFeetAngle);
  table->GetValue("collapsedLegAngle", m_collapsedLegAngle);
  table->GetValue("recoverTime", m_recoverTime);

  // save original thruster values
  m_thrustersInit.reserve(m_vecThrusters.size());

  for (TThrusters::iterator it=m_vecThrusters.begin(); it!=m_vecThrusters.end(); ++it)
  {
    m_thrustersInit.push_back( new SThruster(**it) );
  }

  m_pTurret = m_pVehicle->GetPart("turret1");
  m_pCannon = m_pVehicle->GetPart("cannon");
  m_pWing   = m_pVehicle->GetPart("generator");

	m_pPlatformPos = m_pVehicle->GetHelper("platform_pos");
  
  return true;
}
开发者ID:MrHankey,项目名称:destructionderby,代码行数:31,代码来源:VehicleMovementWarrior.cpp

示例9: GetTeamRadioTable

static bool GetTeamRadioTable(CGameRules *gr, const string &team_name, SmartScriptTable &out_table)
{
	if(!gr)
	{
		return false;
	}

	IScriptTable *pTable = gr->GetEntity()->GetScriptTable();

	if(!pTable)
	{
		return false;
	}

	SmartScriptTable pTeamRadio;

	if(!pTable->GetValue("teamRadio", pTeamRadio))
	{
		return false;
	}

	if(!pTeamRadio->GetValue(team_name, out_table))
	{
		return false;
	}

	return true;
}
开发者ID:Oliverreason,项目名称:bare-minimum-cryengine3,代码行数:28,代码来源:Radio.cpp

示例10: PatchInitialSetup

//-----------------------------------------------------------------------
void CItem::PatchInitialSetup()
{
	const char *temp = NULL;
	// check if the initial setup accessories has been overridden in the level
	SmartScriptTable props;

	if(GetEntity()->GetScriptTable() && GetEntity()->GetScriptTable()->GetValue("Properties", props))
	{
		if(props->GetValue("initialSetup",temp) && temp !=NULL && temp[0]!=0)
		{
			m_properties.initialSetup = temp;
		}
	}

	//Replace initial setup from weapon xml, with initial setup defined for the entity (if neccesary)
	if(!m_properties.initialSetup.empty())
	{
		m_initialSetup["default"].resize(0);

		//Different accessory names are separated by ","

		string::size_type lastPos = m_properties.initialSetup.find_first_not_of(",", 0);
		string::size_type pos = m_properties.initialSetup.find_first_of(",", lastPos);

		while(string::npos != pos || string::npos != lastPos)
		{
			//Add to initial setup
			const char *name = m_properties.initialSetup.substr(lastPos, pos - lastPos).c_str();
			m_initialSetup["default"].push_back(name);

			lastPos = m_properties.initialSetup.find_first_not_of(",", pos);
			pos = m_properties.initialSetup.find_first_of(",", lastPos);
		}
	}
}
开发者ID:super-nova,项目名称:NovaRepo,代码行数:36,代码来源:ItemAccessory.cpp

示例11: GetEntity

//------------------------------------------------------------------------
void CNetworkedPhysicsEntity::ReadPhysicsParams()
{
	SmartScriptTable pScriptTable = GetEntity()->GetScriptTable();
	if (pScriptTable)
	{
		SmartScriptTable pProperties;
		if (pScriptTable->GetValue("Properties", pProperties))
		{
			SmartScriptTable pPhysicsParams;
			if (pProperties->GetValue("Physics", pPhysicsParams))
			{
				CScriptSetGetChain chain(pPhysicsParams);
				chain.GetValue( "mass", m_physicsParams.mass );
				chain.GetValue( "density", m_physicsParams.density );
				chain.GetValue( "flags", m_physicsParams.nFlagsOR );
				chain.GetValue( "partid", m_physicsParams.nAttachToPart );
				chain.GetValue( "stiffness_scale", m_physicsParams.fStiffnessScale );
				chain.GetValue( "lod", m_physicsParams.nLod );

				if(!m_physicsParams.pBuoyancy)
				{
					m_physicsParams.pBuoyancy = new pe_params_buoyancy();
				}
				chain.GetValue( "water_damping", m_physicsParams.pBuoyancy->waterDamping );
				chain.GetValue( "water_resistance", m_physicsParams.pBuoyancy->waterResistance );
				chain.GetValue( "water_density", m_physicsParams.pBuoyancy->waterDensity );

				m_physicsParams.type = PE_RIGID;

				return;
			}
		}
	}
	CRY_ASSERT(!"Failed to read physics params from script for NetworkedPhysicsEntity");
}
开发者ID:Xydrel,项目名称:Infected,代码行数:36,代码来源:NetworkedPhysicsEntity.cpp

示例12: Init

//------------------------------------------------------------------------
bool CVehicleActionDeployRope::Init(IVehicle* pVehicle, TVehicleSeatId seatId, const SmartScriptTable &table)
{
	m_pVehicle = pVehicle;
	m_seatId = seatId;

	SmartScriptTable deployRopeTable;
	if (!table->GetValue("DeployRope", deployRopeTable))
		return false;

	char* pHelperName;
	if (deployRopeTable->GetValue("helper", pHelperName))
		m_pRopeHelper = m_pVehicle->GetHelper(pHelperName);

	char* pAnimName;
	if (deployRopeTable->GetValue("animation", pAnimName))
	{
		m_pDeployAnim = m_pVehicle->GetAnimation(pAnimName);

		if (m_pDeployAnim)
		{
			m_deployAnimOpenedId = m_pDeployAnim->GetStateId("opened");
			m_deployAnimClosedId = m_pDeployAnim->GetStateId("closed");

			if (m_deployAnimOpenedId == InvalidVehicleAnimStateId 
				|| m_deployAnimClosedId == InvalidVehicleAnimStateId)
			{
				m_pDeployAnim = NULL;
			}
		}
	}

	return m_pRopeHelper != NULL;
}
开发者ID:MrHankey,项目名称:destructionderby,代码行数:34,代码来源:VehicleActionDeployRope.cpp

示例13: while

bool CMultipleGrabHandler::SetGrab(SmartScriptTable &rParams)
{
	// NOTE Mrz 20, 2007: <pvl> if we don't find 'params' param in the table,
	// we assume that this is an old-style grab param table that's not aware of
	// the possibility of multiple objects grabbed simultaneously.  

	SmartScriptTable grabParamsTable;
	if (rParams->GetValue("params",grabParamsTable))
	{
		bool result = true;

		IScriptTable::Iterator iter = grabParamsTable->BeginIteration();

		while(grabParamsTable->MoveNext(iter))
		{
			CAnimatedGrabHandler * handler = new CAnimatedGrabHandler (m_pActor);
			SmartScriptTable params;
			iter.value.CopyTo (params);
			result = handler->SetGrab(params) & result;
			m_handlers.push_back (handler);
		}

		grabParamsTable->EndIteration(iter);

		return result;
	}
	else
	{
		CAnimatedGrabHandler * handler = new CAnimatedGrabHandler (m_pActor);
		m_handlers.push_back (handler);
		return handler->SetGrab(rParams);
	}
}
开发者ID:AiYong,项目名称:CryGame,代码行数:33,代码来源:GrabHandler.cpp

示例14: synchedTable

// add a synch proxy table to an entity
void CScriptRMI::AddSynchedTable( IScriptTable * pEntityTable, 
																  ScriptHandle id,
																  const char * name, SmartScriptTable dispatchTable )
{
	SmartScriptTable synchedTable( pEntityTable->GetScriptSystem() );
	SmartScriptTable hiddenTable( pEntityTable->GetScriptSystem() );
	SmartScriptTable origTable;
	pEntityTable->GetValue( name, origTable );

	hiddenTable->Clone( dispatchTable );
	hiddenTable->SetValue( "__index", hiddenTable );

	IScriptTable::Iterator iter = origTable->BeginIteration();
	while (origTable->MoveNext(iter))
	{
		if (iter.sKey)
		{
			if (hiddenTable->GetValueType( iter.sKey ) != svtNull)
				GameWarning( "Replacing non-null value %s", iter.sKey );

			ScriptAnyValue value;
			origTable->GetValueAny( iter.sKey, value );
			hiddenTable->SetValueAny( iter.sKey, value );
		}
	}
	origTable->EndIteration(iter);

	synchedTable->Delegate( hiddenTable );
	synchedTable->SetValue( ID_FIELD, id );
	synchedTable->SetValue( HIDDEN_FIELD, hiddenTable );
	pEntityTable->SetValue( name, synchedTable );
}
开发者ID:aronarts,项目名称:FireNET,代码行数:33,代码来源:ScriptRMI.cpp

示例15: Prologue

	bool Prologue( EntityId objID, bool bClient, uint8 funcID )
	{
		if (!InitGameMembers(objID))
			return false;

		SmartScriptTable dispatchTable;
		if (!m_pScriptTable->GetValue( bClient? CLIENT_DISPATCH_FIELD : SERVER_DISPATCH_FIELD, dispatchTable))
			return false;

		const char * funcData;
		if (!dispatchTable->GetAt( funcID+1, funcData ))
		{
			GameWarning( "No such function dispatch index %d on entity %s (class %s)", funcID,
				m_pEntity->GetName(), m_pEntity->GetClass()->GetName() );
			return false;
		}

		const char * colon = strchr(funcData, ':');
		if (colon == NULL)
			return false;
		if (colon - funcData > BUFFER)
			return false;
		memcpy( m_function, funcData, colon-funcData );
		m_function[colon-funcData] = 0;
		m_format = colon + 1;
		return true;
	}
开发者ID:aronarts,项目名称:FireNET,代码行数:27,代码来源:ScriptRMI.cpp


注:本文中的SmartScriptTable类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。