void CAnimatedCharacter::SetBlendWeightParam(const EMotionParamID motionParamID, const float value, const uint8 targetFlags/* = eBWPT_All*/) { if (motionParamID >= eMotionParamID_BlendWeight && motionParamID <= eMotionParamID_BlendWeight_Last) { //only allowed on the generic blend weights params IEntity* pEntity = GetEntity(); CRY_ASSERT(pEntity); if (targetFlags & eBWPT_FirstPersonSkeleton) { if (ICharacterInstance* pCharacterInstance = pEntity->GetCharacter(0)) { if (ISkeletonAnim* pSkeletonAnim = pCharacterInstance->GetISkeletonAnim()) { pSkeletonAnim->SetDesiredMotionParam(motionParamID, value, 0.0f); } } } if (targetFlags & eBWPT_ShadowSkeleton) { if (m_hasShadowCharacter) { if (ICharacterInstance* pShadowCharacter = pEntity->GetCharacter(m_shadowCharacterSlot)) { if (ISkeletonAnim* pShadowSkeletonAnim = pShadowCharacter->GetISkeletonAnim()) { pShadowSkeletonAnim->SetDesiredMotionParam(motionParamID, value, 0.0f); } } } } } else { CryLogAlways("[CryAnimation] ERROR: motionParam that was sent: %d is not within allowed range of blendweights %d to %d", motionParamID, eMotionParamID_BlendWeight, eMotionParamID_BlendWeight_Last); } }
void CHeavyMountedWeapon::Update( SEntityUpdateContext& ctx, int slot ) { BaseClass::Update(ctx, slot); if (m_rotatingSoundID!=INVALID_SOUNDID) { if (m_RotationSoundTimeOut>0) { m_RotationSoundTimeOut -= ctx.fFrameTime; RequireUpdate( eIUS_General ); } else { StopSound(m_rotatingSoundID); m_rotatingSoundID = INVALID_SOUNDID; } } // Helper for editor placing if (gEnv->IsEditing()) { // If host id is not 0, it means it is mounted to a vehicle, so don't render the helper in that case if (!GetHostId()) { IRenderAuxGeom* pRenderAux = gEnv->pRenderer->GetIRenderAuxGeom(); const Matrix34& weaponTM = GetEntity()->GetWorldTM(); const Vec3 point1 = weaponTM.GetTranslation(); const Vec3 point2 = point1 - (m_sharedparams->pMountParams->ground_distance * weaponTM.GetColumn2()); const Vec3 point3 = point2 - (m_sharedparams->pMountParams->body_distance * weaponTM.GetColumn1()); pRenderAux->DrawLine(point1, ColorB(0, 192, 0), point2, ColorB(0, 192, 0), 3.0f); pRenderAux->DrawLine(point2, ColorB(0, 192, 0), point3, ColorB(0, 192, 0), 3.0f); pRenderAux->DrawSphere(point3, 0.15f, ColorB(192, 0, 0)); RequireUpdate(eIUS_General); } } }
//----------------------------------------------------------------------- void CVehiclePartLight::UpdateLight(const float frameTime) { if (m_slot == -1) return; // move to vehicle event change view? if (m_diffuseMult[0] != m_diffuseMult[1]) { SEntitySlotInfo info; if (m_pVehicle->GetEntity()->GetSlotInfo(m_slot, info) && info.pLight) { CDLight& light = info.pLight->GetLightProperties(); IActor* pActor = CCryAction::GetCryAction()->GetClientActor(); bool localPlayer = (pActor != NULL) && (pActor->GetLinkedVehicle() == m_pVehicle); IVehicleSeat* pSeat = pActor ? m_pVehicle->GetSeatForPassenger(pActor->GetEntityId()) : NULL; IVehicleView* pView = pSeat? pSeat->GetView(pSeat->GetCurrentView()) : NULL; bool isThirdPersonView = pView? pView->IsThirdPerson() : true; if (localPlayer && !isThirdPersonView) light.SetLightColor(ColorF(m_diffuseCol * m_diffuseMult[0], 1.f)); else light.SetLightColor(ColorF(m_diffuseCol * m_diffuseMult[1], 1.f)); } } if (m_pHelper) { const static Matrix33 rot(Matrix33::CreateRotationXYZ(Ang3(0.f, 0.f, DEG2RAD(90.f)))); Matrix34 helperTM; m_pHelper->GetVehicleTM(helperTM); Matrix34 localTM = Matrix33(helperTM) * rot; localTM.SetTranslation(helperTM.GetTranslation()); GetEntity()->SetSlotLocalTM(m_slot, localTM); } }
//---------------------------------------------------- void CRocketLauncher::ActivateTPLaser(bool activate) { if(activate) { DrawSlot( eIGS_Aux1,true); ActivateLaserDot(true,false); m_laserTPOn = true; //Force first update m_lastUpdate = 0.0f; m_smoothLaserLength = -1.0f; UpdateTPLaser(0.0f); RequireUpdate(eIUS_General); } else { DrawSlot( eIGS_Aux1,false); GetEntity()->SetSlotLocalTM( eIGS_Aux1,Matrix34::CreateIdentity()); ActivateLaserDot(false,false); m_laserTPOn = false; } }
//------------------------------------------ bool CC4Projectile::Init(IGameObject *pGameObject) { bool ok = CProjectile::Init(pGameObject); // C4 should always be saved (unlike other projectiles) IEntity* pEntity = GetEntity(); pEntity->SetFlags(pEntity->GetFlags() & ~ENTITY_FLAG_NO_SAVE); if(!gEnv->bServer) { CreateLight(); } if(gEnv->bMultiplayer) { CGameRules *pGameRules = g_pGame->GetGameRules(); pGameRules->RegisterTeamChangedListener(this); pGameRules->RegisterClientConnectionListener(this); } return ok; }
void CMonoEntityExtension::FullSerialize(TSerialize ser) { IEntity *pEntity = GetEntity(); ser.BeginGroup("Properties"); auto pPropertyHandler = static_cast<CEntityPropertyHandler *>(pEntity->GetClass()->GetPropertyHandler()); for(int i = 0; i < pPropertyHandler->GetPropertyCount(); i++) { if(ser.IsWriting()) { IEntityPropertyHandler::SPropertyInfo propertyInfo; pPropertyHandler->GetPropertyInfo(i, propertyInfo); ser.Value(propertyInfo.name, pPropertyHandler->GetProperty(pEntity, i)); } else { IEntityPropertyHandler::SPropertyInfo propertyInfo; pPropertyHandler->GetPropertyInfo(i, propertyInfo); char *propertyValue = nullptr; ser.ValueChar(propertyInfo.name, propertyValue, 0); pPropertyHandler->SetProperty(pEntity, i, propertyValue); } } ser.EndGroup(); ser.BeginGroup("ManagedEntity"); IMonoArray *pArgs = CreateMonoArray(1); pArgs->InsertNativePointer(&ser); m_pScript->GetClass()->InvokeArray(m_pScript->GetManagedObject(), "InternalFullSerialize", pArgs); pArgs->Release(); ser.EndGroup(); }
void CFlyer::SetActorMovement(SMovementRequestParams& movementRequestParams) { SMovementState state; GetMovementController()->GetMovementState(state); if (movementRequestParams.vMoveDir.IsZero()) { Vec3 vDesiredDirection = movementRequestParams.vLookTargetPos.IsZero() ? GetEntity()->GetWorldRotation() * FORWARD_DIRECTION : (movementRequestParams.vLookTargetPos - state.eyePosition).GetNormalizedSafe(); SetDesiredDirection(vDesiredDirection); SetDesiredVelocity(Vec3Constants<float>::fVec3_Zero); } else { Vec3 vDesiredDirection = movementRequestParams.vLookTargetPos.IsZero() ? movementRequestParams.vMoveDir.GetNormalizedSafe() : (movementRequestParams.vLookTargetPos - state.eyePosition).GetNormalizedSafe(); SetDesiredDirection(vDesiredDirection); SetDesiredVelocity(movementRequestParams.vMoveDir * movementRequestParams.fDesiredSpeed); } }
void CBoundingContainer::ProcessEvent( SEntityEvent& entityEvent ) { switch(entityEvent.event) { case ENTITY_EVENT_RESET: { const bool bEnteringGameMode = ( entityEvent.nParam[ 0 ] == 1 ); Reset( bEnteringGameMode ); } break; case ENTITY_EVENT_START_LEVEL: // Need to wait till all entities are loaded since other entities can be inside { bool bHideContainedItemsOnStart = false; EntityScripts::GetEntityProperty(GetEntity(), "bHideContainedItemsOnStart", bHideContainedItemsOnStart); if (bHideContainedItemsOnStart && !gEnv->IsEditor()) { HideContainedItems(); } } break; } }
RodinBTNode::ETickStatus RodinBTNodePlayActions::Tick(float DeltaTime) { Unused(DeltaTime); WBEntity* const pEntity = GetEntity(); WBEvent BTNodePlayActionsEvent; STATIC_HASHED_STRING(BTNodePlayActionsEvent); BTNodePlayActionsEvent.SetEventName(sBTNodePlayActionsEvent); pEntity->AddContextToEvent(BTNodePlayActionsEvent); const uint NumActions = m_Actions.Size(); for (uint ActionIndex = 0; ActionIndex < NumActions; ++ActionIndex) { WBAction* const pAction = m_Actions[ActionIndex]; ASSERT(pAction); WBActionStack::Push(BTNodePlayActionsEvent); pAction->Execute(); WBActionStack::Pop(); } return ETS_Success; }
void CComponentVida::Decrease(float _fAmount) { if(m_fVida > 0.0f) { m_fTimeSinceHit = 0.0f; if(_fAmount < 0.0f) _fAmount *= -1; m_fVida -= _fAmount; if(m_fVida <= 0.f) { m_fVida = 0.0f; SEvent l_morir; l_morir.Msg = SEvent::MORIR; l_morir.Receiver = l_morir.Sender = GetEntity()->GetGUID(); CORE->GetEntityManager()->SendEvent(l_morir); } } }
bool Bot::IsFriendInLineOfFire (float distance) { // bot can't hurt teammates, if friendly fire is not enabled... if (!engine->IsFriendlyFireOn ()) return false; MakeVectors (pev->v_angle); TraceResult tr; TraceLine (EyePosition (), EyePosition () + pev->v_angle.Normalize () * distance, false, false, GetEntity (), &tr); // check if we hit something if (!FNullEnt (tr.pHit)) { int playerIndex = ENTINDEX (tr.pHit) - 1; // check valid range if (playerIndex >= 0 && playerIndex < engine->GetMaxClients () && g_clients[playerIndex].team == GetTeam (GetEntity ()) && (g_clients[playerIndex].flags & CFLAG_ALIVE)) return true; } // search the world for players for (int i = 0; i < engine->GetMaxClients (); i++) { if (!(g_clients[i].flags & CFLAG_USED) || !(g_clients[i].flags & CFLAG_ALIVE) || g_clients[i].team != GetTeam (GetEntity ()) || g_clients[i].ent == GetEntity ()) continue; edict_t *ent = g_clients[i].ent; float friendDistance = (GetEntityOrigin (ent) - pev->origin).GetLength (); float squareDistance = sqrtf (1089.0f + (friendDistance * friendDistance)); if ((GetShootingConeDeviation (GetEntity (), &GetEntityOrigin (ent))) > ((friendDistance * friendDistance) / (squareDistance * squareDistance)) && friendDistance <= distance) return true; } return false; }
bool Bot::IsGroupOfEnemies (Vector location, int numEnemies, int radius) { int numPlayers = 0; // search the world for enemy players... for (int i = 0; i < engine->GetMaxClients (); i++) { if (!(g_clients[i].flags & CFLAG_USED) || !(g_clients[i].flags & CFLAG_ALIVE) || g_clients[i].ent == GetEntity ()) continue; if ((GetEntityOrigin (g_clients[i].ent) - location).GetLength () < radius) { // don't target our teammates... if (g_clients[i].team == GetTeam (GetEntity ())) return false; if (numPlayers++ > numEnemies) return true; } } return false; }
//------------------------------------------------------------------------ void CVehiclePartEntity::UpdateEntity() { if(IEntity *pEntity = GetPartEntity()) { Matrix34 worldTM; if(m_pHelper) { m_pHelper->GetWorldTM(worldTM); } else if(IVehiclePart *pParent = GetParent()) { worldTM = pParent->GetWorldTM(); } else { worldTM = GetEntity()->GetWorldTM(); } pEntity->SetWorldTM(worldTM); } }
//================================================================================ // Update hitbox positions and visibility // This function can be very expensive, it should only be called for the active enemy. //================================================================================ void CEntityMemory::UpdateHitboxAndVisibility() { VPROF_BUDGET("CEntityMemory::UpdateHitboxAndVisibility", VPROF_BUDGETGROUP_BOTS_EXPENSIVE); // For now let's assume that we do not know Hitbox and therefore we have no vision UpdateVisibility(false); m_Hitbox.Reset(); m_VisibleHitbox.Reset(); // We obtain the positions of the Hitbox Utils::GetHitboxPositions(GetEntity(), m_Hitbox); if (!m_Hitbox.IsValid()) return; { VPROF_BUDGET("UpdateVisibility", VPROF_BUDGETGROUP_BOTS_EXPENSIVE); // Now let's check if we can see any of them if (m_pBot->GetDecision()->IsAbleToSee(m_Hitbox.head)) { m_VisibleHitbox.head = m_Hitbox.head; UpdateVisibility(true); } if (m_pBot->GetDecision()->IsAbleToSee(m_Hitbox.chest)) { m_VisibleHitbox.chest = m_Hitbox.chest; UpdateVisibility(true); } if (m_pBot->GetDecision()->IsAbleToSee(m_Hitbox.feet)) { m_VisibleHitbox.feet = m_Hitbox.feet; UpdateVisibility(true); } } // We update the ideal position GetVisibleHitboxPosition(m_vecIdealPosition, m_pBot->GetProfile()->GetFavoriteHitbox()); }
void CBoundingContainer::HideContainedItems() { IEntity* pEntity = GetEntity(); if (pEntity) { // Proximity query all entities in area AABB aabbBounds(m_vBoundingMin, m_vBoundingMax); OBB obbBounds; Matrix34 worldTM = pEntity->GetWorldTM(); obbBounds.SetOBBfromAABB(Matrix33(worldTM), aabbBounds); aabbBounds.Reset(); aabbBounds.SetAABBfromOBB(pEntity->GetWorldPos(), obbBounds); SEntityProximityQuery query; query.box = aabbBounds; gEnv->pEntitySystem->QueryProximity(query); const int iQueryCount = query.nCount; for (int i = 0; i < iQueryCount; ++i) { IEntity* pQueryEntity = query.pEntities[i]; if (pQueryEntity) { const EntityId queryEntityId = pQueryEntity->GetId(); if (!stl::find(m_hiddenEntities, queryEntityId)) // Only if not already hidden { // Make sure entity type should be hidden and entity pos is also inside, not just an intersection if (ShouldHide(queryEntityId, pQueryEntity) && aabbBounds.IsContainPoint(pQueryEntity->GetWorldPos())) { pQueryEntity->Hide(true); m_hiddenEntities.push_back(pQueryEntity->GetId()); } } } } } }
void CAICorpse::HandleEvent( const SGameObjectEvent& gameObjectEvent ) { if(gameObjectEvent.event == eCGE_ItemTakenFromCorpse) { assert(gameObjectEvent.param != NULL); bool matchFound = false; const EntityId itemId = *static_cast<const EntityId*>(gameObjectEvent.param); for (uint32 i = 0; i < m_attachedItemsInfo.size(); ++i) { if(m_attachedItemsInfo[i].id == itemId) { ICharacterInstance* pCharacter = GetEntity()->GetCharacter(0); if(pCharacter != NULL) { IAttachment* pAttachment = pCharacter->GetIAttachmentManager()->GetInterfaceByName( m_attachedItemsInfo[i].attachmentName.c_str() ); if(pAttachment != NULL) { pAttachment->ClearBinding(); } } m_attachedItemsInfo.removeAt(i); matchFound = true; break; } } if(matchFound) { if(m_attachedItemsInfo.empty()) { m_priority = 0; //Lower the priority once all attached items have been removed } } } }
//----------------------------------------------------------- /// The image from the texture atlas will have potentially /// been cropped by the tool. This will affect the sprites /// position within the uncropped image and we need to /// account for that when positioning the corners //----------------------------------------------------------- void SpriteComponent::UpdateVertexPositions() { Core::Vector2 frameCenter; Core::Vector2 frameSize; if(m_textureAtlas != nullptr && m_hashedTextureAtlasId > 0) { CalcFrameCentreAndSize(frameCenter, frameSize); } else if(mpMaterial != nullptr && mpMaterial->GetTexture() != nullptr) { auto texture = mpMaterial->GetTexture().get(); frameSize = m_sizePolicyDelegate(m_originalSize, Core::Vector2((f32)texture->GetWidth(), (f32)texture->GetHeight())); } const Core::Matrix4& worldTransform = GetEntity()->GetTransform().GetWorldTransform(); Core::Vector2 halfFrameSize(frameSize.x * 0.5f, frameSize.y * 0.5f); Core::Vector2 alignedPosition = -GetAnchorPoint(m_originAlignment, halfFrameSize); Core::Vector4 vertexCentre(alignedPosition.x + frameCenter.x, alignedPosition.y + frameCenter.y, 0.0f, 1.0f); //TL Core::Vector4 vertexOffset(-halfFrameSize.x, halfFrameSize.y, 0.0f, 0.0f); m_spriteData.sVerts[(u32)SpriteBatch::Verts::k_topLeft].vPos = (vertexCentre + vertexOffset) * worldTransform; //TR vertexOffset.x = halfFrameSize.x; vertexOffset.y = halfFrameSize.y; m_spriteData.sVerts[(u32)SpriteBatch::Verts::k_topRight].vPos = (vertexCentre + vertexOffset) * worldTransform; //BL vertexOffset.x = -halfFrameSize.x; vertexOffset.y = -halfFrameSize.y; m_spriteData.sVerts[(u32)SpriteBatch::Verts::k_bottomLeft].vPos = (vertexCentre + vertexOffset) * worldTransform; //BR vertexOffset.x = halfFrameSize.x; vertexOffset.y = -halfFrameSize.y; m_spriteData.sVerts[(u32)SpriteBatch::Verts::k_bottomRight].vPos = (vertexCentre + vertexOffset) * worldTransform; }
//------------------------------------------------------------------------ void CProjectile::SetParams(EntityId ownerId, EntityId hostId, EntityId weaponId, int damage, int hitTypeId, float damageDrop /*= 0.0f*/, float damageDropMinR /*=0.0f*/) { m_ownerId = ownerId; m_weaponId = weaponId; m_hostId = hostId; m_damage = damage; m_hitTypeId = hitTypeId; m_damageDropPerMeter = damageDrop; m_damageDropMinDisSqr = damageDropMinR*damageDropMinR; if (m_hostId || m_ownerId) { IEntity* pSelfEntity = GetEntity(); if (pSelfEntity) pSelfEntity->AddEntityLink("Shooter", m_ownerId); IEntity *pEntity = gEnv->pEntitySystem->GetEntity(m_hostId?m_hostId:m_ownerId); if (pEntity) { if (pSelfEntity) { //need to set AI species to the shooter - not to be scared of it's own rockets IAIObject* projectileAI = pSelfEntity->GetAI(); IAIObject* shooterAI = pEntity->GetAI(); if (projectileAI && shooterAI) projectileAI->SetFactionID(shooterAI->GetFactionID()); } if (m_pPhysicalEntity && m_pPhysicalEntity->GetType()==PE_PARTICLE) { pe_params_particle pparams; pparams.pColliderToIgnore = pEntity->GetPhysics(); m_pPhysicalEntity->SetParams(&pparams); } } } }
void CFlyer::PrePhysicsUpdate() { if(m_stats.isRagDoll) return; if(GetHealth() <= 0.f) return; IEntity *pEntity = GetEntity(); if(pEntity->IsHidden()) return; if(IPhysicalEntity *pPhysicalEntity = pEntity->GetPhysics()) { pe_player_dynamics player_dynamics; player_dynamics.gravity.zero(); pPhysicalEntity->SetParams(&player_dynamics); } float frameTime = gEnv->pTimer->GetFrameTime(); if(m_pMovementController) { SActorFrameMovementParams params; m_pMovementController->Update(frameTime, params); } if(m_linkStats.CanMove() && m_linkStats.CanRotate()) { ProcessMovement(frameTime); if(m_pAnimatedCharacter) { m_pAnimatedCharacter->AddMovement(m_moveRequest); } } }
int CScriptBind_Boids::SetFlockParams(IFunctionHandler *pH,SmartScriptTable entity,SmartScriptTable paramTable) { CFlock *flock = GetFlock(entity); if (!flock) return pH->EndFunction(); string currModel = flock->GetModelName(); int currCount = flock->GetBoidsCount(); SBoidContext bc; flock->GetBoidSettings(bc); SBoidsCreateContext ctx; if (ReadParamsTable( paramTable,bc,ctx )) { flock->SetBoidSettings( bc ); string model = ""; if (!ctx.models.empty()) model = ctx.models[0]; if ((!model.empty() && stricmp(model.c_str(),currModel.c_str()) == 0) || (ctx.boidsCount > 0 && ctx.boidsCount != currCount)) { flock->CreateBoids( ctx ); } } IEntity *pEntity = GetEntity(entity); if (pEntity) { CBoidsProxy *pBoidsProxy = (CBoidsProxy*)pEntity->GetProxy(ENTITY_PROXY_BOIDS); if (pBoidsProxy) { // Update pBoidsProxy->SetFlock(flock); } } return pH->EndFunction(); }
int XENTITYS::Ref2Entity( const char* estr, char* str, int strlen ) { char* pes = (char*)estr; char* ps = str; char* ps_end = ps+strlen; while( pes && *pes && ps < ps_end ) { XENTITY *ent = GetEntity( pes ); if( ent ) { // copy entity meanning char *ps = ent->entity; pes += ent->ref_len; } else *ps = *pes++; // default character copy ps++; } *ps = '\0'; // total copied characters return ps-str; }
int _tagXMLEntitys::Ref2Entity( LPCTSTR estr, LPTSTR str, int strlen ) { LPTSTR pes = (LPTSTR)estr; LPTSTR ps = str; LPTSTR ps_end = ps+strlen; while( pes && *pes && ps < ps_end ) { LPXENTITY ent = GetEntity( pes ); if( ent ) { // copy entity meanning char *ps = ent->entity; pes += ent->ref_len; } else *ps = *pes++; // default character copy ps++; } *ps = '\0'; // total copied characters return ps-str; }
//------------------------------------------------------------------------ void CItem::StopLayer(const ItemString& layerName, int flags, bool record) { TLayerMap::iterator it = m_sharedparams->layers.find(CONST_TEMPITEM_STRING(layerName)); if (it == m_sharedparams->layers.end()) return; for (int i=0; i<eIGS_Last; i++) { if (!(flags&1<<i)) continue; ICharacterInstance *pCharacter = GetEntity()->GetCharacter(i); if (pCharacter) pCharacter->GetISkeletonAnim()->StopAnimationInLayer(it->second.id[i],0.0f); } if (record) { TActiveLayerMap::iterator ait = m_activelayers.find(CONST_TEMPITEM_STRING(layerName)); if (ait != m_activelayers.end()) m_activelayers.erase(ait); } }
void CHeavyMountedWeapon::OnReset() { BaseClass::OnReset(); m_rippedOff = m_rippingOff = false; m_stats.mounted = true; m_rotatingSoundID = INVALID_SOUNDID; m_lastUsedFrame = -1; Physicalize(false, false); RequireUpdate(eIUS_General); if (m_linkedParentId != 0) { IEntity* pLinkedParent = gEnv->pEntitySystem->GetEntity(m_linkedParentId); if (pLinkedParent) { pLinkedParent->AttachChild(GetEntity()); } m_linkedParentId = 0; } }
void CLivingEntitySample::StartAnimationForCurrentAnimationState() { IEntity* pEntity = GetEntity(); const int slot = 0; ICharacterInstance* pCharacterInstance = pEntity->GetCharacter( slot ); if ( pCharacterInstance == NULL ) { return; } ISkeletonAnim* pSkeletonAnim = pCharacterInstance->GetISkeletonAnim(); if ( pSkeletonAnim == NULL ) { return; } CryCharAnimationParams animationParams; animationParams.m_nFlags |= CA_LOOP_ANIMATION; animationParams.m_nLayerID = 0; animationParams.m_fTransTime = 0.3f; const char* animationName = IDLE_ANIMATION_NAME; switch ( m_animationState ) { case None: case Idle: animationName = IDLE_ANIMATION_NAME; break; case Walk: animationName = WALK_ANIMATION_NAME; break; } pSkeletonAnim->StartAnimation( animationName, animationParams ); }
void CJaw::PickUp(EntityId pickerId, bool sound, bool select, bool keepHistory, const char* setup) { for (TAmmoVector::iterator it = m_bonusammo.begin(); it != m_bonusammo.end(); ++it) { SWeaponAmmo& currentBonusAmmo = *it; currentBonusAmmo.count = 0; } IItemSystem* pItemSystem = gEnv->pGame->GetIGameFramework()->GetIItemSystem(); IActor* pPicketActor = gEnv->pGame->GetIGameFramework()->GetIActorSystem()->GetActor(pickerId); IInventory* pInventory = pPicketActor->GetInventory(); bool giveExtraTube = GiveExtraTubeToInventory(pPicketActor, pItemSystem); if (pPicketActor->IsClient()) SetAmmoCount(m_fm->GetAmmoType(), 1); BaseClass::PickUp(pickerId,sound,select,keepHistory, setup); if (giveExtraTube) { int numJaws = m_weaponsharedparams->ammoParams.extraItems; while(numJaws-- > 0) { pItemSystem->GiveItem(pPicketActor, GetEntity()->GetClass()->GetName(), false, false, false); } m_extraTubesAdded = true; } if(m_auxSlotUsed) { DrawSlot(eIGS_ThirdPersonAux,false); m_auxSlotUsed = false; } if(GetOwnerActor() && !GetOwnerActor()->IsPlayer()) m_stats.first_selection = false; }
RodinBTNode::ETickStatus RodinBTNodeEldLookAt::Tick(float DeltaTime) { Unused(DeltaTime); WBEntity* const pEntity = GetEntity(); WBCompRodinBlackboard* const pAIBlackboard = GET_WBCOMP(pEntity, RodinBlackboard); ASSERT(pAIBlackboard); const WBEvent::EType TargetType = pAIBlackboard->GetType(m_LookTargetBlackboardKey); if (TargetType == WBEvent::EWBEPT_Vector) { const Vector LookTarget = pAIBlackboard->GetVector(m_LookTargetBlackboardKey); WB_MAKE_EVENT(LookAt, pEntity); WB_SET_AUTO(LookAt, Vector, LookAtLocation, LookTarget); WB_DISPATCH_EVENT(GetEventManager(), LookAt, pEntity); return ETS_Success; } else if (TargetType == WBEvent::EWBEPT_Entity) { WBEntity* const pLookTargetEntity = pAIBlackboard->GetEntity(m_LookTargetBlackboardKey); if (!pLookTargetEntity) { return ETS_Fail; } WB_MAKE_EVENT(LookAt, pEntity); WB_SET_AUTO(LookAt, Entity, LookAtEntity, pLookTargetEntity); WB_DISPATCH_EVENT(GetEventManager(), LookAt, pEntity); return ETS_Success; } return ETS_Fail; }
void CDoorPanel::Update( SEntityUpdateContext& ctx, int slot ) { if (m_bHasDelayedStateEvent) { if (m_fDelayedStateEventTimeDelay > FLT_EPSILON) { m_fDelayedStateEventTimeDelay -= ctx.fFrameTime; } else { m_fDelayedStateEventTimeDelay = -1.0f; m_bHasDelayedStateEvent = false; const EDoorPanelBehaviorState delayedState = m_delayedState; m_delayedState = eDoorPanelBehaviorState_Invalid; SetStateById(delayedState); } } // Check visible distance if (m_fVisibleDistanceSq > 0.0f) { const float fCurTime = ctx.fCurrTime; if ((fCurTime - m_fLastVisibleDistanceCheckTime) >= GetGameConstCVar(g_flashdoorpanel_distancecheckinterval)) { m_fLastVisibleDistanceCheckTime = fCurTime; const Vec3& clientPos = CHUDUtils::GetClientPos(); const float fDistSqFromClientToObject = clientPos.GetSquaredDistance(GetEntity()->GetWorldPos()); const bool bVisible = fDistSqFromClientToObject <= m_fVisibleDistanceSq; if (bVisible != m_bFlashVisible) { m_bFlashVisible = bVisible; SDoorPanelVisibleEvent visibleEvent( bVisible ); StateMachineHandleEventBehavior( visibleEvent ); } } } }
void CMonoActor::ProcessEvent(SEntityEvent& event) { if(m_pScript == nullptr) return; HandleEntityEvent(event, GetEntity(), m_pScript); switch (event.event) { case ENTITY_EVENT_UNHIDE: case ENTITY_EVENT_VISIBLE: GetGameObject()->RequestRemoteUpdate(eEA_Physics | eEA_GameClientDynamic | eEA_GameServerDynamic | eEA_GameClientStatic | eEA_GameServerStatic); break; case ENTITY_EVENT_START_GAME: { GetGameObject()->RequestRemoteUpdate(eEA_Physics | eEA_GameClientDynamic | eEA_GameServerDynamic | eEA_GameClientStatic | eEA_GameServerStatic); if (m_pAnimatedCharacter) m_pAnimatedCharacter->ResetState(); } break; case ENTITY_EVENT_RESET: { if (m_pAnimatedCharacter) m_pAnimatedCharacter->ResetState(); GetGameObject()->RequestRemoteUpdate(eEA_Physics | eEA_GameClientDynamic | eEA_GameServerDynamic | eEA_GameClientStatic | eEA_GameServerStatic); } break; case ENTITY_EVENT_INIT: { if (m_pAnimatedCharacter) m_pAnimatedCharacter->ResetState(); } break; } }
int XENTITYS::Entity2Ref( const char* str, char* estr, int estrlen ) { char* ps = (char*)str; char* pes = (char*)estr; char* pes_end = pes+estrlen; while( ps && *ps && pes < pes_end ) { XENTITY *ent = GetEntity( *ps ); if( ent ) { // copy entity string char* ref = (char*)ent->ref; while( ref && *ref ) *pes++ = *ref++; } else *pes++ = *ps; // default character copy ps++; } *pes = '\0'; // total copied characters return pes-estr; }