void CParasite::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr) { CPatterned::AcceptScriptMsg(msg, uid, mgr); switch (msg) { case EScriptObjectMessage::Registered: x450_bodyController->Activate(mgr); mgr.GetActiveParasites().push_back(GetUniqueId()); CActor::CreateShadow(false); x604_activeSpeed = x3b4_speed; CPhysicsActor::SetBoundingBox(zeus::CAABox(zeus::CVector3f(-x590_colSphere.GetSphere().radius), zeus::CVector3f(x590_colSphere.GetSphere().radius))); lastParasite = GetUniqueId(); AddDoorRepulsors(mgr); if (x5d0_walkerType == EWalkerType::IceZoomer) { SetupIceZoomerCollision(mgr); SetupIceZoomerVulnerability(mgr, x64c_oculusHaltDVuln, CHealthInfo(x714_iceZoomerJointHP, HealthInfo(mgr)->GetKnockbackResistance())); } break; case EScriptObjectMessage::Deleted: mgr.GetActiveParasites().remove(GetUniqueId()); if (x5d0_walkerType == EWalkerType::IceZoomer) DestroyActorManager(mgr); break; case EScriptObjectMessage::Jumped: if (x742_25_jumpVelDirty) { UpdateJumpVelocity(); x742_25_jumpVelDirty = false; } break; case EScriptObjectMessage::Activate: x5d6_27_disableMove = false; if (x5d0_walkerType == EWalkerType::Parasite) x450_bodyController->SetLocomotionType(pas::ELocomotionType::Lurk); break; case EScriptObjectMessage::InvulnDamage: if (x5d0_walkerType == EWalkerType::Oculus) { if (TCastToConstPtr<CActor> act = mgr.GetObjectById(uid)) { float distSq = (act->GetTranslation() - GetTranslation()).magSquared(); auto tb = GetTouchBounds(); float maxComp = std::max(std::max(tb->max.y() - tb->min.y(), tb->max.z() - tb->min.z()), tb->max.x() - tb->min.x()); float maxCompSq = maxComp * maxComp + 1.f; if (distSq < maxCompSq * maxCompSq) x743_26_oculusShotAt = true; } } break; case EScriptObjectMessage::SuspendedMove: if (x620_collisionActorManager) x620_collisionActorManager->SetMovable(mgr, false); break; default: break; } }
// These functions are overloaded from cObject void cFreePlayMenu::Initialize() { sf::Vector3<double> l_Position = GetPosition(); m_Player1Label.setPosition(GetPosition().x, l_Position.y + 4); l_Position.x += 90; m_pPlayer1Option->SetPosition(l_Position, kNormal, false); m_pPlayer1Option->Initialize(); l_Position.y += m_pPlayer1Option->GetBoundingBox().height + 5; m_Player2Label.setPosition(GetPosition().x, l_Position.y + 4); m_pPlayer2Option->SetPosition(l_Position, kNormal, false); m_pPlayer2Option->Initialize(); l_Position.y += m_pPlayer2Option->GetBoundingBox().height + 5; m_GameSpeedLabel.setPosition(GetPosition().x, l_Position.y + 4); m_pGameSpeedOption->SetPosition(l_Position, kNormal, false); m_pGameSpeedOption->Initialize(); l_Position.y += m_pGameSpeedOption->GetBoundingBox().height + 10; m_pStartButton->SetPosition(l_Position, kNormal, false); l_Position.x += m_pStartButton->GetBoundingBox().width + 5; m_pBackButton->SetPosition(l_Position, kNormal, false); // Receive messages when The start button is pushed. sMessage l_Request; l_Request.m_From = m_pStartButton->GetUniqueId(); l_Request.m_Category = GetResources()->GetMessageDispatcher()->Any(); l_Request.m_Key = GetResources()->GetMessageDispatcher()->Any(); l_Request.m_Value = GetResources()->GetMessageDispatcher()->Any(); std::function<void(sMessage)> l_MessageCallback = std::bind(&cFreePlayMenu::MessageReceived, this, std::placeholders::_1); GetResources()->GetMessageDispatcher()->RegisterForMessages( GetUniqueId(), l_MessageCallback, l_Request ); // Receive messages when the back button is pushed. l_Request.m_From = m_pBackButton->GetUniqueId(); l_Request.m_Category = GetResources()->GetMessageDispatcher()->Any(); l_Request.m_Key = GetResources()->GetMessageDispatcher()->Any(); l_Request.m_Value = GetResources()->GetMessageDispatcher()->Any(); GetResources()->GetMessageDispatcher()->RegisterForMessages( GetUniqueId(), l_MessageCallback, l_Request ); }
void CScriptCameraHint::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId sender, CStateManager& mgr) { switch (msg) { case EScriptObjectMessage::Deleted: case EScriptObjectMessage::Deactivate: mgr.GetCameraManager()->DeleteCameraHint(GetUniqueId(), mgr); break; case EScriptObjectMessage::InitializedInArea: InitializeInArea(mgr); break; default: break; } if (GetActive()) { switch (msg) { case EScriptObjectMessage::Increment: AddHelper(sender); mgr.GetCameraManager()->AddActiveCameraHint(GetUniqueId(), mgr); x166_inactive = false; break; case EScriptObjectMessage::Decrement: RemoveHelper(sender); mgr.GetCameraManager()->AddInactiveCameraHint(GetUniqueId(), mgr); break; default: break; } } if (msg == EScriptObjectMessage::Follow) { if (!GetActive()) { if (TCastToConstPtr<CActor> act = mgr.GetObjectById(sender)) { zeus::CVector3f followerToThisFlat = x168_origXf.origin - act->GetTranslation(); followerToThisFlat.z() = 0.f; if (followerToThisFlat.canBeNormalized()) followerToThisFlat.normalize(); else followerToThisFlat = act->GetTransform().basis[1]; zeus::CVector3f target = act->GetTranslation() + followerToThisFlat; target.z() = x168_origXf.origin.z() + followerToThisFlat.z(); SetTransform(zeus::lookAt(act->GetTranslation(), target)); } } AddHelper(sender); mgr.GetCameraManager()->AddActiveCameraHint(GetUniqueId(), mgr); } CActor::AcceptScriptMsg(msg, sender, mgr); }
void CScriptActorKeyframe::UpdateEntity(TUniqueId uid, CStateManager& mgr) { CEntity* ent = mgr.ObjectById(uid); CActor* act = nullptr; if (TCastToPtr<CScriptActor> tmp = ent) act = tmp; else if (TCastToPtr<CScriptPlatform> tmp = ent) act = tmp; if (act) { if (!act->GetActive()) mgr.SendScriptMsg(act, GetUniqueId(), EScriptObjectMessage::Activate); act->SetDrawFlags({0, 0, 3, zeus::skWhite}); if (act->HasModelData() && act->GetModelData()->HasAnimData()) { CAnimData* animData = act->ModelData()->AnimationData(); if (animData->IsAdditiveAnimation(x34_animationId)) { animData->AddAdditiveAnimation(x34_animationId, 1.f, x44_24_looping, x44_26_fadeOut); } else { animData->SetAnimation(CAnimPlaybackParms(x34_animationId, -1, 1.f, true), false); act->ModelData()->EnableLooping(x44_24_looping); animData->MultiplyPlaybackRate(x3c_playbackRate); } } } else if (TCastToPtr<CPatterned> ai = ent) { CAnimData* animData = ai->ModelData()->AnimationData(); if (animData->IsAdditiveAnimation(x34_animationId)) { animData->AddAdditiveAnimation(x34_animationId, 1.f, x44_24_looping, x44_26_fadeOut); } else { ai->BodyController()->GetCommandMgr().DeliverCmd( CBCScriptedCmd(x34_animationId, x44_24_looping, x44_27_timedLoop, x38_initialLifetime)); } } }
void FanBoomerangManager::Add(float p_deltaTime, RakNet::RakNetGUID p_guid, float p_posX, float p_posY, float p_posZ, float p_dirX, float p_dirY, float p_dirZ) { FanNet fan; fan.x = p_posX + p_dirX; fan.y = p_posY; fan.z = p_posZ + p_dirZ; fan.dirX = p_dirX; fan.dirY = p_dirY; fan.dirZ = p_dirZ; fan.id = GetUniqueId(); fan.guid = p_guid; fan.lifeTime = FANBOOMERANG_DURATION; fan.speed = FANBOOMERANG_SPEED; m_fans.push_back(fan); RakNet::BitStream wBitStream; wBitStream.Write((RakNet::MessageID)ID_FAN_THROWN); wBitStream.Write(fan.x); wBitStream.Write(fan.y); wBitStream.Write(fan.z); wBitStream.Write(fan.dirX); wBitStream.Write(fan.dirY); wBitStream.Write(fan.dirZ); wBitStream.Write(fan.id); wBitStream.Write(fan.guid); wBitStream.Write(fan.speed); m_serverPeer->Send(&wBitStream, HIGH_PRIORITY, RELIABLE, 3, RakNet::UNASSIGNED_RAKNET_GUID, true); }
GraphicsBase::GraphicsBase() : selected_(false) , finished_(false) , handle_size_(8.0f) { object_id_ = GetUniqueId(); }
void cAiBlock::Collision(cObject* a_pOther) { if (a_pOther->GetType() == GetType()) { SitFlush(a_pOther); m_AiLabel.setPosition( static_cast<int32_t>(GetPosition().x + GetBoundingBox().width / 2 - m_AiLabel.getLocalBounds().width / 2), static_cast<int32_t>(GetPosition().y + GetBoundingBox().height / 2 - m_AiLabel.getCharacterSize() / 2.0 - 10) ); SetVelocityY(0, kNormal); sMessage l_Message; l_Message.m_From = GetUniqueId(); l_Message.m_Category =GetResources()->GetMessageDispatcher()->Any(); l_Message.m_Key = GetResources()->GetMessageDispatcher()->Any(); l_Message.m_Value = "Settled"; GetResources()->GetMessageDispatcher()->PostMessage(l_Message); m_Falling = false; PlaySound("Media/Sounds/BigFall.ogg"); } }
void CScriptCameraHint::InitializeInArea(CStateManager& mgr) { x164_delegatedCamera = kInvalidUniqueId; for (CEntity* ent : mgr.GetAllObjectList()) { for (const SConnection& conn : ent->GetConnectionList()) { if (mgr.GetIdForScript(conn.x8_objId) != GetUniqueId()) continue; if (conn.x4_msg != EScriptObjectMessage::Increment && conn.x4_msg != EScriptObjectMessage::Decrement) continue; for (auto it = ent->GetConnectionList().begin(); it != ent->GetConnectionList().cend(); ++it) { const SConnection& conn2 = *it; if (conn2.x4_msg != EScriptObjectMessage::Increment && conn2.x4_msg != EScriptObjectMessage::Decrement) continue; TUniqueId id = mgr.GetIdForScript(conn2.x8_objId); if (TCastToPtr<CPathCamera>(mgr.ObjectById(id)) || TCastToPtr<CScriptSpindleCamera>(mgr.ObjectById((id)))) { ent->ConnectionList().erase(it); if (x164_delegatedCamera != id) x164_delegatedCamera = id; break; } } break; } } }
void cButton::Event(std::list<sf::Event> * a_pEventList) { for (std::list<sf::Event>::iterator i = a_pEventList->begin(); i != a_pEventList->end(); ++i ) { if (i->type == sf::Event::MouseButtonPressed) { // See if the mouse press was on us sf::Rect<int32_t> l_PositionBox = GetBoundingBox(); l_PositionBox.left += GetPosition().x; l_PositionBox.top += GetPosition().y; if (l_PositionBox.contains(i->mouseButton.x, i->mouseButton.y)) { PlayAnimationLoop(m_SpritePressedImage.second); PlaySound("Media/Sounds/Click1.ogg"); sMessage l_Message; l_Message.m_From = GetUniqueId(); l_Message.m_Category = "Widget"; l_Message.m_Key = "Button"; l_Message.m_Value = "Pressed"; GetResources()->GetMessageDispatcher()->PostMessage(l_Message); } } else if (i->type == sf::Event::MouseButtonReleased) { PlayAnimationLoop(m_SpriteImage.second); } } }
void Connection::onConnectCompleted(const asio::error_code& err) { UInt32 result = 1; if ( !err ) { result = 0; } EventRawConnected* e = new EventRawConnected; e->idx = GetUniqueId(); e->result = result; e->socketIndex = GetSessionId(); e->key = 0; m_net->Notify( EventPtr( e ) ); if ( !err ) { requestRecv(); } else { // 에러 날 경우 연결 종료도 통보함 onError( err ); } MU2LogSystem( 0, "Connection::Error> [Code: %d]", err.value()); }
//----------------------------------------------------------------------------- void StateObject::Stop() { Dia::Core::Log::OutputVaradicLine("Stoping %s", GetUniqueId().AsChar()); DIA_ASSERT(mState == StateEnum::kRunning, "Stoping %s but in wrong state: %s", mUniqueId.AsChar(), mState.AsString()); DoStop(); }
void CBloodFlower::PodAttack(CStateManager& mgr, EStateMsg msg, float arg) { if (msg == EStateMsg::Activate) { x450_bodyController->GetCommandMgr().DeliverCmd(CBCMeleeAttackCmd(pas::ESeverity::Zero)); x574_podEffect->SetParticleEmission(true); ActivateTriggers(mgr, true); } else if (msg == EStateMsg::Update) { if (TooClose(mgr, 0.f)) return; mgr.ApplyDamage(GetUniqueId(), mgr.GetPlayer().GetUniqueId(), GetUniqueId(), x5f8_podDamage, CMaterialFilter::MakeIncludeExclude({EMaterialTypes::Solid}, {}), {}); } else if (msg == EStateMsg::Deactivate) { x574_podEffect->SetParticleEmission(false); ActivateTriggers(mgr, false); x450_bodyController->GetCommandMgr().DeliverCmd(CBCKnockBackCmd({}, pas::ESeverity::One)); } }
void CScriptDoor::Think(float dt, CStateManager& mgr) { if (!GetActive()) return; if (!x2a8_26_isOpen && x25c_animTime < 0.5f) x25c_animTime += dt; if (x2a8_27_conditionsMet && GetDoorOpenCondition(mgr) == 2) { x2a8_27_conditionsMet = false; OpenDoor(x280_prevDoor, mgr); } if (x2a8_24_closing) { x2a8_25_wasOpen = false; mgr.GetCameraManager()->GetBallCamera()->DoorClosed(GetUniqueId()); x2a8_28_projectilesCollide = false; x2a8_24_closing = false; SendScriptMsgs(EScriptObjectState::Closed, mgr, EScriptObjectMessage::Decrement); x25c_animTime = 0.f; x2a8_30_doClose = false; } if (x2a8_26_isOpen && !x64_modelData->IsAnimating()) RemoveMaterial(EMaterialTypes::Solid, EMaterialTypes::Occluder, EMaterialTypes::Orbit, EMaterialTypes::Scannable, mgr); else { if (x2a8_25_wasOpen && !x64_modelData->IsAnimating()) { x2a8_25_wasOpen = false; mgr.GetCameraManager()->GetBallCamera()->DoorClosed(GetUniqueId()); x2a8_28_projectilesCollide = false; x2a8_27_conditionsMet = false; SendScriptMsgs(EScriptObjectState::Closed, mgr, EScriptObjectMessage::None); } if (GetScannableObjectInfo()) AddMaterial(EMaterialTypes::Solid, EMaterialTypes::Metal, EMaterialTypes::Occluder, EMaterialTypes::Orbit, EMaterialTypes::Scannable, mgr); else AddMaterial(EMaterialTypes::Solid, EMaterialTypes::Metal, EMaterialTypes::Occluder, EMaterialTypes::Orbit, mgr); } if (x64_modelData->IsAnimating()) UpdateAnimation((x64_modelData->GetAnimationDuration(s32(x260_doorAnimState)) / x258_animLen) * dt, mgr, true); xe7_31_targetable = mgr.GetPlayerState()->GetCurrentVisor() == CPlayerState::EPlayerVisor::Scan; }
void GL::PushTransform(const Matrix& aTransform) { MOZ_ASSERT(IsCurrent()); MatrixPushEXT(GL_MODELVIEW); mTransformIdStack.push(mTransformIdStack.top()); SetTransform(aTransform, GetUniqueId()); }
CTargetableProjectile* CBloodFlower::CreateArcProjectile(CStateManager& mgr, const TToken<CWeaponDescription>& desc, const zeus::CTransform& xf, const CDamageInfo& damage, TUniqueId uid) { if (!x578_projectileDesc) return nullptr; TUniqueId projId = mgr.AllocateUniqueId(); CTargetableProjectile* targProj = new CTargetableProjectile( desc, EWeaponType::AI, xf, EMaterialTypes::Character, damage, x5dc_projectileDamage, projId, GetAreaIdAlways(), GetUniqueId(), x578_projectileDesc, uid, EProjectileAttrib::None, {x5c4_visorParticle}, x5d4_visorSfx, false); if (mgr.GetPlayer().GetOrbitTargetId() == GetUniqueId()) { mgr.GetPlayer().ResetAimTargetPrediction(projId); mgr.GetPlayer().SetOrbitTargetId(projId, mgr); } return targProj; }
void CParasite::SetupIceZoomerCollision(CStateManager& mgr) { std::vector<CJointCollisionDescription> descs; descs.reserve(2); descs.push_back(CJointCollisionDescription::SphereCollision( x64_modelData->GetAnimationData()->GetLocatorSegId("Ice_LCTR"sv), 0.4f, "Ice_LCTR"sv, 0.001f)); RemoveMaterial(EMaterialTypes::Solid, mgr); AddMaterial(EMaterialTypes::ProjectilePassthrough, mgr); x620_collisionActorManager = std::make_unique<CCollisionActorManager>(mgr, GetUniqueId(), GetAreaIdAlways(), descs, GetActive()); }
bool Texture::Create(unsigned int width, unsigned int height) { // Check if texture parameters are valid before creating it if (!width || !height) { Err() << "Failed to create texture, invalid size (" << width << "x" << height << ")" << std::endl; return false; } // Compute the internal texture dimensions depending on NPOT textures support unsigned int textureWidth = GetValidSize(width); unsigned int textureHeight = GetValidSize(height); // Check the maximum texture size unsigned int maxSize = GetMaximumSize(); if ((textureWidth > maxSize) || (textureHeight > maxSize)) { Err() << "Failed to create texture, its internal size is too high " << "(" << textureWidth << "x" << textureHeight << ", " << "maximum is " << maxSize << "x" << maxSize << ")" << std::endl; return false; } // All the validity checks passed, we can store the new texture settings myWidth = width; myHeight = height; myTextureWidth = textureWidth; myTextureHeight = textureHeight; myPixelsFlipped = false; EnsureGlContext(); // Create the OpenGL texture if it doesn't exist yet if (!myTexture) { GLuint texture; GLCheck(glGenTextures(1, &texture)); myTexture = static_cast<unsigned int>(texture); } // Make sure that the current texture binding will be preserved priv::TextureSaver save; // Initialize the texture GLCheck(glBindTexture(GL_TEXTURE_2D, myTexture)); GLCheck(glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, myTextureWidth, myTextureHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL)); GLCheck(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, myIsRepeated ? GL_REPEAT : GL_CLAMP_TO_EDGE)); GLCheck(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, myIsRepeated ? GL_REPEAT : GL_CLAMP_TO_EDGE)); GLCheck(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, myIsSmooth ? GL_LINEAR : GL_NEAREST)); GLCheck(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, myIsSmooth ? GL_LINEAR : GL_NEAREST)); myCacheId = GetUniqueId(); return true; }
void Connection::onError(const asio::error_code& err) { MU2LogSystem( 0, "Connection::onError> %s", err.message().c_str() ); EventDisconnected* e = new EventDisconnected; e->idx = GetUniqueId(); e->socketIndex = GetSessionId(); e->sessionType = 0; m_net->Notify( EventPtr( e ) ); }
void CBloodFlower::ActivateTriggers(CStateManager& mgr, bool activate) { for (const SConnection& conn : GetConnectionList()) { auto search = mgr.GetIdListForScript(conn.x8_objId); for (auto it = search.first; it != search.second; ++it) { if (TCastToPtr<CScriptTrigger> trigger = mgr.ObjectById(it->second)) { mgr.SendScriptMsg(trigger, GetUniqueId(), (activate ? EScriptObjectMessage::Activate : EScriptObjectMessage::Deactivate)); } } } }
void KillableTargetActor::ProcessMessage(const dtGame::Message& message) { // HANDLE GAME EVENT MESSAGE - "TankFired" if (message.GetMessageType() == dtGame::MessageType::INFO_GAME_EVENT) { const dtGame::GameEventMessage& eventMsg = static_cast<const dtGame::GameEventMessage&>(message); // Note, we are using strings which aren't constants. In a real application, these // event names should be stored in some sort of shared place and should be constants... if (eventMsg.GetGameEvent() != 0 && eventMsg.GetGameEvent()->GetName() == "TankFired") { if (mIsTargeted && mCurrentHealth > 0) { SetCurrentHealth(GetCurrentHealth() - 25); } } // test our shaders else if (eventMsg.GetGameEvent() != 0 && eventMsg.GetGameEvent()->GetName() == "TestShaders") { // Note, this behavior is now done in the InputComponent.cpp using the new Shader method. //dtCore::ShaderManager::GetInstance().Clear(); //dtCore::ShaderManager::GetInstance().LoadShaderDefinitions("Shaders/TutorialShaderDefs.xml", false); //ApplyMyShader(); } // reset me! else if (eventMsg.GetGameEvent() != 0 && eventMsg.GetGameEvent()->GetName() == "ResetStuff") { SetTransform(mOriginalPosition); ResetState(); } } // HANDLE TARGET CHANGED MESSAGE else if (message.GetMessageType() == TutorialMessageType::TANK_TARGET_CHANGED) { const TargetChangedMessage& targetChanged = static_cast<const TargetChangedMessage&>(message); mIsTargeted = (targetChanged.GetNewTargetUniqueId() == GetUniqueId()); if (mIsTargeted && mCurrentHealth > 0) { // Ahhhh! Get that gun outta my face! mCurrentShaderName = "Green"; } else { //mCurrentShaderName = "Green"; mCurrentShaderName = "Normal"; } ApplyMyShader(); } }
Texture::Texture() : myWidth (0), myHeight (0), myTextureWidth (0), myTextureHeight(0), myTexture (0), myIsSmooth (false), myIsRepeated (false), myPixelsFlipped(false), myCacheId (GetUniqueId()) { }
// These functions are overloaded from cObject void cSelectionBox::Initialize() { sf::Vector3<double> l_Position = GetPosition(); m_pLeftArrowButton->SetPosition(l_Position, kNormal, false); m_pLeftArrowButton->Initialize(); l_Position.x += m_pLeftArrowButton->GetBoundingBox().width; m_pTextBox->SetPosition(l_Position, kNormal, false); m_pTextBox->Initialize(); l_Position.x += m_pTextBox->GetBoundingBox().width; m_pRightArrowButton->SetPosition(l_Position, kNormal, false); m_pRightArrowButton->Initialize(); // Receive messages when buttons are pushed. sMessage l_Request; l_Request.m_From = m_pLeftArrowButton->GetUniqueId(); l_Request.m_Category = GetResources()->GetMessageDispatcher()->Any(); l_Request.m_Key = GetResources()->GetMessageDispatcher()->Any(); l_Request.m_Value = GetResources()->GetMessageDispatcher()->Any(); std::function<void(sMessage)> l_MessageCallback = std::bind(&cSelectionBox::MessageReceived, this, std::placeholders::_1); GetResources()->GetMessageDispatcher()->RegisterForMessages( GetUniqueId(), l_MessageCallback, l_Request ); l_Request.m_From = m_pRightArrowButton->GetUniqueId(); GetResources()->GetMessageDispatcher()->RegisterForMessages( GetUniqueId(), l_MessageCallback, l_Request ); }
Texture::Texture(const Texture& copy) : myWidth (0), myHeight (0), myTextureWidth (0), myTextureHeight(0), myTexture (0), myIsSmooth (copy.myIsSmooth), myIsRepeated (copy.myIsRepeated), myPixelsFlipped(false), myCacheId (GetUniqueId()) { if (copy.myTexture) LoadFromImage(copy.CopyToImage()); }
Texture& Texture::operator =(const Texture& right) { Texture temp(right); std::swap(myWidth, temp.myWidth); std::swap(myHeight, temp.myHeight); std::swap(myTextureWidth, temp.myTextureWidth); std::swap(myTextureHeight, temp.myTextureHeight); std::swap(myTexture, temp.myTexture); std::swap(myIsSmooth, temp.myIsSmooth); std::swap(myIsRepeated, temp.myIsRepeated); std::swap(myPixelsFlipped, temp.myPixelsFlipped); myCacheId = GetUniqueId(); return *this; }
void Texture::Update(const Window& window, unsigned int x, unsigned int y) { assert(x + window.GetWidth() <= myWidth); assert(y + window.GetHeight() <= myHeight); if (myTexture && window.SetActive(true)) { // Make sure that the current texture binding will be preserved priv::TextureSaver save; // Copy pixels from the back-buffer to the texture GLCheck(glBindTexture(GL_TEXTURE_2D, myTexture)); GLCheck(glCopyTexSubImage2D(GL_TEXTURE_2D, 0, x, y, 0, 0, window.GetWidth(), window.GetHeight())); myPixelsFlipped = true; myCacheId = GetUniqueId(); } }
/* ORIGINAL 0-00 OFFSET: 8007EA64 */ void CScriptDoor::OpenDoor(TUniqueId uid, CStateManager& mgr) { TEditorId eid = mgr.GetEditorIdForUniqueId(uid); mgr.MapWorldInfo()->SetDoorVisited(eid, true); x2a8_26_isOpen = true; x2a8_25_wasOpen = true; x2a8_27_conditionsMet = false; x27c_partner1 = kInvalidUniqueId; x27e_partner2 = kInvalidUniqueId; if (const CScriptDoor* door = TCastToConstPtr<CScriptDoor>(mgr.GetObjectById(uid))) x27c_partner1 = door->GetUniqueId(); SetDoorAnimation(EDoorAnimType::Open); if (x27c_partner1 == kInvalidUniqueId) SendScriptMsgs(EScriptObjectState::Open, mgr, EScriptObjectMessage::None); else SendScriptMsgs(EScriptObjectState::MaxReached, mgr, EScriptObjectMessage::None); if (TCastToConstPtr<CScriptDock> dock1 = mgr.GetObjectById(x282_dockId)) { for (CEntity* ent : mgr.GetPlatformAndDoorObjectList()) { TCastToConstPtr<CScriptDoor> door = ent; if (!door || door->GetUniqueId() == uid) continue; if (TCastToConstPtr<CScriptDock> dock2 = mgr.GetObjectById(door->x282_dockId)) { if (dock1->GetCurrentConnectedAreaId(mgr) == dock2->GetAreaId() && dock2->GetCurrentConnectedAreaId(mgr) == dock1->GetAreaId()) { x27e_partner2 = door->GetUniqueId(); mgr.SendScriptMsg(ent, GetUniqueId(), EScriptObjectMessage::Open); } } } } if (x27c_partner1 == kInvalidUniqueId && x27e_partner2 == kInvalidUniqueId) { for (const SConnection& conn : x20_conns) { if (conn.x4_msg != EScriptObjectMessage::Open) continue; if (TCastToConstPtr<CScriptDoor> door = mgr.GetObjectById(mgr.GetIdForScript(conn.x8_objId))) { x27e_partner2 = door->GetUniqueId(); break; } } } }
void Texture::Update(const Uint8* pixels, unsigned int width, unsigned int height, unsigned int x, unsigned int y) { assert(x + width <= myWidth); assert(y + height <= myHeight); if (pixels && myTexture) { EnsureGlContext(); // Make sure that the current texture binding will be preserved priv::TextureSaver save; // Copy pixels from the given array to the texture GLCheck(glBindTexture(GL_TEXTURE_2D, myTexture)); GLCheck(glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, width, height, GL_RGBA, GL_UNSIGNED_BYTE, pixels)); myPixelsFlipped = false; myCacheId = GetUniqueId(); } }
void CParasite::Deactivate(CStateManager& mgr, EStateMsg msg, float) { switch (msg) { case EStateMsg::Activate: x5e8_stateProgress = 0; SendScriptMsgs(EScriptObjectState::DeactivateState, mgr, EScriptObjectMessage::None); mgr.FreeScriptObject(GetUniqueId()); break; case EStateMsg::Update: if (x5e8_stateProgress == 0) { if (x450_bodyController->GetCurrentStateId() == pas::EAnimationState::Generate) x5e8_stateProgress = 1; else x450_bodyController->GetCommandMgr().DeliverCmd(CBCGenerateCmd(pas::EGenerateType::One)); } break; default: break; } }
void cFreePlayMenu::Step (uint32_t a_ElapsedMiliSec) { if (GetPosition() != GetPreviousPosition()) { sf::Vector3<double> l_Position = GetPosition(); m_Player1Label.setPosition(GetPosition().x, l_Position.y + 4); l_Position.y += m_pPlayer1Option->GetBoundingBox().height + 5; m_Player2Label.setPosition(GetPosition().x, l_Position.y + 4); l_Position.y += m_pPlayer2Option->GetBoundingBox().height + 5; m_GameSpeedLabel.setPosition(GetPosition().x, l_Position.y + 4); } // We can't post a message from inside the MessageReceived function, so it // gets deferred to here instead. // TODO: This might not actually be true. It might only be registering for // messages that is problematic. if (m_PostBackMessage) { sMessage l_Message; l_Message.m_From = GetUniqueId(); l_Message.m_Category = "Button"; l_Message.m_Key = "Menu Change"; l_Message.m_Value = "cMainMenu"; GetResources()->GetMessageDispatcher()->PostMessage(l_Message); m_PostBackMessage = false; } if (GetVelocity().x < 0) { if (GetPosition().x + m_Player1Label.getLocalBounds().width < GetResources()->GetWindow()->getSize().x / 2) { SetVelocityX(0, kNormal); } } else if (GetVelocity().x > 0) { if (GetPosition().x > GetResources()->GetWindow()->getSize().x) { SetVelocityX(0, kNormal); } } }
void CPathCamera::Think(float dt, CStateManager& mgr) { if (!GetActive()) return; if (mgr.GetCameraManager()->GetPathCameraId() != GetUniqueId()) return; if (x188_spline.GetSize() <= 0) return; zeus::CTransform xf = GetTransform(); zeus::CVector3f ballLook = mgr.GetCameraManager()->GetBallCamera()->GetLookPos(); if ((x1ec_flags & 0x10)) { if (const CScriptCameraHint* hint = mgr.GetCameraManager()->GetCameraHint(mgr)) ballLook.z() = hint->GetTranslation().z(); } if (!mgr.GetPlayer().GetVelocity().canBeNormalized() && (ballLook - GetTranslation()).canBeNormalized()) { if (x1ec_flags & 4) SetTransform(x188_spline.GetInterpolatedSplinePointByLength(x1d4_pos)); else SetTransform(zeus::lookAt(GetTranslation(), ballLook)); return; } xf = MoveAlongSpline(dt, mgr); SetTranslation(xf.origin); if (x1ec_flags & 0x20) ClampToClosedDoor(mgr); zeus::CVector3f tmp = ballLook - GetTranslation(); tmp.z() = 0.f; if (tmp.canBeNormalized()) SetTransform(zeus::lookAt(GetTranslation(), ballLook)); if (x1ec_flags & 4) SetTransform(xf); }