mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-04-17 17:43:52 +00:00
rendering/game: make player model semi-transparent in ghost form
Add GhostStateCallback to GameHandler, fired when PLAYER_FLAGS_GHOST transitions on or off in UPDATE_OBJECT / login detection. Add setInstanceOpacity() to CharacterRenderer to directly set opacity without disturbing fade-in state. Application wires the callback to set opacity 0.5 on ghost entry and 1.0 on resurrect.
This commit is contained in:
parent
366321042f
commit
c8d9d6b792
5 changed files with 28 additions and 0 deletions
|
|
@ -624,6 +624,10 @@ public:
|
||||||
using StandStateCallback = std::function<void(uint8_t standState)>;
|
using StandStateCallback = std::function<void(uint8_t standState)>;
|
||||||
void setStandStateCallback(StandStateCallback cb) { standStateCallback_ = std::move(cb); }
|
void setStandStateCallback(StandStateCallback cb) { standStateCallback_ = std::move(cb); }
|
||||||
|
|
||||||
|
// Ghost state callback — fired when player enters or leaves ghost (spirit) form
|
||||||
|
using GhostStateCallback = std::function<void(bool isGhost)>;
|
||||||
|
void setGhostStateCallback(GhostStateCallback cb) { ghostStateCallback_ = std::move(cb); }
|
||||||
|
|
||||||
// Melee swing callback (for driving animation/SFX)
|
// Melee swing callback (for driving animation/SFX)
|
||||||
using MeleeSwingCallback = std::function<void()>;
|
using MeleeSwingCallback = std::function<void()>;
|
||||||
void setMeleeSwingCallback(MeleeSwingCallback cb) { meleeSwingCallback_ = std::move(cb); }
|
void setMeleeSwingCallback(MeleeSwingCallback cb) { meleeSwingCallback_ = std::move(cb); }
|
||||||
|
|
@ -2256,6 +2260,7 @@ private:
|
||||||
NpcAggroCallback npcAggroCallback_;
|
NpcAggroCallback npcAggroCallback_;
|
||||||
NpcRespawnCallback npcRespawnCallback_;
|
NpcRespawnCallback npcRespawnCallback_;
|
||||||
StandStateCallback standStateCallback_;
|
StandStateCallback standStateCallback_;
|
||||||
|
GhostStateCallback ghostStateCallback_;
|
||||||
MeleeSwingCallback meleeSwingCallback_;
|
MeleeSwingCallback meleeSwingCallback_;
|
||||||
SpellCastAnimCallback spellCastAnimCallback_;
|
SpellCastAnimCallback spellCastAnimCallback_;
|
||||||
NpcSwingCallback npcSwingCallback_;
|
NpcSwingCallback npcSwingCallback_;
|
||||||
|
|
|
||||||
|
|
@ -78,6 +78,7 @@ public:
|
||||||
void setInstanceRotation(uint32_t instanceId, const glm::vec3& rotation);
|
void setInstanceRotation(uint32_t instanceId, const glm::vec3& rotation);
|
||||||
void moveInstanceTo(uint32_t instanceId, const glm::vec3& destination, float durationSeconds);
|
void moveInstanceTo(uint32_t instanceId, const glm::vec3& destination, float durationSeconds);
|
||||||
void startFadeIn(uint32_t instanceId, float durationSeconds);
|
void startFadeIn(uint32_t instanceId, float durationSeconds);
|
||||||
|
void setInstanceOpacity(uint32_t instanceId, float opacity);
|
||||||
const pipeline::M2Model* getModelData(uint32_t modelId) const;
|
const pipeline::M2Model* getModelData(uint32_t modelId) const;
|
||||||
void setActiveGeosets(uint32_t instanceId, const std::unordered_set<uint16_t>& geosets);
|
void setActiveGeosets(uint32_t instanceId, const std::unordered_set<uint16_t>& geosets);
|
||||||
void setGroupTextureOverride(uint32_t instanceId, uint16_t geosetGroup, VkTexture* texture);
|
void setGroupTextureOverride(uint32_t instanceId, uint16_t geosetGroup, VkTexture* texture);
|
||||||
|
|
|
||||||
|
|
@ -2794,6 +2794,16 @@ void Application::setupUICallbacks() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Ghost state callback — make player semi-transparent when in spirit form
|
||||||
|
gameHandler->setGhostStateCallback([this](bool isGhost) {
|
||||||
|
if (!renderer) return;
|
||||||
|
auto* cr = renderer->getCharacterRenderer();
|
||||||
|
if (!cr) return;
|
||||||
|
uint32_t charInstId = renderer->getCharacterInstanceId();
|
||||||
|
if (charInstId == 0) return;
|
||||||
|
cr->setInstanceOpacity(charInstId, isGhost ? 0.5f : 1.0f);
|
||||||
|
});
|
||||||
|
|
||||||
// Stand state animation callback — map server stand state to M2 animation on player
|
// Stand state animation callback — map server stand state to M2 animation on player
|
||||||
// and sync camera sit flag so movement is blocked while sitting
|
// and sync camera sit flag so movement is blocked while sitting
|
||||||
gameHandler->setStandStateCallback([this](uint8_t standState) {
|
gameHandler->setStandStateCallback([this](uint8_t standState) {
|
||||||
|
|
|
||||||
|
|
@ -7749,6 +7749,7 @@ void GameHandler::handleUpdateObject(network::Packet& packet) {
|
||||||
releasedSpirit_ = true;
|
releasedSpirit_ = true;
|
||||||
playerDead_ = true;
|
playerDead_ = true;
|
||||||
LOG_INFO("Player logged in as ghost (PLAYER_FLAGS)");
|
LOG_INFO("Player logged in as ghost (PLAYER_FLAGS)");
|
||||||
|
if (ghostStateCallback_) ghostStateCallback_(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Determine hostility from faction template for online creatures
|
// Determine hostility from faction template for online creatures
|
||||||
|
|
@ -8212,12 +8213,14 @@ void GameHandler::handleUpdateObject(network::Packet& packet) {
|
||||||
if (!wasGhost && nowGhost) {
|
if (!wasGhost && nowGhost) {
|
||||||
releasedSpirit_ = true;
|
releasedSpirit_ = true;
|
||||||
LOG_INFO("Player entered ghost form (PLAYER_FLAGS)");
|
LOG_INFO("Player entered ghost form (PLAYER_FLAGS)");
|
||||||
|
if (ghostStateCallback_) ghostStateCallback_(true);
|
||||||
} else if (wasGhost && !nowGhost) {
|
} else if (wasGhost && !nowGhost) {
|
||||||
releasedSpirit_ = false;
|
releasedSpirit_ = false;
|
||||||
playerDead_ = false;
|
playerDead_ = false;
|
||||||
repopPending_ = false;
|
repopPending_ = false;
|
||||||
resurrectPending_ = false;
|
resurrectPending_ = false;
|
||||||
LOG_INFO("Player resurrected (PLAYER_FLAGS ghost cleared)");
|
LOG_INFO("Player resurrected (PLAYER_FLAGS ghost cleared)");
|
||||||
|
if (ghostStateCallback_) ghostStateCallback_(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2876,6 +2876,15 @@ void CharacterRenderer::startFadeIn(uint32_t instanceId, float durationSeconds)
|
||||||
it->second.fadeInDuration = durationSeconds;
|
it->second.fadeInDuration = durationSeconds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CharacterRenderer::setInstanceOpacity(uint32_t instanceId, float opacity) {
|
||||||
|
auto it = instances.find(instanceId);
|
||||||
|
if (it != instances.end()) {
|
||||||
|
it->second.opacity = std::clamp(opacity, 0.0f, 1.0f);
|
||||||
|
// Cancel any fade-in in progress to avoid overwriting the new opacity
|
||||||
|
it->second.fadeInDuration = 0.0f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CharacterRenderer::setActiveGeosets(uint32_t instanceId, const std::unordered_set<uint16_t>& geosets) {
|
void CharacterRenderer::setActiveGeosets(uint32_t instanceId, const std::unordered_set<uint16_t>& geosets) {
|
||||||
auto it = instances.find(instanceId);
|
auto it = instances.find(instanceId);
|
||||||
if (it != instances.end()) {
|
if (it != instances.end()) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue