本文整理汇总了C++中IEntityClass类的典型用法代码示例。如果您正苦于以下问题:C++ IEntityClass类的具体用法?C++ IEntityClass怎么用?C++ IEntityClass使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了IEntityClass类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetEntityType
EEntityType GetEntityType(EntityId id)
{
int type = eET_Unknown;
IEntitySystem *pEntitySystem = gEnv->pEntitySystem;
if (pEntitySystem)
{
IEntity *pEntity = pEntitySystem->GetEntity(id);
if (pEntity)
{
type = eET_Valid;
IEntityClass *pClass = pEntity->GetClass();
if (pClass)
{
const char* className = pClass->GetName();
// Check AI
if (pEntity->GetAI())
{
type |= eET_AI;
}
// Check actor
IActorSystem *pActorSystem = gEnv->pGame->GetIGameFramework()->GetIActorSystem();
if (pActorSystem)
{
IActor *pActor = pActorSystem->GetActor(id);
if (pActor)
{
type |= eET_Actor;
}
}
// Check vehicle
IVehicleSystem *pVehicleSystem = gEnv->pGame->GetIGameFramework()->GetIVehicleSystem();
if (pVehicleSystem)
{
if (pVehicleSystem->IsVehicleClass(className))
{
type |= eET_Vehicle;
}
}
// Check item
IItemSystem *pItemSystem = gEnv->pGame->GetIGameFramework()->GetIItemSystem();
if (pItemSystem)
{
if (pItemSystem->IsItemClass(className))
{
type |= eET_Item;
}
}
}
}
}
return (EEntityType)type;
}
示例2: GetActor
//------------------------------------------------------------------------
int CScriptBind_Actor::AddInventoryAmmo(IFunctionHandler *pH, const char *ammo, int amount)
{
CActor * pActor = GetActor(pH);
if (!pActor)
return pH->EndFunction();
IInventory *pInventory=pActor->GetInventory();
if (!pInventory)
return pH->EndFunction();
IEntityClass* pClass = gEnv->pEntitySystem->GetClassRegistry()->FindClass(ammo);
assert(pClass);
int capacity = pInventory->GetAmmoCapacity(pClass);
int current = pInventory->GetAmmoCount(pClass);
if((!gEnv->pSystem->IsEditor()) && (amount > capacity))
{
if(pActor->IsClient())
SAFE_HUD_FUNC(DisplayFlashMessage("@ammo_maxed_out", 2, ColorF(1.0f, 0,0), true, (string("@")+pClass->GetName()).c_str()));
//If still there's some place, full inventory to maximum...
if(current<capacity)
{
pInventory->SetAmmoCount(pClass,capacity);
if(pActor->IsClient() && capacity - current > 0)
{
/*char buffer[5];
itoa(capacity - current, buffer, 10);
SAFE_HUD_FUNC(DisplayFlashMessage("@grab_ammo", 3, Col_Wheat, true, (string("@")+pClass->GetName()).c_str(), buffer));*/
if(g_pGame->GetHUD())
g_pGame->GetHUD()->DisplayAmmoPickup(pClass->GetName(), capacity - current);
}
if (gEnv->bServer)
pActor->GetGameObject()->InvokeRMI(CActor::ClAddAmmo(), CActor::AmmoParams(ammo, amount), eRMI_ToRemoteClients);
}
}
else
{
pInventory->SetAmmoCount(pClass, amount);
if(pActor->IsClient() && amount - current > 0)
{
/*char buffer[5];
itoa(amount - current, buffer, 10);
SAFE_HUD_FUNC(DisplayFlashMessage("@grab_ammo", 3, Col_Wheat, true, (string("@")+pClass->GetName()).c_str(), buffer));*/
if(g_pGame->GetHUD())
g_pGame->GetHUD()->DisplayAmmoPickup(pClass->GetName(), amount - current);
}
if (gEnv->bServer)
pActor->GetGameObject()->InvokeRMI(CActor::ClAddAmmo(), CActor::AmmoParams(ammo, amount), eRMI_ToRemoteClients);
}
return pH->EndFunction();
}
示例3: GetOwnerActor
bool CJaw::OutOfAmmo(bool allFireModes) const
{
CActor* pOwner = GetOwnerActor();
IInventory* pOwnerInventory = pOwner ? pOwner->GetInventory() : 0;
if (!pOwnerInventory)
return true;
IEntityClass* pJawClass = GetEntity()->GetClass();
IItemSystem* pItemSystem = gEnv->pGame->GetIGameFramework()->GetIItemSystem();
int jawUniqueId = pItemSystem->GetItemUniqueId(pJawClass->GetName());
int currentNumJaws = pOwnerInventory->GetCountOfUniqueId(jawUniqueId);
return currentNumJaws == 0;
}
示例4: GetEntity
bool CJaw::GiveExtraTubeToInventory(IActor* pPickerActor, IItemSystem* pItemSystem) const
{
if (m_weaponsharedparams->ammoParams.extraItems == 0 || !pPickerActor->IsPlayer())
return false;
if (m_extraTubesAdded)
return false;
IEntityClass* pJawClass = GetEntity()->GetClass();
IInventory* pPickerInventory = pPickerActor ? pPickerActor->GetInventory() : 0;
int jawUniqueId = pItemSystem->GetItemUniqueId(pJawClass->GetName());
int currentNumJaws = pPickerInventory ? pPickerInventory->GetCountOfUniqueId(jawUniqueId) : 0;
bool giveExtraTube = (currentNumJaws == 0);
return giveExtraTube;
}
示例5: execute
void execute(CItem *_this)
{
CShotgun *fm = (CShotgun *)pWep->GetFireMode(pWep->GetCurrentFireMode());
if(fm->m_reload_was_broken)
return;
IEntityClass *pAmmoType = fm->GetAmmoType();
if(pWep->IsServer())
{
const int ammoCount = pWep->GetAmmoCount(pAmmoType);
const int inventoryCount = pWep->GetInventoryAmmoCount(pAmmoType);
const int refill = fm->m_pShared->shotgunparams.partial_reload ? 1 : min(inventoryCount, fm->GetClipSize() - ammoCount);
pWep->SetAmmoCount(pAmmoType, ammoCount + refill);
pWep->SetInventoryAmmoCount(pAmmoType, pWep->GetInventoryAmmoCount(pAmmoType) - refill);
}
g_pGame->GetIGameFramework()->GetIGameplayRecorder()->Event(pWep->GetOwner(), GameplayEvent(eGE_WeaponReload, pAmmoType->GetName(), 1, (void *)(pWep->GetEntityId())));
if(!fm->m_break_reload)
fm->ReloadShell(rzoomed);
else
fm->EndReload(rzoomed);
}
示例6: ResetClient
void CEditorGame::ResetClient(IConsoleCmdArgs*)
{
bool value = s_pEditorGame->m_bPlayer;
s_pEditorGame->EnablePlayer(false);
IEntityClass *pClass = gEnv->pEntitySystem->GetClassRegistry()->FindClass("Player");
if (pClass) pClass->LoadScript(true);
if (value)
{
s_pEditorGame->ConfigureNetContext(true);
SetGameRules();
}
s_pEditorGame->EnablePlayer(value);
s_pEditorGame->HidePlayer(true);
}
示例7: ToggleMultiplayerGameRules
//------------------------------------------------------------------------
void CEditorGame::ToggleMultiplayerGameRules()
{
m_bUsingMultiplayerGameRules = !m_bUsingMultiplayerGameRules;
bool value = s_pEditorGame->m_bPlayer;
s_pEditorGame->EnablePlayer(false);
s_pEditorGame->ConfigureNetContext(true);
IEntityClass *pClass = gEnv->pEntitySystem->GetClassRegistry()->FindClass("Player");
if (pClass)
{
pClass->LoadScript(true);
}
SetGameRules();
s_pEditorGame->EnablePlayer(value);
s_pEditorGame->HidePlayer(true);
gEnv->pConsole->ShowConsole(false);
}
示例8: ResetClient
void CEditorGame::ResetClient(IConsoleCmdArgs*)
{
g_pGame->ReloadPlayerParamFiles();
bool value = s_pEditorGame->m_bPlayer;
s_pEditorGame->EnablePlayer(false);
IEntityClass *pClass = gEnv->pEntitySystem->GetClassRegistry()->FindClass("Player");
if (pClass) pClass->LoadScript(true);
if (value)
{
s_pEditorGame->ConfigureNetContext(true);
const char *pGameRulesName = GetGameRulesName();
s_pEditorGame->m_pGame->GetIGameFramework()->GetIGameRulesSystem()->CreateGameRules(pGameRulesName);
}
s_pEditorGame->EnablePlayer(value);
s_pEditorGame->HidePlayer(true);
}
示例9: assert
bool CEntityClassRegistry::RegisterEntityClass( IEntityClass *pClass )
{
assert( pClass != NULL );
bool newClass = false;
if ((pClass->GetFlags() & ECLF_MODIFY_EXISTING) == 0)
{
IEntityClass *pOldClass = FindClass(pClass->GetName());
if (pOldClass)
{
EntityWarning( "CEntityClassRegistry::RegisterEntityClass failed, class with name %s already registered",
pOldClass->GetName() );
return false;
}
newClass = true;
}
m_mapClassName[pClass->GetName()] = pClass;
NotifyListeners(newClass ? ECRE_CLASS_REGISTERED : ECRE_CLASS_MODIFIED, pClass);
return true;
}
示例10: SetGameObject
bool CMonoEntityExtension::Init(IGameObject *pGameObject)
{
SetGameObject(pGameObject);
pGameObject->EnablePhysicsEvent( true, eEPE_OnPostStepImmediate );
if (!GetGameObject()->BindToNetwork())
return false;
IEntity *pEntity = GetEntity();
IEntityClass *pEntityClass = pEntity->GetClass();
m_pScript = g_pScriptSystem->InstantiateScript(pEntityClass->GetName(), eScriptFlag_Entity);
IMonoClass *pEntityInfoClass = g_pScriptSystem->GetCryBraryAssembly()->GetClass("EntityInitializationParams", "CryEngine.Native");
SMonoEntityInfo entityInfo(pEntity);
IMonoArray *pArgs = CreateMonoArray(1);
pArgs->InsertMonoObject(pEntityInfoClass->BoxObject(&entityInfo));
g_pScriptSystem->InitializeScriptInstance(m_pScript, pArgs);
pArgs->Release();
int numProperties;
auto pProperties = static_cast<CEntityPropertyHandler *>(pEntityClass->GetPropertyHandler())->GetQueuedProperties(pEntity->GetId(), numProperties);
if(pProperties)
{
for(int i = 0; i < numProperties; i++)
{
auto queuedProperty = pProperties[i];
SetPropertyValue(queuedProperty.propertyInfo, queuedProperty.value.c_str());
}
}
m_bInitialized = true;
return true;
}
示例11: InitEntityClassesEnums
void CEditorGame::InitEntityClassesEnums(IGameToEditorInterface* pGTE)
{
// init ActionFilter enums
gEnv->pEntitySystem->GetClassRegistry()->IteratorMoveFirst();
IEntityClass* entClass = gEnv->pEntitySystem->GetClassRegistry()->IteratorNext();
const char** allEntities = new const char*[gEnv->pEntitySystem->GetClassRegistry()->GetClassCount()+2];
allEntities[0] = "AllClasses";
allEntities[1] = "CustomClasses";
unsigned int numEnts = 2;
while (entClass)
{
const char* classname = entClass->GetName();
allEntities[numEnts++] = classname;
entClass = gEnv->pEntitySystem->GetClassRegistry()->IteratorNext();
}
pGTE->SetUIEnums("entity_classes", allEntities, numEnts);
delete[] allEntities;
}
示例12: CryWarning
// ===========================================================================
// Cache the resources of an actor class (pre-load them).
//
// In: The LUA function handler.
// In: The name of the actor entity class that we should pre-load
// (case-sensitive) (NULL is invalid!)
//
int CScriptBind_Game::CacheActorClassResources(IFunctionHandler *pH, const char* actorEntityClassName)
{
if (actorEntityClassName == NULL)
{
CryWarning(VALIDATOR_MODULE_GAME, VALIDATOR_WARNING,
"CacheActorClassResources(): Invalid entity actor class name!");
}
else
{
IEntityClass* entityClass = gEnv->pEntitySystem->GetClassRegistry()->FindClass(actorEntityClassName);
if (entityClass == NULL)
{
CryWarning(VALIDATOR_MODULE_GAME, VALIDATOR_WARNING,
"CacheActorClassResources(): Unable to cache entity actor class resource '%s'!", actorEntityClassName);
}
else
{
g_pGame->GetGameCache().CacheActorClass(entityClass, entityClass->GetScriptTable());
}
}
return pH->EndFunction();
}
示例13: GetEntity
void CVicinityDependentObjectMover::ActivateOutputPortBool( const char* szPortName )
{
IEntity* pEntity = GetEntity();
CRY_ASSERT( pEntity );
IEntityClass::SEventInfo eventInfo;
IEntityClass *pEntityClass = pEntity->GetClass();
if ( pEntityClass->FindEventInfo( szPortName,eventInfo ) )
{
SEntityEvent event( ENTITY_EVENT_SCRIPT_EVENT );
event.nParam[0] = (INT_PTR)szPortName;
event.nParam[1] = IEntityClass::EVT_BOOL;
bool bValue = true;
event.nParam[2] = (INT_PTR)&bValue;
GetEntity()->SendEvent( event );
}
else
{
GameWarning( "CVicinityDependentObjectMover::ActivateOutputPortBool: Called with undefined port %s", szPortName );
}
}
示例14: FUNCTION_PROFILER
void CScriptProxy::Reload( IEntity* pEntity,SEntitySpawnParams ¶ms )
{
FUNCTION_PROFILER( GetISystem(), PROFILE_ENTITY );
IEntityClass* pClass = (pEntity ? pEntity->GetClass() : NULL);
CEntityScript* pEntityScript = (pClass ? (CEntityScript*)pClass->GetIEntityScript() : NULL);
if (pEntityScript && pEntityScript->LoadScript())
{
// Release current
SAFE_RELEASE(m_pThis);
m_pEntity = (CEntity*)pEntity;
m_pScript = pEntityScript;
m_nCurrStateId = 0;
m_fScriptUpdateRate = 0;
m_fScriptUpdateTimer = 0;
m_bEnableSoundAreaEvents = false;
m_bUpdateScript = CurrentState()->IsStateFunctionImplemented(ScriptState_OnUpdate);
// New object must be created here.
CreateScriptTable(¶ms);
}
}
示例15: if
//-----------------------------------------------------
void CThrow::ThrowGrenade()
{
//Grenade speed scale is always one (for player)
CPlayer *pPlayer = static_cast<CPlayer *>(m_pWeapon->GetOwnerActor());
if(pPlayer)
{
if(pPlayer->IsPlayer())
{
m_speed_scale = 1.0f;
}
else if(pPlayer->GetHealth() <= 0 || pPlayer->GetGameObject()->GetAspectProfile(eEA_Physics) == eAP_Sleep)
{
return; //Do not throw grenade is player is death (AI "ghost grenades")
}
//Hide grenade in hand (FP)
if(pPlayer->IsClient() && m_pWeapon->GetEntity()->GetClass() == CItem::sOffHandClass)
{
if(COffHand *pOffHand = static_cast<COffHand *>(m_pWeapon))
{
pOffHand->AttachGrenadeToHand(pOffHand->GetCurrentFireMode());
}
}
}
m_pWeapon->SetBusy(false);
Shoot(true);
m_pWeapon->SetBusy(true);
// Luciano - send ammo count game event
if(pPlayer)
{
IEntityClass *pAmmo = m_pShared->fireparams.ammo_type_class;
if(pAmmo)
{
int ammoCount = pPlayer->GetInventory()->GetAmmoCount(pAmmo);
g_pGame->GetIGameFramework()->GetIGameplayRecorder()->Event(pPlayer->GetEntity(), GameplayEvent(eGE_AmmoCount, m_pWeapon->GetEntity()/*->GetClass()*/->GetName(), float(ammoCount), (void *)(pAmmo->GetName())));
}
}
}