Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
Pospelove committed Dec 9, 2024
1 parent 9d9c07d commit a9f801f
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#include "UpdateAppearanceAttemptEvent.h"

#include "MpActor.h"
#include <spdlog/spdlog.h>

UpdateAppearanceAttemptEvent::UpdateAppearanceAttemptEvent(
MpActor* actor_, const Appearance& appearance_, bool isAllowed_)
: actor(actor_)
, appearance(appearance_)
, isAllowed(isAllowed_)
{
}

const char* UpdateAppearanceAttemptEvent::GetName() const
{
return "onUpdateAppearanceAttempt";
}

std::string UpdateAppearanceAttemptEvent::GetArgumentsJsonArray() const
{
std::string result;
result += "[";
result += std::to_string(actor->GetFormId());
result += ",";
result += appearance.ToJson().dump();
result += ",";
result += isAllowed ? "true" : "false";
result += "]";
return result;
}

void UpdateAppearanceAttemptEvent::OnFireSuccess(WorldState* worldState)
{
}

void UpdateAppearanceAttemptEvent::OnFireBlocked(WorldState* worldState)
{
spdlog::warn(
"UpdateAppearanceAttemptEvent::OnFireBlocked - Not implemented. Please "
"consider never blocking {} event in gamemode",
GetName());
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#pragma once
#include "GameModeEvent.h"

class MpActor;

#include "Appearance.h"

class UpdateAppearanceAttemptEvent : public GameModeEvent
{
public:
UpdateAppearanceAttemptEvent(MpActor* actor_, const Appearance& appearance_,
bool isAllowed_);

const char* GetName() const override;

std::string GetArgumentsJsonArray() const override;

private:
void OnFireSuccess(WorldState* worldState) override;
void OnFireBlocked(WorldState* worldState) override;

MpActor* actor = nullptr;
Appearance appearance;
bool isAllowed = false;
};

0 comments on commit a9f801f

Please sign in to comment.