mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-25 06:57:28 +00:00
631365b7f7
* update naming for animation flag enum value 0 * Add change idle flags behaviors and GM * default to 0 when none is given
38 lines
1.4 KiB
C++
38 lines
1.4 KiB
C++
|
|
#include "ChangeIdleFlagsBehavior.h"
|
|
#include "BehaviorContext.h"
|
|
#include "BehaviorBranchContext.h"
|
|
|
|
void ChangeIdleFlagsBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
|
const auto target = branch.target != LWOOBJID_EMPTY ? branch.target : context->originator;
|
|
if (!target) return;
|
|
|
|
GameMessages::SendChangeIdleFlags(target, m_FlagsOn, m_FlagsOff, UNASSIGNED_SYSTEM_ADDRESS);
|
|
|
|
if (branch.duration > 0.0f) {
|
|
context->RegisterTimerBehavior(this, branch);
|
|
} else if (branch.start > 0) {
|
|
context->RegisterEndBehavior(this, branch);
|
|
}
|
|
}
|
|
|
|
void ChangeIdleFlagsBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
|
Handle(context, bitStream, branch);
|
|
}
|
|
|
|
void ChangeIdleFlagsBehavior::End(BehaviorContext* context, BehaviorBranchContext branch, LWOOBJID second) {
|
|
const auto target = branch.target != LWOOBJID_EMPTY ? branch.target : context->originator;
|
|
if (!target) return;
|
|
// flip on and off to end behavior
|
|
GameMessages::SendChangeIdleFlags(target, m_FlagsOff, m_FlagsOn, UNASSIGNED_SYSTEM_ADDRESS);
|
|
}
|
|
|
|
void ChangeIdleFlagsBehavior::Timer(BehaviorContext* context, BehaviorBranchContext branch, LWOOBJID second) {
|
|
End(context, branch, second);
|
|
}
|
|
|
|
void ChangeIdleFlagsBehavior::Load() {
|
|
m_FlagsOff = static_cast<eAnimationFlags>(GetInt("flags_off", 0));
|
|
m_FlagsOn = static_cast<eAnimationFlags>(GetInt("flags_on", 0));
|
|
}
|