void CItemComponent::GetSharedParameters(XmlNodeRef rootParams) { // Parameters get stored under a combination of the class name and the section name for the parameters. CryFixedStringT<256> sharedName; sharedName.Format("item::%s::%s", GetEntity()->GetClass()->GetName(), "itemBase"); ISharedParamsManager* pSharedParamsManager = gEnv->pGameFramework->GetISharedParamsManager(); CRY_ASSERT(pSharedParamsManager); m_itemBaseParameter = CastSharedParamsPtr<SItemBaseParameter>(pSharedParamsManager->Get(sharedName)); // If no parameter set exists we should attempt to create and register one. if (!m_itemBaseParameter) { SItemBaseParameter sharedParams; // Load in the base item shared parameters. XmlNodeRef itemBaseParams = rootParams->findChild("itemBase"); if (itemBaseParams) sharedParams.Read(itemBaseParams); // Register a new set of parameters and retrieve a shared pointer to them. m_itemBaseParameter = CastSharedParamsPtr<SItemBaseParameter>(pSharedParamsManager->Register(sharedName, sharedParams)); } // Double check the shared parameter. CRY_ASSERT(m_itemBaseParameter.get()); }
void CPickAndThrowProxy::OnReloadExtension() { // Entity class could have changed, cache if we need reloading data ISharedParamsManager* pSharedParamsManager = gEnv->pGame->GetIGameFramework()->GetISharedParamsManager(); CRY_ASSERT(pSharedParamsManager); // Query if params have changed CryFixedStringT<64> sharedParamsName = GetSharedParamsName(); ISharedParamsConstPtr pSharedParams = pSharedParamsManager->Get(sharedParamsName); m_bNeedsReloading = m_pParams != pSharedParams; }
//------------------------------------------------------------------------ bool CVehicleDamageBehaviorEffect::Init(IVehicle *pVehicle, const CVehicleParams &table) { m_pVehicle = pVehicle; m_pDamageEffect = NULL; m_slot = -1; CVehicleParams effectParams = table.findChild("Effect"); if(!effectParams) { return false; } string effectName = effectParams.getAttr("effect"); CryFixedStringT<256> sharedParamsName; sharedParamsName.Format("%s::DamageBehaviorEffect::%s", pVehicle->GetEntity()->GetClass()->GetName(), effectName.c_str()); ISharedParamsManager *pSharedParamsManager = CCryAction::GetCryAction()->GetISharedParamsManager(); CRY_ASSERT(pSharedParamsManager); m_pSharedParams = CastSharedParamsPtr<SSharedParams>(pSharedParamsManager->Get(sharedParamsName)); if(!m_pSharedParams) { SSharedParams sharedParams; sharedParams.effectName = effectName; sharedParams.damageRatioMin = 1.0f; sharedParams.updateFromHelper = false; table.getAttr("damageRatioMin", sharedParams.damageRatioMin); sharedParams.disableAfterExplosion = false; effectParams.getAttr("disableAfterExplosion", sharedParams.disableAfterExplosion); effectParams.getAttr("updateFromHelper", sharedParams.updateFromHelper); m_pSharedParams = CastSharedParamsPtr<SSharedParams>(pSharedParamsManager->Register(sharedParamsName, sharedParams)); } CRY_ASSERT(m_pSharedParams.get()); return true; }
void CPickAndThrowProxy::ReadXmlData(const IItemParamsNode* pRootNode) { ISharedParamsManager* pSharedParamsManager = gEnv->pGame->GetIGameFramework()->GetISharedParamsManager(); CRY_ASSERT(pSharedParamsManager); // If we change the SharedParamsManager to accept CRCs on its interface we could compute this once and store // the name's CRC32 instead of constructing it here each time this method is invoked (it shouldn't be invoked // too often, though) CryFixedStringT<64> sharedParamsName = GetSharedParamsName(); ISharedParamsConstPtr pSharedParams = pSharedParamsManager->Get(sharedParamsName); if (pSharedParams) { m_pParams = CastSharedParamsPtr<SPnTProxyParams>(pSharedParams); } else { m_pParams.reset(); SPnTProxyParams newParams; const char* szProxyShape = pRootNode->GetAttribute("proxyShape"); if (szProxyShape) { if (strcmpi("capsule", szProxyShape) == 0) { newParams.proxyShape = ePS_Capsule; } else if (strcmpi("sphere", szProxyShape) == 0) { newParams.proxyShape = ePS_Sphere; } else if (strcmpi("cylinder", szProxyShape) == 0) { newParams.proxyShape = ePS_Cylinder; } } pRootNode->GetAttribute("proxyRadius", newParams.fRadius); pRootNode->GetAttribute("proxyHeight", newParams.fHeight); pRootNode->GetAttribute("proxyPivot", newParams.vPosPivot); m_pParams = CastSharedParamsPtr<SPnTProxyParams>(pSharedParamsManager->Register(sharedParamsName, newParams)); } }
//----------------------------------------------------------------------- void CSpectacularKill::ReadXmlData( const IItemParamsNode* pRootNode) { CRY_ASSERT(pRootNode); ISharedParamsManager* pSharedParamsManager = gEnv->pGame->GetIGameFramework()->GetISharedParamsManager(); CRY_ASSERT(pSharedParamsManager); // If we change the SharedParamsManager to accept CRCs on its interface we could compute this once and store // the name's CRC32 instead of constructing it here each time this method is invoked (it shouldn't be invoked // too often, though) const char* szEntityClassName = m_pOwner->GetEntityClassName(); CryFixedStringT<64> sharedParamsName; sharedParamsName.Format("%s_%s", SSharedSpectacularParams::s_typeInfo.GetName(), szEntityClassName); ISharedParamsConstPtr pSharedParams = pSharedParamsManager->Get(sharedParamsName); if (pSharedParams) { m_pParams = CastSharedParamsPtr<SSharedSpectacularParams>(pSharedParams); return; } m_pParams.reset(); const IItemParamsNode* pParams = pRootNode->GetChild("SpectacularKill"); if (pParams) { SSharedSpectacularParams newParams; const int childCount = pParams->GetChildCount(); newParams.paramsList.reserve(childCount); for (int i = 0; i < childCount; ++i) { const IItemParamsNode* pTargetParams = pParams->GetChild(i); CRY_ASSERT(pTargetParams); IEntityClass* pTargetClass = gEnv->pEntitySystem->GetClassRegistry()->FindClass(pTargetParams->GetName()); if (pTargetClass) { SSpectacularKillParams targetParams; const IItemParamsNode* pChildParamsNode = pTargetParams->GetChild("Params"); const IItemParamsNode* pChildAnimsNode = pTargetParams->GetChild("Anims"); targetParams.pEnemyClass = pTargetClass; if(pChildParamsNode) { pChildParamsNode->GetAttribute("impulseScale", targetParams.impulseScale); const char* szImpulseBone = pChildParamsNode->GetAttributeSafe("impulseBone"); ICharacterInstance* pCharacter = m_pOwner->GetEntity()->GetCharacter(0); targetParams.impulseBone = pCharacter ? pCharacter->GetIDefaultSkeleton().GetJointIDByName(szImpulseBone) : -1; } if(pChildAnimsNode) { const int animCount = pChildAnimsNode->GetChildCount(); targetParams.animations.reserve(animCount); for(int j = 0; j < animCount; j++) { const IItemParamsNode* pAnimNode = pChildAnimsNode->GetChild(j); if(pAnimNode) { SSpectacularKillAnimation newAnimation; newAnimation.victimAnimation = pAnimNode->GetAttributeSafe("victimAnimation"); newAnimation.killerAnimation = pAnimNode->GetAttributeSafe("killerAnimation"); pAnimNode->GetAttribute("optimalDist", newAnimation.optimalDist); if (pAnimNode->GetAttribute("targetToKillerAngle", newAnimation.targetToKillerAngle)) newAnimation.targetToKillerAngle = DEG2RAD(newAnimation.targetToKillerAngle); if (pAnimNode->GetAttribute("targetToKillerAngleRange", newAnimation.targetToKillerMinDot)) newAnimation.targetToKillerMinDot = cos_tpl(DEG2RAD(newAnimation.targetToKillerMinDot) / 2.0f); pAnimNode->GetAttribute("obstacleCheckStartOffset", newAnimation.vKillerObstacleCheckOffset); pAnimNode->GetAttribute("obstacleCheckLength", newAnimation.fObstacleCheckLength); targetParams.animations.push_back(newAnimation); } } } CRY_ASSERT_MESSAGE(targetParams.animations.size() > 0, string().Format("No Animations defined for %s spectacular kill", pTargetClass->GetName())); newParams.paramsList.push_back(targetParams); } #ifdef SPECTACULAR_KILL_DEBUG else { GameWarning("spectacular Kill: Couldn't find entity of class '%s', skipping", pTargetParams->GetName()); } #endif } m_pParams = CastSharedParamsPtr<SSharedSpectacularParams>(pSharedParamsManager->Register(sharedParamsName, newParams)); } }
//------------------------------------------------------------------------ bool CVehiclePartLight::Init(IVehicle* pVehicle, const CVehicleParams& table, IVehiclePart* parent, CVehicle::SPartInitInfo& initInfo, int partType) { if (!CVehiclePartBase::Init(pVehicle, table, parent, initInfo, eVPT_Light)) return false; float specularMul = 1.0f; m_light.m_nLightStyle = 0; m_light.SetPosition( Vec3(ZERO) ); m_light.m_fRadius = 5.0f; m_light.m_Flags |= DLF_DEFERRED_LIGHT; m_light.m_Flags &= ~DLF_DISABLED; if(CVehicleParams lightTable = table.findChild("Light")) { m_lightType = lightTable.getAttr("type"); ISharedParamsManager *pSharedParamsManager = CCryAction::GetCryAction()->GetISharedParamsManager(); CRY_ASSERT(pSharedParamsManager); SVehicleLightParamsConstPtr pVehicleLightParams = CastSharedParamsPtr<SVehicleLightParams>(pSharedParamsManager->Get(m_lightType.c_str())); if(!pVehicleLightParams) { pVehicleLightParams = LoadVehicleLightParams( pSharedParamsManager, m_lightType.c_str() ); } if(pVehicleLightParams) { m_light.m_fRadius = pVehicleLightParams->radius; m_diffuseCol = pVehicleLightParams->diffuse; m_diffuseMult[1] = pVehicleLightParams->diffuseMult; m_diffuseMult[0] = pVehicleLightParams->diffuseMult_fp; specularMul = pVehicleLightParams->specularMult; m_light.m_nLightStyle = pVehicleLightParams->style; m_light.m_fLightFrustumAngle = pVehicleLightParams->frustumAngle; m_light.m_fHDRDynamic = pVehicleLightParams->HDRDynamic; m_light.m_nLightPhase = pVehicleLightParams->animPhase; m_light.SetAnimSpeed(pVehicleLightParams->animSpeed); m_light.SetFalloffMax(pVehicleLightParams->falloff); m_lightViewDistanceRatio = pVehicleLightParams->viewDistanceRatio; if(pVehicleLightParams->castShadows > 0) { const ICVar* pLightSpec = gEnv->pConsole->GetCVar("sys_spec_light"); int configSpec = (pLightSpec != NULL) ? pLightSpec->GetIVal() : gEnv->pSystem->GetConfigSpec(true); // Treating consoles and custom as med spec for simplicity if(configSpec == CONFIG_CUSTOM) { configSpec = CONFIG_MEDIUM_SPEC; } if(pVehicleLightParams->castShadows <= configSpec) { m_light.m_Flags |= DLF_CASTSHADOW_MAPS; m_light.m_Flags &= ~DLF_HASCLIPBOUND; } } m_light.m_Flags = pVehicleLightParams->fakeLight ? m_light.m_Flags|DLF_FAKE : m_light.m_Flags&~DLF_FAKE; if (pVehicleLightParams->texture.empty() == false) { m_light.m_pLightImage = gEnv->pRenderer->EF_LoadTexture(pVehicleLightParams->texture.c_str(), FT_DONT_STREAM); } if (pVehicleLightParams->material.empty() == false) { m_pMaterial = gEnv->p3DEngine->GetMaterialManager()->LoadMaterial(pVehicleLightParams->material.c_str()); } if (pVehicleLightParams->flare.empty() == false) { int lensOpticsID = 0; if( gEnv->pOpticsManager->Load(pVehicleLightParams->flare.c_str(), lensOpticsID) ) { m_light.SetLensOpticsElement(gEnv->pOpticsManager->GetOptics(lensOpticsID)); int modularAngle = ((int)pVehicleLightParams->flareFOV)%360; if( modularAngle == 0 ) m_light.m_LensOpticsFrustumAngle = 255; else m_light.m_LensOpticsFrustumAngle = (uint8)(pVehicleLightParams->flareFOV*(255.0f/360.0f)); } if(m_pMaterial == NULL) { GameWarning("VehiclePartLight - Light uses flares, but it does not have a material. Flares won't work"); } } } } m_light.SetLightColor(ColorF(m_diffuseCol*m_diffuseMult[1], 1.f)); m_light.SetSpecularMult( specularMul / m_diffuseMult[1] ); if (m_light.m_fLightFrustumAngle && m_light.m_pLightImage && m_light.m_pLightImage->IsTextureLoaded()) { m_light.m_Flags |= DLF_PROJECT; } else { if (m_light.m_pLightImage) { m_light.m_pLightImage->Release(); m_light.m_pLightImage = 0; } m_light.m_Flags |= DLF_POINT; } return true; }