Merge pull request #1025 from EmosewaMC/more-cdclient-cleanup

Implement animation table
This commit is contained in:
Gie "Max" Vanommeslaeghe 2023-05-14 15:08:18 +02:00 committed by GitHub
commit f9b52ad01c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
57 changed files with 438 additions and 285 deletions

12
dCommon/DluAssert.h Normal file
View File

@ -0,0 +1,12 @@
#ifndef __DLUASSERT__H__
#define __DLUASSERT__H__
#include <assert.h>
#ifdef _DEBUG
# define DluAssert(expression) assert(expression)
#else
# define DluAssert(expression)
#endif
#endif //!__DLUASSERT__H__

View File

@ -16,9 +16,6 @@
// Enable this to cache all entries in each table for fast access, comes with more memory cost
//#define CDCLIENT_CACHE_ALL
// Enable this to skip some unused columns in some tables
#define UNUSED(v)
/*!
\file CDClientDatabase.hpp
\brief An interface between the CDClient.sqlite file and the server

View File

@ -40,7 +40,7 @@
CDClientManager::CDClientManager() {
CDActivityRewardsTable::Instance();
UNUSED(CDAnimationsTable::Instance());
CDAnimationsTable::Instance();
CDBehaviorParameterTable::Instance();
CDBehaviorTemplateTable::Instance();
CDComponentsRegistryTable::Instance();

View File

@ -4,6 +4,8 @@
#include "Singleton.h"
#define UNUSED_TABLE(v)
/**
* Initialize the CDClient tables so they are all loaded into memory.
*/

View File

@ -1,56 +1,83 @@
#include "CDAnimationsTable.h"
#include "GeneralUtils.h"
#include "Game.h"
CDAnimationsTable::CDAnimationsTable(void) {
bool CDAnimationsTable::CacheData(CppSQLite3Statement& queryToCache) {
auto tableData = queryToCache.execQuery();
// If we received a bad lookup, cache it anyways so we do not run the query again.
if (tableData.eof()) return false;
// First, get the size of the table
unsigned int size = 0;
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM Animations");
while (!tableSize.eof()) {
size = tableSize.getIntField(0, 0);
do {
std::string animation_type = tableData.getStringField("animation_type", "");
DluAssert(!animation_type.empty());
AnimationGroupID animationGroupID = tableData.getIntField("animationGroupID", -1);
DluAssert(animationGroupID != -1);
tableSize.nextRow();
}
tableSize.finalize();
// Reserve the size
this->entries.reserve(size);
// Now get the data
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM Animations");
while (!tableData.eof()) {
CDAnimations entry;
entry.animationGroupID = tableData.getIntField("animationGroupID", -1);
entry.animation_type = tableData.getStringField("animation_type", "");
CDAnimation entry;
entry.animation_name = tableData.getStringField("animation_name", "");
entry.chance_to_play = tableData.getFloatField("chance_to_play", -1.0f);
entry.min_loops = tableData.getIntField("min_loops", -1);
entry.max_loops = tableData.getIntField("max_loops", -1);
entry.animation_length = tableData.getFloatField("animation_length", -1.0f);
entry.hideEquip = tableData.getIntField("hideEquip", -1) == 1 ? true : false;
entry.ignoreUpperBody = tableData.getIntField("ignoreUpperBody", -1) == 1 ? true : false;
entry.restartable = tableData.getIntField("restartable", -1) == 1 ? true : false;
entry.face_animation_name = tableData.getStringField("face_animation_name", "");
entry.priority = tableData.getFloatField("priority", -1.0f);
entry.blendTime = tableData.getFloatField("blendTime", -1.0f);
entry.chance_to_play = tableData.getFloatField("chance_to_play", 1.0f);
UNUSED_COLUMN(entry.min_loops = tableData.getIntField("min_loops", 0);)
UNUSED_COLUMN(entry.max_loops = tableData.getIntField("max_loops", 0);)
entry.animation_length = tableData.getFloatField("animation_length", 0.0f);
UNUSED_COLUMN(entry.hideEquip = tableData.getIntField("hideEquip", 0) == 1;)
UNUSED_COLUMN(entry.ignoreUpperBody = tableData.getIntField("ignoreUpperBody", 0) == 1;)
UNUSED_COLUMN(entry.restartable = tableData.getIntField("restartable", 0) == 1;)
UNUSED_COLUMN(entry.face_animation_name = tableData.getStringField("face_animation_name", "");)
UNUSED_COLUMN(entry.priority = tableData.getFloatField("priority", 0.0f);)
UNUSED_COLUMN(entry.blendTime = tableData.getFloatField("blendTime", 0.0f);)
this->entries.push_back(entry);
this->animations[CDAnimationKey(animation_type, animationGroupID)].push_back(entry);
tableData.nextRow();
}
} while (!tableData.eof());
tableData.finalize();
return true;
}
std::vector<CDAnimations> CDAnimationsTable::Query(std::function<bool(CDAnimations)> predicate) {
std::vector<CDAnimations> data = cpplinq::from(this->entries)
>> cpplinq::where(predicate)
>> cpplinq::to_vector();
return data;
void CDAnimationsTable::CacheAnimations(const CDAnimationKey animationKey) {
auto query = CDClientDatabase::CreatePreppedStmt("SELECT * FROM Animations WHERE animationGroupID = ? and animation_type = ?");
query.bind(1, static_cast<int32_t>(animationKey.second));
query.bind(2, animationKey.first.c_str());
// If we received a bad lookup, cache it anyways so we do not run the query again.
if (!CacheData(query)) {
this->animations[animationKey];
}
}
std::vector<CDAnimations> CDAnimationsTable::GetEntries(void) const {
return this->entries;
void CDAnimationsTable::CacheAnimationGroup(AnimationGroupID animationGroupID) {
auto animationEntryCached = this->animations.find(CDAnimationKey("", animationGroupID));
if (animationEntryCached != this->animations.end()) {
return;
}
auto query = CDClientDatabase::CreatePreppedStmt("SELECT * FROM Animations WHERE animationGroupID = ?");
query.bind(1, static_cast<int32_t>(animationGroupID));
// Cache the query so we don't run the query again.
CacheData(query);
this->animations[CDAnimationKey("", animationGroupID)];
}
CDAnimationLookupResult CDAnimationsTable::GetAnimation(const AnimationID& animationType, const std::string& previousAnimationName, const AnimationGroupID animationGroupID) {
CDAnimationKey animationKey(animationType, animationGroupID);
auto animationEntryCached = this->animations.find(animationKey);
if (animationEntryCached == this->animations.end()) {
this->CacheAnimations(animationKey);
}
auto animationEntry = this->animations.find(animationKey);
// If we have only one animation, return it regardless of the chance to play.
if (animationEntry->second.size() == 1) {
return CDAnimationLookupResult(animationEntry->second.front());
}
auto randomAnimation = GeneralUtils::GenerateRandomNumber<float>(0, 1);
for (auto& animationEntry : animationEntry->second) {
randomAnimation -= animationEntry.chance_to_play;
// This is how the client gets the random animation.
if (animationEntry.animation_name != previousAnimationName && randomAnimation <= 0.0f) return CDAnimationLookupResult(animationEntry);
}
return CDAnimationLookupResult();
}

View File

@ -1,33 +1,66 @@
#pragma once
// Custom Classes
#include "CDTable.h"
#include <list>
struct CDAnimations {
unsigned int animationGroupID; //!< The animation group ID
std::string animation_type; //!< The animation type
struct CDAnimation {
// unsigned int animationGroupID;
// std::string animation_type;
// The above two are a pair to represent a primary key in the map.
std::string animation_name; //!< The animation name
float chance_to_play; //!< The chance to play the animation
unsigned int min_loops; //!< The minimum number of loops
unsigned int max_loops; //!< The maximum number of loops
UNUSED_COLUMN(unsigned int min_loops;) //!< The minimum number of loops
UNUSED_COLUMN(unsigned int max_loops;) //!< The maximum number of loops
float animation_length; //!< The animation length
bool hideEquip; //!< Whether or not to hide the equip
bool ignoreUpperBody; //!< Whether or not to ignore the upper body
bool restartable; //!< Whether or not the animation is restartable
std::string face_animation_name; //!< The face animation name
float priority; //!< The priority
float blendTime; //!< The blend time
UNUSED_COLUMN(bool hideEquip;) //!< Whether or not to hide the equip
UNUSED_COLUMN(bool ignoreUpperBody;) //!< Whether or not to ignore the upper body
UNUSED_COLUMN(bool restartable;) //!< Whether or not the animation is restartable
UNUSED_COLUMN(std::string face_animation_name;) //!< The face animation name
UNUSED_COLUMN(float priority;) //!< The priority
UNUSED_COLUMN(float blendTime;) //!< The blend time
};
typedef LookupResult<CDAnimation> CDAnimationLookupResult;
class CDAnimationsTable : public CDTable<CDAnimationsTable> {
private:
std::vector<CDAnimations> entries;
typedef int32_t AnimationGroupID;
typedef std::string AnimationID;
typedef std::pair<std::string, AnimationGroupID> CDAnimationKey;
public:
CDAnimationsTable();
// Queries the table with a custom "where" clause
std::vector<CDAnimations> Query(std::function<bool(CDAnimations)> predicate);
/**
* Given an animationType and the previousAnimationName played, return the next animationType to play.
* If there are more than 1 animationTypes that can be played, one is selected at random but also does not allow
* the previousAnimationName to be played twice.
*
* @param animationType The animationID to lookup
* @param previousAnimationName The previously played animation
* @param animationGroupID The animationGroupID to lookup
* @return CDAnimationLookupResult
*/
[[nodiscard]] CDAnimationLookupResult GetAnimation(const AnimationID& animationType, const std::string& previousAnimationName, const AnimationGroupID animationGroupID);
std::vector<CDAnimations> GetEntries(void) const;
/**
* Cache a full AnimationGroup by its ID.
*/
void CacheAnimationGroup(AnimationGroupID animationGroupID);
private:
/**
* Cache all animations given a premade key
*/
void CacheAnimations(const CDAnimationKey animationKey);
/**
* Run the query responsible for caching the data.
* @param queryToCache
* @return true
* @return false
*/
bool CacheData(CppSQLite3Statement& queryToCache);
/**
* Each animation is key'd by its animationName and its animationGroupID. Each
* animation has a possible list of animations. This is because there can be animations have a percent chance to play so one is selected at random.
*/
std::map<CDAnimationKey, std::list<CDAnimation>> animations;
};

View File

@ -2,6 +2,7 @@
#include "CDClientDatabase.h"
#include "Singleton.h"
#include "DluAssert.h"
#include <functional>
#include <string>
@ -15,6 +16,12 @@
#endif
#include "cpplinq.hpp"
// Used for legacy
#define UNUSED(x)
// Enable this to skip some unused columns in some tables
#define UNUSED_COLUMN(v)
#pragma warning (disable : 4244) //Disable double to float conversion warnings
#pragma warning (disable : 4715) //Disable "not all control paths return a value"
@ -23,3 +30,15 @@ class CDTable : public Singleton<Table> {
protected:
virtual ~CDTable() = default;
};
template<class T>
class LookupResult {
typedef std::pair<T, bool> DataType;
public:
LookupResult() { m_data.first = T(); m_data.second = false; };
LookupResult(T& data) { m_data.first = data; m_data.second = true; };
inline const T& Data() { return m_data.first; };
inline const bool& FoundData() { return m_data.second; };
private:
DataType m_data;
};

View File

@ -595,8 +595,9 @@ void Entity::Initialize() {
m_Components.insert(std::make_pair(eReplicaComponentType::BOUNCER, comp));
}
if ((compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::RENDER) > 0 && m_TemplateID != 2365) || m_Character) {
RenderComponent* render = new RenderComponent(this);
int32_t renderComponentId = compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::RENDER);
if ((renderComponentId > 0 && m_TemplateID != 2365) || m_Character) {
RenderComponent* render = new RenderComponent(this, renderComponentId);
m_Components.insert(std::make_pair(eReplicaComponentType::RENDER, render));
}

View File

@ -26,6 +26,7 @@
#include "Database.h"
#include "EntityInfo.h"
#include "eMissionTaskType.h"
#include "RenderComponent.h"
#include "eObjectBits.h"
#include "eGameMasterLevel.h"
@ -530,7 +531,7 @@ void PetComponent::NotifyTamingBuildSuccess(NiPoint3 position) {
}
GameMessages::SendPlayFXEffect(tamer, -1, u"petceleb", "", LWOOBJID_EMPTY, 1, 1, true);
GameMessages::SendPlayAnimation(tamer, u"rebuild-celebrate");
RenderComponent::PlayAnimation(tamer, u"rebuild-celebrate");
EntityInfo info{};
info.lot = cached->second.puzzleModelLot;

View File

@ -7,6 +7,8 @@
#include "RebuildComponent.h"
#include "Game.h"
#include "dLogger.h"
#include "RenderComponent.h"
#include "EntityManager.h"
#include "eStateChangeType.h"
RailActivatorComponent::RailActivatorComponent(Entity* parent, int32_t componentID) : Component(parent) {
@ -57,23 +59,10 @@ void RailActivatorComponent::OnUse(Entity* originator) {
GameMessages::SendPlayFXEffect(originator->GetObjectID(), m_StartEffect.first, m_StartEffect.second,
std::to_string(m_StartEffect.first));
}
float animationLength = 0.5f;
if (!m_StartAnimation.empty()) {
GameMessages::SendPlayAnimation(originator, m_StartAnimation);
}
float animationLength;
if (m_StartAnimation == u"whirlwind-rail-up-earth") {
animationLength = 1.5f;
} else if (m_StartAnimation == u"whirlwind-rail-up-lightning") {
animationLength = 0.5f;
} else if (m_StartAnimation == u"whirlwind-rail-up-ice") {
animationLength = 0.5f;
} else if (m_StartAnimation == u"whirlwind-rail-up-fire") {
animationLength = 0.5f;
} else {
animationLength = 0.5f;
animationLength = RenderComponent::PlayAnimation(originator, m_StartAnimation);
}
const auto originatorID = originator->GetObjectID();
@ -112,7 +101,7 @@ void RailActivatorComponent::OnRailMovementReady(Entity* originator) const {
}
if (!m_LoopAnimation.empty()) {
GameMessages::SendPlayAnimation(originator, m_LoopAnimation);
RenderComponent::PlayAnimation(originator, m_LoopAnimation);
}
GameMessages::SendSetRailMovement(originator->GetObjectID(), m_PathDirection, m_Path, m_PathStart,
@ -147,7 +136,7 @@ void RailActivatorComponent::OnCancelRailMovement(Entity* originator) {
}
if (!m_StopAnimation.empty()) {
GameMessages::SendPlayAnimation(originator, m_StopAnimation);
RenderComponent::PlayAnimation(originator, m_StopAnimation);
}
// Remove the player after they've signalled they're done railing

View File

@ -20,6 +20,7 @@
#include "Preconditions.h"
#include "Loot.h"
#include "TeamManager.h"
#include "RenderComponent.h"
#include "CppScripts.h"
@ -517,7 +518,7 @@ void RebuildComponent::CompleteRebuild(Entity* user) {
character->SetPlayerFlag(flagNumber, true);
}
}
GameMessages::SendPlayAnimation(user, u"rebuild-celebrate", 1.09f);
RenderComponent::PlayAnimation(user, u"rebuild-celebrate", 1.09f);
}
void RebuildComponent::ResetRebuild(bool failed) {
@ -527,7 +528,7 @@ void RebuildComponent::ResetRebuild(bool failed) {
GameMessages::SendEnableRebuild(m_Parent, false, false, failed, eQuickBuildFailReason::NOT_GIVEN, m_ResetTime, builder->GetObjectID());
if (failed) {
GameMessages::SendPlayAnimation(builder, u"rebuild-fail");
RenderComponent::PlayAnimation(builder, u"rebuild-fail");
}
}

View File

@ -11,72 +11,36 @@
#include "GameMessages.h"
#include "Game.h"
#include "dLogger.h"
#include "CDAnimationsTable.h"
std::unordered_map<int32_t, float> RenderComponent::m_DurationCache{};
RenderComponent::RenderComponent(Entity* parent) : Component(parent) {
RenderComponent::RenderComponent(Entity* parent, int32_t componentId): Component(parent) {
m_Effects = std::vector<Effect*>();
m_LastAnimationName = "";
if (componentId == -1) return;
return;
auto query = CDClientDatabase::CreatePreppedStmt("SELECT * FROM RenderComponent WHERE id = ?;");
query.bind(1, componentId);
auto result = query.execQuery();
/*
auto* table = CDClientManager::Instance().GetTable<CDComponentsRegistryTable>();
const auto entry = table->GetByIDAndType(parent->GetLOT(), eReplicaComponentType::RENDER);
std::stringstream query;
query << "SELECT effect1, effect2, effect3, effect4, effect5, effect6 FROM RenderComponent WHERE id = " << std::to_string(entry) << ";";
auto result = CDClientDatabase::ExecuteQuery(query.str());
if (result.eof())
{
return;
}
for (auto i = 0; i < 6; ++i)
{
if (result.fieldIsNull(i))
{
continue;
}
const auto id = result.getIntField(i);
if (id <= 0)
{
continue;
}
query.clear();
query << "SELECT effectType, effectName FROM BehaviorEffect WHERE effectID = " << std::to_string(id) << ";";
auto effectResult = CDClientDatabase::ExecuteQuery(query.str());
while (!effectResult.eof())
{
const auto type = effectResult.fieldIsNull(0) ? "" : std::string(effectResult.getStringField(0));
const auto name = effectResult.fieldIsNull(1) ? "" : std::string(effectResult.getStringField(1));
auto* effect = new Effect();
effect->name = name;
effect->type = GeneralUtils::ASCIIToUTF16(type);
effect->scale = 1;
effect->effectID = id;
effect->secondary = LWOOBJID_EMPTY;
m_Effects.push_back(effect);
effectResult.nextRow();
if (!result.eof()) {
auto animationGroupIDs = std::string(result.getStringField("animationGroupIDs", ""));
if (!animationGroupIDs.empty()) {
auto* animationsTable = CDClientManager::Instance().GetTable<CDAnimationsTable>();
auto groupIdsSplit = GeneralUtils::SplitString(animationGroupIDs, ',');
for (auto& groupId : groupIdsSplit) {
int32_t groupIdInt;
if (!GeneralUtils::TryParse(groupId, groupIdInt)) {
Game::logger->Log("RenderComponent", "bad animation group Id %s", groupId.c_str());
continue;
}
m_animationGroupIds.push_back(groupIdInt);
animationsTable->CacheAnimationGroup(groupIdInt);
}
}
}
result.finalize();
*/
}
RenderComponent::~RenderComponent() {
@ -224,3 +188,45 @@ void RenderComponent::StopEffect(const std::string& name, const bool killImmedia
std::vector<Effect*>& RenderComponent::GetEffects() {
return m_Effects;
}
float RenderComponent::PlayAnimation(Entity* self, const std::u16string& animation, float priority, float scale) {
if (!self) return 0.0f;
return RenderComponent::PlayAnimation(self, GeneralUtils::UTF16ToWTF8(animation), priority, scale);
}
float RenderComponent::PlayAnimation(Entity* self, const std::string& animation, float priority, float scale) {
if (!self) return 0.0f;
return RenderComponent::DoAnimation(self, animation, true, priority, scale);
}
float RenderComponent::GetAnimationTime(Entity* self, const std::u16string& animation) {
if (!self) return 0.0f;
return RenderComponent::GetAnimationTime(self, GeneralUtils::UTF16ToWTF8(animation));
}
float RenderComponent::GetAnimationTime(Entity* self, const std::string& animation) {
if (!self) return 0.0f;
return RenderComponent::DoAnimation(self, animation, false);
}
float RenderComponent::DoAnimation(Entity* self, const std::string& animation, bool sendAnimation, float priority, float scale) {
float returnlength = 0.0f;
if (!self) return returnlength;
auto* renderComponent = self->GetComponent<RenderComponent>();
if (!renderComponent) return returnlength;
auto* animationsTable = CDClientManager::Instance().GetTable<CDAnimationsTable>();
for (auto& groupId : renderComponent->m_animationGroupIds) {
auto animationGroup = animationsTable->GetAnimation(animation, renderComponent->GetLastAnimationName(), groupId);
if (animationGroup.FoundData()) {
auto data = animationGroup.Data();
renderComponent->SetLastAnimationName(data.animation_name);
returnlength = data.animation_length;
}
}
if (sendAnimation) GameMessages::SendPlayAnimation(self, GeneralUtils::ASCIIToUTF16(animation), priority, scale);
if (returnlength == 0.0f) Game::logger->Log("RenderComponent", "WARNING: Unable to find animation %s for lot %i in any group.", animation.c_str(), self->GetLOT());
return returnlength;
}

View File

@ -58,7 +58,7 @@ class RenderComponent : public Component {
public:
static const eReplicaComponentType ComponentType = eReplicaComponentType::RENDER;
RenderComponent(Entity* entity);
RenderComponent(Entity* entity, int32_t componentId = -1);
~RenderComponent() override;
void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags);
@ -104,6 +104,32 @@ public:
*/
std::vector<Effect*>& GetEffects();
/**
* Verifies that an animation can be played on this entity by checking
* if it has the animation assigned to its group. If it does, the animation is echo'd
* down to all clients to be played and the duration of the played animation is returned.
* If the animation did not exist or the function was called in an invalid state, 0 is returned.
*
* The logic here matches the exact client logic.
*
* @param self The entity that wants to play an animation
* @param animation The animation_type (animationID in the client) to be played.
* @param sendAnimation Whether or not to echo the animation down to all clients.
* @param priority The priority of the animation. Only used if sendAnimation is true.
* @param scale The scale of the animation. Only used if sendAnimation is true.
*
* @return The duration of the animation that was played.
*/
static float DoAnimation(Entity* self, const std::string& animation, bool sendAnimation, float priority = 0.0f, float scale = 1.0f);
static float PlayAnimation(Entity* self, const std::u16string& animation, float priority = 0.0f, float scale = 1.0f);
static float PlayAnimation(Entity* self, const std::string& animation, float priority = 0.0f, float scale = 1.0f);
static float GetAnimationTime(Entity* self, const std::string& animation);
static float GetAnimationTime(Entity* self, const std::u16string& animation);
const std::string& GetLastAnimationName() const { return m_LastAnimationName; };
void SetLastAnimationName(const std::string& name) { m_LastAnimationName = name; };
private:
/**
@ -111,6 +137,11 @@ private:
*/
std::vector<Effect*> m_Effects;
std::vector<int32_t> m_animationGroupIds;
// The last animationName that was played
std::string m_LastAnimationName;
/**
* Cache of queries that look for the length of each effect, indexed by effect ID
*/

View File

@ -1,6 +1,7 @@
#include "SwitchComponent.h"
#include "EntityManager.h"
#include "eTriggerEventType.h"
#include "RenderComponent.h"
std::vector<SwitchComponent*> SwitchComponent::petSwitches;
@ -59,7 +60,7 @@ void SwitchComponent::EntityEnter(Entity* entity) {
if (m_PetBouncer != nullptr) {
GameMessages::SendPlayFXEffect(m_Parent->GetObjectID(), 2602, u"pettriggeractive", "BounceEffect", LWOOBJID_EMPTY, 1, 1, true);
GameMessages::SendPlayAnimation(m_Parent, u"engaged", 0, 1);
RenderComponent::PlayAnimation(m_Parent, u"engaged");
m_PetBouncer->SetPetBouncerEnabled(true);
} else {
EntityManager::Instance()->SerializeEntity(m_Parent);

View File

@ -70,6 +70,7 @@
#include "PetComponent.h"
#include "ModuleAssemblyComponent.h"
#include "VehiclePhysicsComponent.h"
#include "RenderComponent.h"
#include "PossessableComponent.h"
#include "PossessorComponent.h"
#include "RacingControlComponent.h"
@ -5125,7 +5126,7 @@ void GameMessages::HandlePlayEmote(RakNet::BitStream* inStream, Entity* entity)
if (emote) sAnimationName = emote->animationName;
}
GameMessages::SendPlayAnimation(entity, GeneralUtils::ASCIIToUTF16(sAnimationName));
RenderComponent::PlayAnimation(entity, sAnimationName);
}
void GameMessages::HandleModularBuildConvertModel(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) {

View File

@ -77,6 +77,7 @@
#include "eObjectBits.h"
#include "eGameMasterLevel.h"
#include "eReplicaComponentType.h"
#include "RenderComponent.h"
#include "eControlScheme.h"
#include "eConnectionType.h"
#include "eChatInternalMessageType.h"
@ -411,11 +412,11 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
if ((chatCommand == "playanimation" || chatCommand == "playanim") && args.size() == 1 && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER) {
std::u16string anim = GeneralUtils::ASCIIToUTF16(args[0], args[0].size());
GameMessages::SendPlayAnimation(entity, anim);
RenderComponent::PlayAnimation(entity, anim);
auto* possessorComponent = entity->GetComponent<PossessorComponent>();
if (possessorComponent) {
auto* possessedComponent = EntityManager::Instance()->GetEntity(possessorComponent->GetPossessable());
if (possessedComponent) GameMessages::SendPlayAnimation(possessedComponent, anim);
if (possessedComponent) RenderComponent::PlayAnimation(possessedComponent, anim);
}
}
@ -1947,7 +1948,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
EntityManager::Instance()->SerializeEntity(closest);
} else if (args[1] == "-a" && args.size() >= 3) {
GameMessages::SendPlayAnimation(closest, GeneralUtils::UTF8ToUTF16(args[2]));
RenderComponent::PlayAnimation(closest, args.at(2));
} else if (args[1] == "-s") {
for (auto* entry : closest->GetSettings()) {
ChatPackets::SendSystemMessage(sysAddr, GeneralUtils::UTF8ToUTF16(entry->GetString()));

View File

@ -50,6 +50,7 @@ namespace Game {
dConfig* config = nullptr;
AssetManager* assetManager = nullptr;
bool shouldShutdown = false;
std::mt19937 randomEngine;
} //namespace Game
bool shutdownSequenceStarted = false;
@ -291,6 +292,7 @@ int main(int argc, char** argv) {
return EXIT_SUCCESS;
}
Game::randomEngine = std::mt19937(time(0));
uint32_t maxClients = 999;
uint32_t ourPort = 1000;
if (Game::config->GetValue("max_clients") != "") maxClients = std::stoi(Game::config->GetValue("max_clients"));

View File

@ -2,6 +2,7 @@
#include "GameMessages.h"
#include "dServer.h"
#include "VanityUtilities.h"
#include "RenderComponent.h"
void DLUVanityNPC::OnStartup(Entity* self) {
m_NPC = VanityUtilities::GetNPC("averysumner - Destroyer of Worlds");
@ -17,7 +18,7 @@ void DLUVanityNPC::OnStartup(Entity* self) {
void DLUVanityNPC::OnTimerDone(Entity* self, std::string timerName) {
if (timerName == "setupTeleport") {
GameMessages::SendPlayAnimation(self, u"interact");
RenderComponent::PlayAnimation(self, u"interact");
GameMessages::SendPlayFXEffect(self->GetObjectID(), 6478, u"teleportBeam", "teleportBeam");
GameMessages::SendPlayFXEffect(self->GetObjectID(), 6478, u"teleportRings", "teleportRings");

View File

@ -14,6 +14,7 @@
#include "GameMessages.h"
#include "SkillComponent.h"
#include "eReplicaComponentType.h"
#include "RenderComponent.h"
#include <vector>
@ -616,11 +617,11 @@ float BossSpiderQueenEnemyServer::PlayAnimAndReturnTime(Entity* self, const std:
//TODO: Get the actual animation time
// Get the anim time
float animTimer = defaultAnimPause; //self:GetAnimationTime{animationID = animID}.time
float animTimer = RenderComponent::GetAnimationTime(self, animID);
// If we have an animation play it
if (animTimer > 0) {
GameMessages::SendPlayAnimation(self, animID);
animTimer = RenderComponent::PlayAnimation(self, animID);
}
// If the anim time is less than the the default time use default

View File

@ -7,6 +7,7 @@
#include "BaseCombatAIComponent.h"
#include "EntityInfo.h"
#include "eAninmationFlags.h"
#include "RenderComponent.h"
void AmDarklingDragon::OnStartup(Entity* self) {
self->SetVar<int32_t>(u"weakspot", 0);
@ -70,9 +71,9 @@ void AmDarklingDragon::OnHitOrHealResult(Entity* self, Entity* attacker, int32_t
self->SetVar<int32_t>(u"weakpoint", 2);
GameMessages::SendChangeIdleFlags(self->GetObjectID(), eAnimationFlags::IDLE_NONE, eAnimationFlags::IDLE_COMBAT, UNASSIGNED_SYSTEM_ADDRESS);
GameMessages::SendPlayAnimation(self, u"stunstart", 1.7f);
float animationTime = RenderComponent::PlayAnimation(self, u"stunstart", 1.7f);
self->AddTimer("timeToStunLoop", 1);
self->AddTimer("timeToStunLoop", 1.0f);
auto position = self->GetPosition();
auto forward = self->GetRotation().GetForwardVector();
@ -121,9 +122,9 @@ void AmDarklingDragon::OnTimerDone(Entity* self, std::string timerName) {
} else if (timerName == "ExposeWeakSpotTimer") {
self->SetVar<int32_t>(u"weakspot", 1);
} else if (timerName == "timeToStunLoop") {
GameMessages::SendPlayAnimation(self, u"stunloop", 1.8f);
RenderComponent::PlayAnimation(self, u"stunloop", 1.8f);
} else if (timerName == "ReviveTimer") {
GameMessages::SendPlayAnimation(self, u"stunend", 2.0f);
RenderComponent::PlayAnimation(self, u"stunend", 2.0f);
self->AddTimer("backToAttack", 1);
} else if (timerName == "backToAttack") {
auto* baseCombatAIComponent = self->GetComponent<BaseCombatAIComponent>();
@ -153,5 +154,5 @@ void AmDarklingDragon::OnFireEventServerSide(Entity* self, Entity* sender, std::
self->SetVar<LWOOBJID>(u"Golem", sender->GetObjectID());
GameMessages::SendPlayAnimation(self, u"quickbuildhold", 1.9f);
RenderComponent::PlayAnimation(self, u"quickbuildhold", 1.9f);
}

View File

@ -5,6 +5,7 @@
#include "DestroyableComponent.h"
#include "eAninmationFlags.h"
#include "EntityInfo.h"
#include "RenderComponent.h"
void FvMaelstromDragon::OnStartup(Entity* self) {
self->SetVar<int32_t>(u"weakspot", 0);
@ -86,9 +87,9 @@ void FvMaelstromDragon::OnHitOrHealResult(Entity* self, Entity* attacker, int32_
self->SetVar<int32_t>(u"weakpoint", 2);
GameMessages::SendChangeIdleFlags(self->GetObjectID(), eAnimationFlags::IDLE_NONE, eAnimationFlags::IDLE_COMBAT, UNASSIGNED_SYSTEM_ADDRESS);
GameMessages::SendPlayAnimation(self, u"stunstart", 1.7f);
RenderComponent::PlayAnimation(self, u"stunstart", 1.7f);
self->AddTimer("timeToStunLoop", 1);
self->AddTimer("timeToStunLoop", 1.0f);
auto position = self->GetPosition();
auto forward = self->GetRotation().GetForwardVector();
@ -137,10 +138,10 @@ void FvMaelstromDragon::OnTimerDone(Entity* self, std::string timerName) {
} else if (timerName == "ExposeWeakSpotTimer") {
self->SetVar<int32_t>(u"weakspot", 1);
} else if (timerName == "timeToStunLoop") {
GameMessages::SendPlayAnimation(self, u"stunloop", 1.8f);
RenderComponent::PlayAnimation(self, u"stunloop", 1.8f);
} else if (timerName == "ReviveTimer") {
GameMessages::SendPlayAnimation(self, u"stunend", 2.0f);
self->AddTimer("backToAttack", 1);
RenderComponent::PlayAnimation(self, u"stunend", 2.0f);
self->AddTimer("backToAttack", 1.0f);
} else if (timerName == "backToAttack") {
auto* baseCombatAIComponent = self->GetComponent<BaseCombatAIComponent>();
auto* skillComponent = self->GetComponent<SkillComponent>();
@ -174,5 +175,5 @@ FvMaelstromDragon::OnFireEventServerSide(Entity* self, Entity* sender, std::stri
self->SetVar<LWOOBJID>(u"Golem", sender->GetObjectID());
GameMessages::SendPlayAnimation(self, u"quickbuildhold", 1.9f);
RenderComponent::PlayAnimation(self, u"quickbuildhold", 1.9f);
}

View File

@ -6,6 +6,7 @@
#include "EntityInfo.h"
#include "SkillComponent.h"
#include "eAninmationFlags.h"
#include "RenderComponent.h"
#include "eStateChangeType.h"
void BaseEnemyApe::OnStartup(Entity* self) {
@ -38,7 +39,7 @@ void BaseEnemyApe::OnHit(Entity* self, Entity* attacker) {
if (skillComponent) {
skillComponent->Reset();
}
GameMessages::SendPlayAnimation(self, u"disable", 1.7f);
RenderComponent::PlayAnimation(self, u"disable", 1.7f);
GameMessages::SendChangeIdleFlags(self->GetObjectID(), eAnimationFlags::IDLE_NONE, eAnimationFlags::IDLE_COMBAT, UNASSIGNED_SYSTEM_ADDRESS);
const auto reviveTime = self->GetVar<float_t>(u"reviveTime") != 0.0f
? self->GetVar<float_t>(u"reviveTime") : 12.0f;

View File

@ -1,6 +1,8 @@
#include "GfApeSmashingQB.h"
#include "EntityManager.h"
#include "GameMessages.h"
#include "Entity.h"
#include "RenderComponent.h"
void GfApeSmashingQB::OnStartup(Entity* self) {
self->SetNetworkVar<LWOOBJID>(u"lootTagOwner", self->GetVar<LWOOBJID>(u"lootTagOwner"));
@ -16,7 +18,7 @@ void GfApeSmashingQB::OnRebuildComplete(Entity* self, Entity* target) {
auto* ape = EntityManager::Instance()->GetEntity(self->GetVar<LWOOBJID>(u"ape"));
if (ape != nullptr) {
ape->OnFireEventServerSide(target, "rebuildDone");
GameMessages::SendPlayAnimation(self, u"smash", 1.7f);
RenderComponent::PlayAnimation(self, u"smash", 1.7f);
self->AddTimer("anchorBreakTime", 1.0f);
}
}

View File

@ -4,19 +4,18 @@
#include "EntityManager.h"
#include "MissionComponent.h"
#include "eMissionTaskType.h"
#include "RenderComponent.h"
void MaestromExtracticatorServer::OnStartup(Entity* self) {
//self:SetNetworkVar("current_anim", failAnim)
GameMessages::SendPlayAnimation(self, GeneralUtils::ASCIIToUTF16(failAnim));
float animTime = RenderComponent::PlayAnimation(self, failAnim);
if (animTime == 0.0f) animTime = defaultTime;
self->AddTimer("PlayFail", defaultTime);
self->AddTimer("PlayFail", animTime);
self->AddTimer("RemoveSample", destroyAfterNoSampleTime);
}
void MaestromExtracticatorServer::OnFireEventServerSide(Entity* self, Entity* sender, std::string args, int32_t param1,
int32_t param2, int32_t param3) {
if (sender == nullptr)
return;
void MaestromExtracticatorServer::OnFireEventServerSide(Entity* self, Entity* sender, std::string args, int32_t param1, int32_t param2, int32_t param3) {
if (sender == nullptr) return;
if (args == "attemptCollection") {
Entity* player = EntityManager::Instance()->GetEntity(self->GetSpawnerID());
@ -32,20 +31,17 @@ void MaestromExtracticatorServer::OnFireEventServerSide(Entity* self, Entity* se
}
void MaestromExtracticatorServer::CollectSample(Entity* self, LWOOBJID sampleObj) {
PlayAnimAndReturnTime(self, collectAnim);
self->AddTimer("RemoveSample", defaultTime);
self->AddTimer("RemoveSample", PlayAnimAndReturnTime(self, collectAnim));
}
void MaestromExtracticatorServer::PlayAnimAndReturnTime(Entity* self, std::string animID) {
GameMessages::SendPlayAnimation(self, GeneralUtils::ASCIIToUTF16(animID));
float MaestromExtracticatorServer::PlayAnimAndReturnTime(Entity* self, std::string animID) {
return RenderComponent::PlayAnimation(self, animID);
}
void MaestromExtracticatorServer::OnTimerDone(Entity* self, std::string timerName) {
if (timerName == "RemoveSample") {
self->ScheduleKillAfterUpdate();
}
if (timerName == "PlayFail") {
GameMessages::SendPlayAnimation(self, GeneralUtils::ASCIIToUTF16(failAnim));
} else if (timerName == "PlayFail") {
RenderComponent::PlayAnimation(self, failAnim);
}
}

View File

@ -7,7 +7,7 @@ public:
void OnFireEventServerSide(Entity* self, Entity* sender, std::string args, int32_t param1, int32_t param2,
int32_t param3);
void CollectSample(Entity* self, LWOOBJID sampleObj);
void PlayAnimAndReturnTime(Entity* self, std::string animID);
float PlayAnimAndReturnTime(Entity* self, std::string animID);
void OnTimerDone(Entity* self, std::string timerName);
private:

View File

@ -1,5 +1,8 @@
#include "AgMonumentBirds.h"
#include "GameMessages.h"
#include "Entity.h"
#include "RenderComponent.h"
#include "EntityManager.h"
//--------------------------------------------------------------
//Makes the ag birds fly away when you get close and smashes them.
@ -16,7 +19,7 @@ void AgMonumentBirds::OnProximityUpdate(Entity* self, Entity* entering, std::str
if (name == "MonumentBirds" && status == "ENTER") {
self->AddTimer("killBird", 1.0f);
GameMessages::SendPlayAnimation(self, sOnProximityAnim);
RenderComponent::PlayAnimation(self, sOnProximityAnim);
self->SetVar<bool>(u"IsFlying", true);
self->SetVar<LWOOBJID>(u"PlayerID", entering->GetObjectID());
}

View File

@ -5,6 +5,7 @@
#include "ProximityMonitorComponent.h"
#include "MissionComponent.h"
#include "EntityInfo.h"
#include "RenderComponent.h"
#include "eStateChangeType.h"
void AmSkullkinDrill::OnStartup(Entity* self) {
@ -71,7 +72,7 @@ void AmSkullkinDrill::OnSkillEventFired(Entity* self, Entity* caster, const std:
}
void AmSkullkinDrill::TriggerDrill(Entity* self) {
GameMessages::SendPlayAnimation(self, u"slowdown");
RenderComponent::PlayAnimation(self, u"slowdown");
self->AddTimer("killDrill", 10.0f);
@ -171,7 +172,7 @@ void AmSkullkinDrill::OnArrived(Entity* self, uint32_t waypointIndex) {
auto* standObj = GetStandObj(self);
if (waypointIndex == 1) {
GameMessages::SendPlayAnimation(self, u"no-spin");
RenderComponent::PlayAnimation(self, u"no-spin");
GameMessages::SendStopFXEffect(self, true, "active");
GameMessages::SendPlayFXEffect(self->GetObjectID(), -1, u"indicator", "indicator");
@ -191,7 +192,7 @@ void AmSkullkinDrill::OnArrived(Entity* self, uint32_t waypointIndex) {
return;
} else {
GameMessages::SendPlayAnimation(self, u"idle");
RenderComponent::PlayAnimation(self, u"idle");
GameMessages::SendPlayFXEffect(self->GetObjectID(), -1, u"spin", "active");
GameMessages::SendStopFXEffect(self, true, "indicator");
}
@ -216,7 +217,7 @@ void AmSkullkinDrill::PlayCinematic(Entity* self) {
void AmSkullkinDrill::PlayAnim(Entity* self, Entity* player, const std::string& animName) {
const auto animTime = animName == "spinjitzu-staff-end" ? 0.5f : 1.0f;
GameMessages::SendPlayAnimation(player, GeneralUtils::ASCIIToUTF16(animName));
RenderComponent::PlayAnimation(player, animName);
self->AddTimer("AnimDone_" + animName, animTime);
}
@ -309,7 +310,7 @@ void AmSkullkinDrill::OnTimerDone(Entity* self, std::string timerName) {
if (animName == "spinjitzu-staff-windup") {
TriggerDrill(self);
GameMessages::SendPlayAnimation(player, u"spinjitzu-staff-loop");
RenderComponent::PlayAnimation(player, u"spinjitzu-staff-loop");
} else if (animName == "spinjitzu-staff-end") {
FreezePlayer(self, player, false);

View File

@ -1,6 +1,8 @@
#include "AmSkullkinDrillStand.h"
#include "GameMessages.h"
#include "dpEntity.h"
#include "Entity.h"
#include "RenderComponent.h"
void AmSkullkinDrillStand::OnStartup(Entity* self) {
self->SetVar(u"bActive", true);
@ -31,5 +33,5 @@ void AmSkullkinDrillStand::OnProximityUpdate(Entity* self, Entity* entering, std
GameMessages::SendPlayFXEffect(entering->GetObjectID(), 1378, u"create", "pushBack");
GameMessages::SendPlayAnimation(entering, u"knockback-recovery");
RenderComponent::PlayAnimation(entering, u"knockback-recovery");
}

View File

@ -5,6 +5,7 @@
#include "EntityInfo.h"
#include "GameMessages.h"
#include "MissionComponent.h"
#include "RenderComponent.h"
void AmSkullkinTower::OnStartup(Entity* self) {
self->SetProximityRadius(20, "Tower");
@ -117,13 +118,13 @@ void AmSkullkinTower::OnChildRemoved(Entity* self, Entity* child) {
self->SetVar(u"legTable", legTable);
if (legTable.size() == 2) {
GameMessages::SendPlayAnimation(self, u"wobble-1");
RenderComponent::PlayAnimation(self, u"wobble-1");
} else if (legTable.size() == 1) {
GameMessages::SendPlayAnimation(self, u"wobble-2");
RenderComponent::PlayAnimation(self, u"wobble-2");
} else if (legTable.empty()) {
const auto animTime = 2.5f;
GameMessages::SendPlayAnimation(self, u"fall");
RenderComponent::PlayAnimation(self, u"fall");
self->AddTimer("spawnGuys", animTime - 0.2f);

View File

@ -2,6 +2,7 @@
#include "GameMessages.h"
#include "EntityManager.h"
#include "MissionComponent.h"
#include "RenderComponent.h"
#include "eTerminateType.h"
#include "eStateChangeType.h"
@ -29,7 +30,7 @@ void GfCaptainsCannon::OnUse(Entity* self, Entity* user) {
GameMessages::SendTeleport(user->GetObjectID(), position, rotation, user->GetSystemAddress());
GameMessages::SendPlayAnimation(user, u"cannon-strike-no-equip");
RenderComponent::PlayAnimation(user, u"cannon-strike-no-equip");
GameMessages::SendPlayFXEffect(user->GetObjectID(), 6039, u"hook", "hook", LWOOBJID_EMPTY, 1, 1, true);
@ -60,7 +61,7 @@ void GfCaptainsCannon::OnTimerDone(Entity* self, std::string timerName) {
for (auto* shark : sharkObjects) {
if (shark->GetLOT() != m_SharkItemID) continue;
GameMessages::SendPlayAnimation(shark, u"cannon");
RenderComponent::PlayAnimation(shark, u"cannon");
}
GameMessages::SendPlay2DAmbientSound(player, "{7457d85c-4537-4317-ac9d-2f549219ea87}");

View File

@ -5,6 +5,7 @@
#include "RenderComponent.h"
#include "eMissionTaskType.h"
#include "eReplicaComponentType.h"
#include "RenderComponent.h"
#include "eTerminateType.h"
void GfTikiTorch::OnStartup(Entity* self) {
@ -17,7 +18,7 @@ void GfTikiTorch::OnUse(Entity* self, Entity* killer) {
return;
}
GameMessages::SendPlayAnimation(self, u"interact");
RenderComponent::PlayAnimation(self, u"interact");
self->SetI64(u"userID", killer->GetObjectID());
for (int i = 0; i < m_numspawn; i++) {
@ -56,7 +57,7 @@ void GfTikiTorch::LightTorch(Entity* self) {
void GfTikiTorch::OnSkillEventFired(Entity* self, Entity* caster, const std::string& message) {
if (self->GetBoolean(u"isBurning") && message == "waterspray") {
GameMessages::SendPlayAnimation(self, u"water");
RenderComponent::PlayAnimation(self, u"water");
auto* renderComponent = self->GetComponent<RenderComponent>();
if (renderComponent != nullptr) {

View File

@ -10,6 +10,7 @@
#define _USE_MATH_DEFINES
#include <math.h>
#endif
#include "RenderComponent.h"
void MastTeleport::OnStartup(Entity* self) {
self->SetNetworkVar<std::string>(u"hookPreconditions", "154;44", UNASSIGNED_SYSTEM_ADDRESS);
@ -63,11 +64,12 @@ void MastTeleport::OnTimerDone(Entity* self, std::string timerName) {
GameMessages::SendPlayFXEffect(playerId, 6039, u"hook", "hook", LWOOBJID_EMPTY, 1, 1, true);
GameMessages::SendPlayAnimation(player, u"crow-swing-no-equip", 4.0f);
float animationTime = 6.25f;
animationTime = RenderComponent::PlayAnimation(player, "crow-swing-no-equip", 4.0f);
GameMessages::SendPlayAnimation(self, u"swing");
RenderComponent::PlayAnimation(self, u"swing");
self->AddTimer("PlayerAnimDone", 6.25f);
self->AddTimer("PlayerAnimDone", animationTime);
} else if (timerName == "PlayerAnimDone") {
GameMessages::SendStopFXEffect(player, true, "hook");

View File

@ -4,6 +4,7 @@
#include "MissionComponent.h"
#include "SkillComponent.h"
#include "eMissionTaskType.h"
#include "RenderComponent.h"
//TODO: this has to be updated so that you only get killed if you're in a certain radius.
//And so that all entities in a certain radius are killed, not just the attacker.
@ -69,23 +70,6 @@ void ExplodingAsset::OnHit(Entity* self, Entity* attacker) {
}
void ExplodingAsset::OnProximityUpdate(Entity* self, Entity* entering, std::string name, std::string status) {
/*
if msg.objId:BelongsToFaction{factionID = 1}.bIsInFaction then
if (msg.status == "ENTER") then
self:PlayAnimation{ animationID = "bounce" }
self:PlayFXEffect{ name = "bouncin", effectType = "anim" }
self:SetVar("playersNearChest", (self:GetVar("playersNearChest") + 1 ))
elseif (msg.status == "LEAVE") then
self:SetVar("playersNearChest", (self:GetVar("playersNearChest") - 1 ))
if self:GetVar("playersNearChest") < 1 then
self:PlayAnimation{ animationID = "idle" }
self:StopFXEffect{ name = "bouncin" }
self:SetVar("playersNearChest", 0)
end
end
end
*/
auto* destuctableComponent = entering->GetComponent<DestroyableComponent>();
if (destuctableComponent == nullptr) return;
@ -95,14 +79,14 @@ void ExplodingAsset::OnProximityUpdate(Entity* self, Entity* entering, std::stri
if (!std::count(factions.begin(), factions.end(), 1)) return;
if (status == "ENTER") {
GameMessages::SendPlayAnimation(self, u"bounce");
RenderComponent::PlayAnimation(self, u"bounce");
GameMessages::SendPlayFXEffect(self, -1, u"anim", "bouncin", LWOOBJID_EMPTY, 1, 1, true);
self->SetVar(u"playersNearChest", self->GetVar<int32_t>(u"playersNearChest") + 1);
} else if (status == "LEAVE") {
self->SetVar(u"playersNearChest", self->GetVar<int32_t>(u"playersNearChest") - 1);
if (self->GetVar<int32_t>(u"playersNearChest") < 1) {
GameMessages::SendPlayAnimation(self, u"idle");
RenderComponent::PlayAnimation(self, u"idle");
GameMessages::SendStopFXEffect(self, true, "bouncin");
self->SetVar<int32_t>(u"playersNearChest", 0);
}

View File

@ -1,6 +1,8 @@
#include "NjIceRailActivator.h"
#include "EntityManager.h"
#include "GameMessages.h"
#include "Entity.h"
#include "RenderComponent.h"
void NjIceRailActivator::OnPlayerRailArrived(Entity* self, Entity* sender, const std::u16string& pathName,
int32_t waypoint) {
@ -9,7 +11,7 @@ void NjIceRailActivator::OnPlayerRailArrived(Entity* self, Entity* sender, const
const auto& blockGroup = self->GetVar<std::u16string>(BlockGroupVariable);
for (auto* block : EntityManager::Instance()->GetEntitiesInGroup(GeneralUtils::UTF16ToWTF8(blockGroup))) {
GameMessages::SendPlayAnimation(block, u"explode");
RenderComponent::PlayAnimation(block, u"explode");
const auto blockID = block->GetObjectID();

View File

@ -4,6 +4,7 @@
#include "MissionComponent.h"
#include "eMissionTaskType.h"
#include "eMissionState.h"
#include "RenderComponent.h"
#include "eEndBehavior.h"
#include "eStateChangeType.h"
@ -51,7 +52,7 @@ void NtAssemblyTubeServer::RunAssemblyTube(Entity* self, Entity* player) {
);
}
GameMessages::SendPlayAnimation(player, u"tube-sucker", 4.0f);
RenderComponent::PlayAnimation(player, u"tube-sucker", 4.0f);
const auto animTime = 3;
@ -84,7 +85,7 @@ void NtAssemblyTubeServer::TeleportPlayer(Entity* self, Entity* player) {
GameMessages::SendTeleport(player->GetObjectID(), destPosition, destRotation, player->GetSystemAddress(), true);
GameMessages::SendPlayAnimation(player, u"tube-resurrect", 4.0f);
RenderComponent::PlayAnimation(player, u"tube-resurrect", 4.0f);
const auto animTime = 2;

View File

@ -4,6 +4,7 @@
#include "EntityManager.h"
#include "Character.h"
#include "eMissionState.h"
#include "RenderComponent.h"
#include "eTerminateType.h"
#include "eStateChangeType.h"
@ -34,18 +35,18 @@ void NtParadoxPanelServer::OnUse(Entity* self, Entity* user) {
player->GetCharacter()->SetPlayerFlag(flag, true);
GameMessages::SendPlayAnimation(player, u"rebuild-celebrate");
RenderComponent::PlayAnimation(player, u"rebuild-celebrate");
GameMessages::SendNotifyClientObject(self->GetObjectID(), u"SparkStop", 0, 0, player->GetObjectID(), "", player->GetSystemAddress());
GameMessages::SendSetStunned(player->GetObjectID(), eStateChangeType::POP, player->GetSystemAddress(), LWOOBJID_EMPTY, false, false, true, false, true, true, false, false, true);
self->SetVar(u"bActive", false);
});
GameMessages::SendPlayAnimation(user, u"nexus-powerpanel", 6.0f);
RenderComponent::PlayAnimation(user, u"nexus-powerpanel", 6.0f);
GameMessages::SendSetStunned(user->GetObjectID(), eStateChangeType::PUSH, user->GetSystemAddress(), LWOOBJID_EMPTY, false, false, true, false, true, true, false, false, true);
return;
}
GameMessages::SendPlayAnimation(user, shockAnim);
RenderComponent::PlayAnimation(user, shockAnim);
const auto dir = self->GetRotation().GetRightVector();

View File

@ -3,6 +3,7 @@
#include "EntityManager.h"
#include "MissionComponent.h"
#include "eMissionTaskType.h"
#include "RenderComponent.h"
#include "eStateChangeType.h"
void NtParadoxTeleServer::OnStartup(Entity* self) {
@ -28,9 +29,8 @@ void NtParadoxTeleServer::OnProximityUpdate(Entity* self, Entity* entering, std:
true, true, true, true, true, true, true
);
GameMessages::SendPlayAnimation(player, u"teledeath", 4.0f);
const auto animTime = 2;
auto animTime = RenderComponent::PlayAnimation(player, u"teledeath", 4.0f);
if (animTime == 0.0f) animTime = 2.0f;
self->AddCallbackTimer(animTime, [this, self, playerID]() {
auto* player = EntityManager::Instance()->GetEntity(playerID);
@ -74,7 +74,7 @@ void NtParadoxTeleServer::TeleportPlayer(Entity* self, Entity* player) {
GameMessages::SendTeleport(player->GetObjectID(), destPosition, destRotation, player->GetSystemAddress(), true);
GameMessages::SendPlayAnimation(player, u"paradox-teleport-in", 4.0f);
RenderComponent::PlayAnimation(player, u"paradox-teleport-in", 4.0f);
const auto animTime = 2;

View File

@ -1,6 +1,7 @@
#include "NtSleepingGuard.h"
#include "GameMessages.h"
#include "MissionComponent.h"
#include "RenderComponent.h"
void NtSleepingGuard::OnStartup(Entity* self) {
self->SetNetworkVar<bool>(u"asleep", true);
@ -17,7 +18,7 @@ void NtSleepingGuard::OnEmoteReceived(Entity* self, const int32_t emote, Entity*
// Set asleep to false
self->SetNetworkVar<bool>(u"asleep", false);
GameMessages::SendPlayAnimation(self, u"greet");
RenderComponent::PlayAnimation(self, u"greet");
auto* missionComponent = target->GetComponent<MissionComponent>();

View File

@ -1,6 +1,9 @@
#include "NtVentureCannonServer.h"
#include "GameMessages.h"
#include "EntityManager.h"
#include "Entity.h"
#include "GeneralUtils.h"
#include "RenderComponent.h"
#include "eEndBehavior.h"
#include "eTerminateType.h"
#include "eStateChangeType.h"
@ -29,7 +32,7 @@ void NtVentureCannonServer::OnUse(Entity* self, Entity* user) {
GameMessages::SendTeleport(playerID, destPosition, destRotation, player->GetSystemAddress(), true);
GameMessages::SendPlayAnimation(player, u"scale-down", 4.0f);
RenderComponent::PlayAnimation(player, u"scale-down", 4.0f);
const auto enterCinematicUname = enterCinematic;
GameMessages::SendPlayCinematic(player->GetObjectID(), enterCinematicUname, player->GetSystemAddress());
@ -121,5 +124,5 @@ void NtVentureCannonServer::FirePlayer(Entity* self, Entity* player) {
GameMessages::SendTeleport(player->GetObjectID(), destPosition, destRotation, player->GetSystemAddress(), true);
GameMessages::SendPlayAnimation(player, u"venture-cannon-out", 4.0f);
RenderComponent::PlayAnimation(player, u"venture-cannon-out", 4.0f);
}

View File

@ -1,6 +1,8 @@
#include "CatapultBaseServer.h"
#include "GameMessages.h"
#include "EntityManager.h"
#include "Entity.h"
#include "RenderComponent.h"
void CatapultBaseServer::OnNotifyObject(Entity* self, Entity* sender, const std::string& name, int32_t param1, int32_t param2) {
if (name == "BouncerBuilt") {
@ -21,7 +23,7 @@ void CatapultBaseServer::OnTimerDone(Entity* self, std::string timerName) {
// tell the arm to the play the platform animation, which is just the arm laying there but with bouncer
for (auto* obj : arm) {
GameMessages::SendPlayAnimation(obj, u"idle-platform");
RenderComponent::PlayAnimation(obj, u"idle-platform");
GameMessages::SendPlayNDAudioEmitter(obj, UNASSIGNED_SYSTEM_ADDRESS, "{8cccf912-69e3-4041-a20b-63e4afafc993}");
// set the art so we can use it again
self->SetVar(u"Arm", obj->GetObjectID());
@ -38,7 +40,7 @@ void CatapultBaseServer::OnTimerDone(Entity* self, std::string timerName) {
// tell the arm to player the launcher animation
auto animTime = 1;
self->AddTimer("resetArm", animTime);
GameMessages::SendPlayAnimation(arm, u"launch");
RenderComponent::PlayAnimation(arm, u"launch");
} else if (timerName == "bounce") {
auto* bouncer = EntityManager::Instance()->GetEntity(self->GetVar<LWOOBJID>(u"Bouncer"));
if (bouncer == nullptr) return;
@ -52,7 +54,7 @@ void CatapultBaseServer::OnTimerDone(Entity* self, std::string timerName) {
if (arm == nullptr) return;
// set the arm back to natural state
GameMessages::SendPlayAnimation(arm, u"idle");
RenderComponent::PlayAnimation(arm, u"idle");
auto* bouncer = EntityManager::Instance()->GetEntity(self->GetVar<LWOOBJID>(u"Bouncer"));
if (bouncer == nullptr) return;

View File

@ -4,6 +4,7 @@
#include "GameMessages.h"
#include "Character.h"
#include "dZoneManager.h"
#include "RenderComponent.h"
void CavePrisonCage::OnStartup(Entity* self) {
const auto& myNum = self->GetVar<std::u16string>(u"myNumber");
@ -101,7 +102,7 @@ void CavePrisonCage::SpawnCounterweight(Entity* self, Spawner* spawner) {
}
// Play the 'down' animation on the button
GameMessages::SendPlayAnimation(button, u"down");
RenderComponent::PlayAnimation(button, u"down");
// Setup a timer named 'buttonGoingDown' to be triggered in 5 seconds
self->AddTimer("buttonGoingDown", 5.0f);
@ -136,13 +137,13 @@ void CavePrisonCage::OnTimerDone(Entity* self, std::string timerName) {
// the anim of the button down is over
if (timerName == "buttonGoingDown") {
// Play the 'up' animation
GameMessages::SendPlayAnimation(self, u"up");
RenderComponent::PlayAnimation(self, u"up");
// Setup a timer named 'CageOpen' to be triggered in 1 second
self->AddTimer("CageOpen", 1.0f);
} else if (timerName == "CageOpen") {
// play the idle open anim
GameMessages::SendPlayAnimation(self, u"idle-up");
RenderComponent::PlayAnimation(self, u"idle-up");
// Get the villeger
auto* villager = EntityManager::Instance()->GetEntity(self->GetVar<LWOOBJID>(u"villager"));
@ -199,13 +200,13 @@ void CavePrisonCage::OnTimerDone(Entity* self, std::string timerName) {
}
// Play the 'up' animation on the button
GameMessages::SendPlayAnimation(button, u"up");
RenderComponent::PlayAnimation(button, u"up");
// Setup a timer named 'CageClosed' to be triggered in 1 second
self->AddTimer("CageClosed", 1.0f);
} else if (timerName == "CageClosed") {
// play the idle closed anim
GameMessages::SendPlayAnimation(self, u"idle");
RenderComponent::PlayAnimation(self, u"idle");
// Setup a timer named 'ResetPrison' to be triggered in 10 seconds
self->AddTimer("ResetPrison", 10.0f);

View File

@ -9,6 +9,7 @@
#include "SkillComponent.h"
#include "TeamManager.h"
#include <algorithm>
#include "RenderComponent.h"
// // // // // // //
// Event handling //
@ -261,7 +262,7 @@ void NjMonastryBossInstance::HandleCounterWeightSpawned(Entity* self, Entity* co
skillComponent->CalculateBehavior(1635, 39097, frakjaw->GetObjectID(), true, false);
}
GameMessages::SendPlayAnimation(frakjaw, StunnedAnimation);
RenderComponent::PlayAnimation(frakjaw, StunnedAnimation);
GameMessages::SendPlayNDAudioEmitter(frakjaw, UNASSIGNED_SYSTEM_ADDRESS, CounterSmashAudio);
// Before wave 4 we should lower frakjaw from the ledge
@ -281,7 +282,7 @@ void NjMonastryBossInstance::HandleCounterWeightSpawned(Entity* self, Entity* co
}
void NjMonastryBossInstance::HandleLowerFrakjawSpawned(Entity* self, Entity* lowerFrakjaw) {
GameMessages::SendPlayAnimation(lowerFrakjaw, TeleportInAnimation);
RenderComponent::PlayAnimation(lowerFrakjaw, TeleportInAnimation);
self->SetVar<LWOOBJID>(LowerFrakjawVariable, lowerFrakjaw->GetObjectID());
auto* combatAI = lowerFrakjaw->GetComponent<BaseCombatAIComponent>();
@ -401,7 +402,7 @@ void NjMonastryBossInstance::TeleportPlayer(Entity* player, uint32_t position) {
void NjMonastryBossInstance::SummonWave(Entity* self, Entity* frakjaw) {
GameMessages::SendNotifyClientObject(self->GetObjectID(), PlayCinematicNotification, 0, 0, LWOOBJID_EMPTY,
LedgeFrakSummon, UNASSIGNED_SYSTEM_ADDRESS);
GameMessages::SendPlayAnimation(frakjaw, SummonAnimation);
RenderComponent::PlayAnimation(frakjaw, SummonAnimation);
// Stop the music for the first, fourth and fifth wave
const auto wave = self->GetVar<uint32_t>(WaveNumberVariable);
@ -425,7 +426,7 @@ void NjMonastryBossInstance::LowerFrakjawSummon(Entity* self, Entity* frakjaw) {
GameMessages::SendNotifyClientObject(self->GetObjectID(), PlayCinematicNotification, 0, 0,
LWOOBJID_EMPTY, BottomFrakSummon, UNASSIGNED_SYSTEM_ADDRESS);
ActivityTimerStart(self, SpawnWaveTimer, 2.0f, 2.0f);
GameMessages::SendPlayAnimation(frakjaw, SummonAnimation);
RenderComponent::PlayAnimation(frakjaw, SummonAnimation);
}
void NjMonastryBossInstance::RemovePoison(Entity* self) {
@ -444,7 +445,7 @@ void NjMonastryBossInstance::RemovePoison(Entity* self) {
}
void NjMonastryBossInstance::LowerFrakjaw(Entity* self, Entity* frakjaw) {
GameMessages::SendPlayAnimation(frakjaw, TeleportOutAnimation);
RenderComponent::PlayAnimation(frakjaw, TeleportOutAnimation);
ActivityTimerStart(self, LowerFrakjawCamTimer, 2.0f, 2.0f);
GameMessages::SendNotifyClientObject(frakjaw->GetObjectID(), StopMusicNotification, 0, 0,

View File

@ -1,6 +1,8 @@
#include "BaseConsoleTeleportServer.h"
#include "GameMessages.h"
#include "Player.h"
#include "RenderComponent.h"
#include "EntityManager.h"
#include "eTerminateType.h"
#include "eStateChangeType.h"
@ -33,13 +35,11 @@ void BaseConsoleTeleportServer::BaseOnMessageBoxResponse(Entity* self, Entity* s
}
const auto& teleIntroAnim = self->GetVar<std::u16string>(u"teleportAnim");
auto animTime = 3.32999992370605f;
if (!teleIntroAnim.empty()) {
GameMessages::SendPlayAnimation(player, teleIntroAnim);
animTime = RenderComponent::PlayAnimation(player, teleIntroAnim);
}
const auto animTime = 3.32999992370605f;
UpdatePlayerTable(self, player, true);
const auto playerID = player->GetObjectID();

View File

@ -5,6 +5,8 @@
#include "PhantomPhysicsComponent.h"
#include "RenderComponent.h"
#include "eReplicaComponentType.h"
#include "RenderComponent.h"
#include "Entity.h"
void AgFans::OnStartup(Entity* self) {
self->SetVar<bool>(u"alive", true);
@ -34,7 +36,7 @@ void AgFans::ToggleFX(Entity* self, bool hit) {
if (fanVolumes.size() == 0 || !self->GetVar<bool>(u"alive")) return;
if (self->GetVar<bool>(u"on")) {
GameMessages::SendPlayAnimation(self, u"fan-off");
RenderComponent::PlayAnimation(self, u"fan-off");
renderComponent->StopEffect("fanOn");
self->SetVar<bool>(u"on", false);
@ -46,11 +48,11 @@ void AgFans::ToggleFX(Entity* self, bool hit) {
EntityManager::Instance()->SerializeEntity(volume);
if (!hit) {
Entity* fxObj = EntityManager::Instance()->GetEntitiesInGroup(fanGroup + "fx")[0];
GameMessages::SendPlayAnimation(fxObj, u"trigger");
RenderComponent::PlayAnimation(fxObj, u"trigger");
}
}
} else if (!self->GetVar<bool>(u"on") && self->GetVar<bool>(u"alive")) {
GameMessages::SendPlayAnimation(self, u"fan-on");
RenderComponent::PlayAnimation(self, u"fan-on");
renderComponent->PlayEffect(495, u"fanOn", "fanOn");
self->SetVar<bool>(u"on", true);
@ -62,7 +64,7 @@ void AgFans::ToggleFX(Entity* self, bool hit) {
EntityManager::Instance()->SerializeEntity(volume);
if (!hit) {
Entity* fxObj = EntityManager::Instance()->GetEntitiesInGroup(fanGroup + "fx")[0];
GameMessages::SendPlayAnimation(fxObj, u"idle");
RenderComponent::PlayAnimation(fxObj, u"idle");
}
}
}

View File

@ -3,6 +3,7 @@
#include "EntityManager.h"
#include "SkillComponent.h"
#include "eReplicaComponentType.h"
#include "RenderComponent.h"
void AgJetEffectServer::OnUse(Entity* self, Entity* user) {
if (inUse || self->GetLOT() != 6859) return;
@ -23,7 +24,7 @@ void AgJetEffectServer::OnRebuildComplete(Entity* self, Entity* target) {
if (self->GetLOT() != 6209) return;
auto entities = EntityManager::Instance()->GetEntitiesInGroup("Jet_FX");
if (entities.empty()) return;
GameMessages::SendPlayAnimation(entities.at(0), u"jetFX");
RenderComponent::PlayAnimation(entities.at(0), u"jetFX");
// So we can give kill credit to person who build this
builder = target->GetObjectID();

View File

@ -1,11 +1,10 @@
#include "AgSalutingNpcs.h"
#include "GameMessages.h"
#include "RenderComponent.h"
void AgSalutingNpcs::OnEmoteReceived(Entity* self, const int32_t emote, Entity* target) {
if (emote != 356) {
return;
}
GameMessages::SendPlayAnimation(self, u"salutePlayer");
RenderComponent::PlayAnimation(self, u"salutePlayer");
}

View File

@ -1,5 +1,7 @@
#include "AgShipPlayerShockServer.h"
#include "GameMessages.h"
#include "RenderComponent.h"
#include "Entity.h"
#include "eTerminateType.h"
void AgShipPlayerShockServer::OnUse(Entity* self, Entity* user) {
@ -8,7 +10,7 @@ void AgShipPlayerShockServer::OnUse(Entity* self, Entity* user) {
return;
}
active = true;
GameMessages::SendPlayAnimation(user, shockAnim);
RenderComponent::PlayAnimation(user, shockAnim);
GameMessages::SendKnockback(user->GetObjectID(), self->GetObjectID(), self->GetObjectID(), 0, NiPoint3(-20, 10, -20));
GameMessages::SendPlayFXEffect(self, 1430, u"create", "console_sparks", LWOOBJID_EMPTY, 1.0, 1.0, true);

View File

@ -3,6 +3,8 @@
#include "GeneralUtils.h"
#include "GameMessages.h"
#include "EntityManager.h"
#include "RenderComponent.h"
#include "Entity.h"
void AgSpaceStuff::OnStartup(Entity* self) {
self->AddTimer("FloaterScale", 5.0f);
@ -27,13 +29,13 @@ void AgSpaceStuff::OnTimerDone(Entity* self, std::string timerName) {
if (timerName == "FloaterScale") {
int scaleType = GeneralUtils::GenerateRandomNumber<int>(1, 5);
GameMessages::SendPlayAnimation(self, u"scale_0" + GeneralUtils::to_u16string(scaleType));
RenderComponent::PlayAnimation(self, u"scale_0" + GeneralUtils::to_u16string(scaleType));
self->AddTimer("FloaterPath", 0.4);
} else if (timerName == "FloaterPath") {
int pathType = GeneralUtils::GenerateRandomNumber<int>(1, 4);
int randTime = GeneralUtils::GenerateRandomNumber<int>(20, 25);
GameMessages::SendPlayAnimation(self, u"path_0" + (GeneralUtils::to_u16string(pathType)));
RenderComponent::PlayAnimation(self, u"path_0" + (GeneralUtils::to_u16string(pathType)));
self->AddTimer("FloaterScale", randTime);
} else if (timerName == "ShipShakeExplode") {
DoShake(self, true);
@ -76,16 +78,16 @@ void AgSpaceStuff::DoShake(Entity* self, bool explodeIdle) {
auto* shipFxObject2 = GetEntityInGroup(ShipFX2);
if (shipFxObject2)
GameMessages::SendPlayAnimation(shipFxObject2, u"explosion");
RenderComponent::PlayAnimation(shipFxObject2, u"explosion");
} else {
auto* shipFxObject = GetEntityInGroup(ShipFX);
auto* shipFxObject2 = GetEntityInGroup(ShipFX2);
if (shipFxObject)
GameMessages::SendPlayAnimation(shipFxObject, u"idle");
RenderComponent::PlayAnimation(shipFxObject, u"idle");
if (shipFxObject2)
GameMessages::SendPlayAnimation(shipFxObject2, u"idle");
RenderComponent::PlayAnimation(shipFxObject2, u"idle");
}
}

View File

@ -1,6 +1,8 @@
#include "FvDragonSmashingGolemQb.h"
#include "GameMessages.h"
#include "EntityManager.h"
#include "RenderComponent.h"
#include "Entity.h"
#include "eRebuildState.h"
void FvDragonSmashingGolemQb::OnStartup(Entity* self) {
@ -15,7 +17,7 @@ void FvDragonSmashingGolemQb::OnTimerDone(Entity* self, std::string timerName) {
void FvDragonSmashingGolemQb::OnRebuildNotifyState(Entity* self, eRebuildState state) {
if (state == eRebuildState::COMPLETED) {
GameMessages::SendPlayAnimation(self, u"dragonsmash");
RenderComponent::PlayAnimation(self, u"dragonsmash");
const auto dragonId = self->GetVar<LWOOBJID>(u"Dragon");

View File

@ -3,6 +3,7 @@
#include "EntityManager.h"
#include "SkillComponent.h"
#include "GeneralUtils.h"
#include "RenderComponent.h"
void FvFlyingCreviceDragon::OnStartup(Entity* self) {
self->AddTimer("waypoint", 5);
@ -67,10 +68,10 @@ void FvFlyingCreviceDragon::OnArrived(Entity* self) {
auto point = self->GetVar<int32_t>(u"waypoint");
if (point == 4) {
GameMessages::SendPlayAnimation(self, u"attack1", 2);
RenderComponent::PlayAnimation(self, u"attack1", 2.0f);
self->AddTimer("platform1attack", 1.75f);
} else if (point == 12) {
GameMessages::SendPlayAnimation(self, u"attack2", 2);
RenderComponent::PlayAnimation(self, u"attack2", 2.0f);
const auto& group2 = EntityManager::Instance()->GetEntitiesInGroup("dragonFireballs2");
@ -101,7 +102,7 @@ void FvFlyingCreviceDragon::OnArrived(Entity* self) {
}
}
} else if (point == 16) {
GameMessages::SendPlayAnimation(self, u"attack3", 2);
RenderComponent::PlayAnimation(self, u"attack3", 2.0f);
self->AddTimer("platform3attack", 0.5f);
}
}

View File

@ -1,6 +1,8 @@
#include "FvNinjaGuard.h"
#include "GameMessages.h"
#include "MissionComponent.h"
#include "RenderComponent.h"
#include "EntityManager.h"
void FvNinjaGuard::OnStartup(Entity* self) {
if (self->GetLOT() == 7412) {
@ -12,24 +14,24 @@ void FvNinjaGuard::OnStartup(Entity* self) {
void FvNinjaGuard::OnEmoteReceived(Entity* self, const int32_t emote, Entity* target) {
if (emote != 392) {
GameMessages::SendPlayAnimation(self, u"no");
RenderComponent::PlayAnimation(self, u"no");
return;
}
GameMessages::SendPlayAnimation(self, u"scared");
RenderComponent::PlayAnimation(self, u"scared");
if (self->GetLOT() == 7412) {
auto* rightGuard = EntityManager::Instance()->GetEntity(m_RightGuard);
if (rightGuard != nullptr) {
GameMessages::SendPlayAnimation(rightGuard, u"laugh_rt");
RenderComponent::PlayAnimation(rightGuard, u"laugh_rt");
}
} else if (self->GetLOT() == 11128) {
auto* leftGuard = EntityManager::Instance()->GetEntity(m_LeftGuard);
if (leftGuard != nullptr) {
GameMessages::SendPlayAnimation(leftGuard, u"laugh_lt");
RenderComponent::PlayAnimation(leftGuard, u"laugh_lt");
}
}
}

View File

@ -2,6 +2,7 @@
#include "Entity.h"
#include "GameMessages.h"
#include "MissionComponent.h"
#include "RenderComponent.h"
#include "eMissionState.h"
void LegoDieRoll::OnStartup(Entity* self) {
@ -17,23 +18,23 @@ void LegoDieRoll::OnTimerDone(Entity* self, std::string timerName) {
switch (dieRoll) {
case 1:
GameMessages::SendPlayAnimation(self, u"roll-die-1");
RenderComponent::PlayAnimation(self, u"roll-die-1");
break;
case 2:
GameMessages::SendPlayAnimation(self, u"roll-die-2");
RenderComponent::PlayAnimation(self, u"roll-die-2");
break;
case 3:
GameMessages::SendPlayAnimation(self, u"roll-die-3");
RenderComponent::PlayAnimation(self, u"roll-die-3");
break;
case 4:
GameMessages::SendPlayAnimation(self, u"roll-die-4");
RenderComponent::PlayAnimation(self, u"roll-die-4");
break;
case 5:
GameMessages::SendPlayAnimation(self, u"roll-die-5");
RenderComponent::PlayAnimation(self, u"roll-die-5");
break;
case 6:
{
GameMessages::SendPlayAnimation(self, u"roll-die-6");
RenderComponent::PlayAnimation(self, u"roll-die-6");
// tracking the It's Truly Random Achievement
auto* owner = self->GetOwner();
auto* missionComponent = owner->GetComponent<MissionComponent>();

View File

@ -1,5 +1,7 @@
#include "GfOrgan.h"
#include "GameMessages.h"
#include "Entity.h"
#include "RenderComponent.h"
void GfOrgan::OnUse(Entity* self, Entity* user) {
if (self->GetBoolean(u"bIsInUse")) {
@ -11,7 +13,7 @@ void GfOrgan::OnUse(Entity* self, Entity* user) {
self->SetBoolean(u"bIsInUse", true);
self->AddTimer("reset", 5.0f);
GameMessages::SendPlayAnimation(user, u"jig");
RenderComponent::PlayAnimation(user, u"jig");
}
void GfOrgan::OnTimerDone(Entity* self, std::string timerName) {

View File

@ -15,6 +15,7 @@
#include "InventoryComponent.h"
#include "eMissionTaskType.h"
#include "eReplicaComponentType.h"
#include "RenderComponent.h"
#include "eGameActivity.h"
void SGCannon::OnStartup(Entity* self) {
@ -508,17 +509,17 @@ void SGCannon::RecordPlayerScore(Entity* self) {
void SGCannon::PlaySceneAnimation(Entity* self, const std::u16string& animationName, bool onCannon, bool onPlayer, float_t priority) {
for (auto* cannon : EntityManager::Instance()->GetEntitiesInGroup("cannongroup")) {
GameMessages::SendPlayAnimation(cannon, animationName, priority);
RenderComponent::PlayAnimation(cannon, animationName, priority);
}
if (onCannon) {
GameMessages::SendPlayAnimation(self, animationName, priority);
RenderComponent::PlayAnimation(self, animationName, priority);
}
if (onPlayer) {
auto* player = EntityManager::Instance()->GetEntity(self->GetVar<LWOOBJID>(PlayerIDVariable));
if (player != nullptr) {
GameMessages::SendPlayAnimation(player, animationName, priority);
RenderComponent::PlayAnimation(player, animationName, priority);
}
}
}

View File

@ -9,6 +9,7 @@
#include "MissionComponent.h"
#include "eMissionState.h"
#include "eMissionTaskType.h"
#include "RenderComponent.h"
// Constants are at the bottom
@ -122,7 +123,7 @@ void NsConcertInstrument::StartPlayingInstrument(Entity* self, Entity* player) {
player->GetObjectID(), "", UNASSIGNED_SYSTEM_ADDRESS);
GameMessages::SendPlayCinematic(player->GetObjectID(), cinematics.at(instrumentLot), UNASSIGNED_SYSTEM_ADDRESS);
self->AddCallbackTimer(1.0f, [player, instrumentLot]() {
GameMessages::SendPlayAnimation(player, animations.at(instrumentLot), 2.0f);
RenderComponent::PlayAnimation(player, animations.at(instrumentLot), 2.0f);
});
for (auto* soundBox : EntityManager::Instance()->GetEntitiesInGroup("Audio-Concert")) {
@ -153,7 +154,7 @@ void NsConcertInstrument::StopPlayingInstrument(Entity* self, Entity* player) {
}
GameMessages::SendEndCinematic(player->GetObjectID(), cinematics.at(instrumentLot), UNASSIGNED_SYSTEM_ADDRESS, 1.0f);
GameMessages::SendPlayAnimation(player, smashAnimations.at(instrumentLot), 2.0f);
RenderComponent::PlayAnimation(player, smashAnimations.at(instrumentLot), 2.0f);
GameMessages::SendNotifyClientObject(self->GetObjectID(), u"stopCheckingMovement", 0, 0,
player->GetObjectID(), "", UNASSIGNED_SYSTEM_ADDRESS);
}

View File

@ -4,6 +4,8 @@
#include "GameMessages.h"
#include "EntityManager.h"
#include "PhantomPhysicsComponent.h"
#include "RenderComponent.h"
#include "Entity.h"
void WhFans::OnStartup(Entity* self) {
self->SetVar<bool>(u"alive", true);
@ -30,7 +32,7 @@ void WhFans::ToggleFX(Entity* self, bool hit) {
if (fanVolumes.size() == 0 || !self->GetVar<bool>(u"alive")) return;
if (self->GetVar<bool>(u"on")) {
GameMessages::SendPlayAnimation(self, u"fan-off");
RenderComponent::PlayAnimation(self, u"fan-off");
renderComponent->StopEffect("fanOn");
self->SetVar<bool>(u"on", false);
@ -42,7 +44,7 @@ void WhFans::ToggleFX(Entity* self, bool hit) {
EntityManager::Instance()->SerializeEntity(volume);
}
} else if (!self->GetVar<bool>(u"on") && self->GetVar<bool>(u"alive")) {
GameMessages::SendPlayAnimation(self, u"fan-on");
RenderComponent::PlayAnimation(self, u"fan-on");
self->SetVar<bool>(u"on", true);

View File

@ -1,6 +1,7 @@
#include "WildAmbients.h"
#include "GameMessages.h"
#include "RenderComponent.h"
void WildAmbients::OnUse(Entity* self, Entity* user) {
GameMessages::SendPlayAnimation(self, u"interact");
RenderComponent::PlayAnimation(self, u"interact");
}