mumble/plugins/amongus/Game.h
Robert Adam 2b35c0c28f REFAC(plugins): Unified Mumble plugin headers
Having different include files that are needed (and which are
inter-dependent) to create your own plugin, makes things harder than it
needs to be.

Therefore, all plugin header files (those for the "new" (1.4) plugin
framework anyway) have been combined into one header file. Thus,
developers now only have to download a single file and include that
instead of having to figure out what files to download and what to
include where.

Taking the chance, the version number has been removed from the header
file's name. This allows one to track changes made to the API via git
(which is not quite as easy if you create a new file every time you make
a change).
2023-07-27 19:39:30 +02:00

54 lines
1.8 KiB
C++

// Copyright 2020-2023 The Mumble Developers. All rights reserved.
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file at the root of the
// Mumble source tree or at <https://www.mumble.info/LICENSE>.
#ifndef AMONGUS_GAME
#define AMONGUS_GAME
#include "structs.h"
#include "ProcessWindows.h"
#define MUMBLE_PLUGIN_NO_DEFAULT_FUNCTION_DEFINITIONS
#include "MumblePlugin.h"
#undef MUMBLE_PLUGIN_NO_DEFAULT_FUNCTION_DEFINITIONS
class Game {
public:
Mumble_PositionalDataErrorCode init();
static inline bool isMultiplayer(const AmongUsClient_Fields &fields) {
return fields.gameMode != GameMode::FreePlay && fields.gameState != GameState::NotJoined;
}
inline AmongUsClient_Fields clientFields() const { return m_proc.peek< AmongUsClient_o >(m_client).fields; }
inline GameData_PlayerInfo_Fields playerInfoFields(const PlayerControl_Fields &fields) const {
return m_proc.peek< GameData_PlayerInfo_o >(fields.cachedData).fields;
}
inline UnityEngine_Vector2_Fields playerPosition(const PlayerControl_Fields &fields) const {
const auto networkTransform = m_proc.peek< CustomNetworkTransform_o >(fields.netTransform);
return networkTransform.fields.prevPosSent.fields;
}
PlayerControl_Fields playerControlFields();
GameData_PlayerOutfit_Fields playerOutfitFields(const GameData_PlayerInfo_Fields &fields);
std::string string(const procptr_t address);
const std::string &context(const AmongUsClient_Fields &fields);
const std::string &identity(const AmongUsClient_Fields &fields, const PlayerControl_Fields &controlFields);
Game(const procid_t id, const std::string name);
protected:
ptr_t m_client;
ptr_t m_playerControlStaticFields;
std::string m_context;
std::string m_identity;
ProcessWindows m_proc;
};
#endif