move files into client folder

This commit is contained in:
2024-08-19 14:37:36 +02:00
parent 211533d967
commit 5c1793c1e7
18 changed files with 29 additions and 42 deletions

View File

@@ -1,36 +0,0 @@
#pragma once
#include "Player.h"
#include <godot_cpp/classes/input_event_mouse_motion.hpp>
namespace blitz {
class FirstPersonPlayer : public Player {
GDCLASS(FirstPersonPlayer, godot::CharacterBody3D)
protected:
static void _bind_methods();
public:
FirstPersonPlayer();
~FirstPersonPlayer();
// Godot overrides
void _unhandled_input(const godot::Ref<godot::InputEvent>&);
void _physics_process(float delta);
void _ready() override;
private:
godot::Camera3D* m_Camera;
godot::Node3D* m_Head;
float m_BobTime;
float m_Speed;
void UpdateBobbing(float delta);
void UpdateFOV(float delta);
void UpdateCamera(const godot::InputEventMouseMotion&);
void UpdatePosition(float delta);
void UpdateAnimation(float delta);
};
} // namespace blitz

View File

@@ -1,32 +0,0 @@
#pragma once
#include <godot_cpp/classes/node.hpp>
#include "NetworkInterface.h"
namespace blitz {
class Lobby : public godot::Node {
GDCLASS(Lobby, godot::Node)
protected:
static void _bind_methods();
public:
Lobby();
~Lobby();
void _ready() override;
godot::Error JoinGame(const godot::String& a_Address, uint16_t a_Port);
godot::Error CreateGame(uint16_t a_Port, bool a_Dedicated = false);
void Shutdown();
private:
void OnPlayerConnected(PeerID a_PeerId);
void OnPlayerDisconnected(PeerID a_PeerId);
void OnConnectOk();
void OnConnectFail();
void OnServerDisconnected();
};
} // namespace blitz

View File

@@ -1,19 +0,0 @@
#pragma once
#include <godot_cpp/classes/node.hpp>
namespace blitz {
class Main : public godot::Node {
GDCLASS(Main, godot::Node)
protected:
static void _bind_methods();
public:
Main();
~Main();
void ChangeScene();
};
} // namespace blitz

View File

@@ -1,32 +0,0 @@
#pragma once
#include <godot_cpp/classes/button.hpp>
#include <godot_cpp/classes/control.hpp>
namespace blitz {
class MainMenu : public godot::Control {
GDCLASS(MainMenu, godot::Control)
protected:
static void _bind_methods();
public:
MainMenu();
~MainMenu();
// Godot overrides
void _ready() override;
private:
godot::Button* m_JoinButton;
godot::Button* m_CreateButton;
godot::Button* m_QuitButton;
void OnConnected();
void OnJoinPressed();
void OnCreatePressed();
void OnQuitPressed();
};
} // namespace blitz

View File

@@ -1,26 +0,0 @@
#pragma once
#include <blitz/protocol/Packets.h>
#include <godot_cpp/classes/node.hpp>
#include <blitz/protocol/PacketDispatcher.h>
namespace blitz {
class NetworkInterface : public godot::Node, public protocol::PacketDispatcher {
GDCLASS(NetworkInterface, godot::Node)
protected:
static void _bind_methods();
public:
NetworkInterface();
~NetworkInterface();
void BroadcastPacket(const protocol::Packet& a_Packet);
void SendPacket(PeerID a_Peer, const protocol::Packet& a_Packet);
void _ready() override;
private:
void RecievePacketDataReliable(godot::PackedByteArray a_PacketData);
};
} // namespace blitz

View File

@@ -1,44 +0,0 @@
#pragma once
#include <godot_cpp/classes/animation_tree.hpp>
#include <godot_cpp/classes/character_body3d.hpp>
#include <godot_cpp/classes/node3d.hpp>
#include <blitz/common/Types.h>
namespace blitz {
class World;
class Player : public godot::CharacterBody3D {
GDCLASS(Player, godot::CharacterBody3D);
protected:
static void _bind_methods();
public:
Player();
~Player();
void _ready();
void _physics_process(float delta);
void animate(float delta);
godot::Vector3 GetCameraRotation() const;
void SetCameraRotation(const godot::Vector3& a_Rotation);
PlayerID GetId() const {
return m_PeerId;
}
protected:
godot::Node3D* m_Mesh;
godot::AnimationTree* m_AnimationTree;
godot::Vector3 m_SnapVector;
float m_Speed;
PeerID m_PeerId;
friend class World;
};
} // namespace blitz

View File

@@ -1,32 +0,0 @@
#pragma once
#include <godot_cpp/classes/node.hpp>
#include <blitz/common/Types.h>
namespace blitz {
class Lobby;
class NetworkInterface;
class Server : public godot::Node {
GDCLASS(Server, godot::Node)
protected:
static void _bind_methods();
public:
Server();
~Server();
void _ready() override;
void OnPlayerConnect(PeerID a_PeerId);
void OnPlayerDisconnect(PeerID a_PeerId);
private:
Lobby* m_Lobby;
NetworkInterface* m_NetworkInterface;
godot::TypedArray<PeerID> m_Peers;
};
} // namespace blitz

View File

@@ -1,41 +0,0 @@
#pragma once
#include <godot_cpp/classes/node3d.hpp>
#include <blitz/protocol/PacketHandler.h>
namespace blitz {
class Player;
class NetworkInterface;
class World : public godot::Node3D, public protocol::PacketHandler {
GDCLASS(World, godot::Node3D)
protected:
static void _bind_methods();
public:
World();
~World();
// Godot overrides
void _ready() override;
void _process(float delta);
Player* GetPlayerById(PlayerID a_PlayerId);
void HandlePacket(const protocol::packets::PlayerJoin&) override;
void HandlePacket(const protocol::packets::PlayerLeave&) override;
void HandlePacket(const protocol::packets::PlayerPositionAndRotation&) override;
private:
NetworkInterface* m_NetworkInterface;
godot::Node* m_Players;
float m_PassedTime;
void AddPlayer(PlayerID a_PlayerId, godot::String a_PlayerName);
void RemovePlayer(PlayerID a_PlayerId);
void SetPlayerPositionAndRotation(PlayerID a_PlayerId, const godot::Vector3& a_Position, const godot::Vector3& a_Rotation);
};
} // namespace blitz

View File

@@ -1,4 +1,4 @@
#include "FirstPersonPlayer.h"
#include <client/FirstPersonPlayer.h>
#include <godot_cpp/classes/camera3d.hpp>
#include <godot_cpp/classes/engine.hpp>

View File

@@ -1,4 +1,4 @@
#include "Lobby.h"
#include <client/Lobby.h>
#include <godot_cpp/classes/e_net_multiplayer_peer.hpp>
#include <godot_cpp/classes/multiplayer_api.hpp>

View File

@@ -1,4 +1,4 @@
#include "Main.h"
#include <client/Main.h>
#include <godot_cpp/classes/engine.hpp>
#include <godot_cpp/classes/packed_scene.hpp>
@@ -7,8 +7,8 @@
#include <godot_cpp/classes/window.hpp>
#include <godot_cpp/variant/utility_functions.hpp>
#include "Lobby.h"
#include "World.h"
#include <client/Lobby.h>
#include <client/World.h>
using namespace godot;

View File

@@ -1,4 +1,4 @@
#include "MainMenu.h"
#include <client/MainMenu.h>
#include <godot_cpp/classes/resource_loader.hpp>
#include <godot_cpp/classes/scene_tree.hpp>

View File

@@ -1,4 +1,4 @@
#include "NetworkInterface.h"
#include <client/NetworkInterface.h>
#include <blitz/protocol/PacketFactory.h>
#include <blitz/protocol/PacketSerializer.h>

View File

@@ -1,4 +1,4 @@
#include "Player.h"
#include <client/Player.h>
#include <godot_cpp/classes/engine.hpp>
#include <godot_cpp/classes/input.hpp>

View File

@@ -1,7 +1,7 @@
#include "Server.h"
#include <client/Server.h>
#include "Lobby.h"
#include "NetworkInterface.h"
#include <client/Lobby.h>
#include <client/NetworkInterface.h>
#include <godot_cpp/classes/engine.hpp>
using namespace godot;

View File

@@ -1,8 +1,8 @@
#include "World.h"
#include <client/World.h>
#include "FirstPersonPlayer.h"
#include "NetworkInterface.h"
#include "Player.h"
#include <client/FirstPersonPlayer.h>
#include <client/NetworkInterface.h>
#include <client/Player.h>
#include <godot_cpp/classes/engine.hpp>
#include <godot_cpp/classes/multiplayer_api.hpp>
#include <godot_cpp/classes/packed_scene.hpp>

View File

@@ -1,13 +1,11 @@
#include "register_types.h"
#include "FirstPersonPlayer.h"
#include "Lobby.h"
#include "Main.h"
#include "MainMenu.h"
#include "NetworkInterface.h"
#include "Player.h"
#include "Server.h"
#include "World.h"
#include <client/FirstPersonPlayer.h>
#include <client/Lobby.h>
#include <client/Main.h>
#include <client/MainMenu.h>
#include <client/NetworkInterface.h>
#include <client/Player.h>
#include <client/Server.h>
#include <client/World.h>
#include <gdextension_interface.h>
#include <godot_cpp/core/defs.hpp>
@@ -26,7 +24,7 @@ static void RegisterClasses() {
GDREGISTER_CLASS(blitz::Server);
}
void initialize_example_module(ModuleInitializationLevel p_level) {
static void initialize_blitz_module(ModuleInitializationLevel p_level) {
if (p_level != MODULE_INITIALIZATION_LEVEL_SCENE) {
return;
}
@@ -34,7 +32,7 @@ void initialize_example_module(ModuleInitializationLevel p_level) {
RegisterClasses();
}
void uninitialize_example_module(ModuleInitializationLevel p_level) {
static void uninitialize_blitz_module(ModuleInitializationLevel p_level) {
if (p_level != MODULE_INITIALIZATION_LEVEL_SCENE) {
return;
}
@@ -44,8 +42,8 @@ extern "C" GDExtensionBool GDE_EXPORT library_init(GDExtensionInterfaceGetProcAd
const GDExtensionClassLibraryPtr p_library, GDExtensionInitialization* r_initialization) {
godot::GDExtensionBinding::InitObject init_obj(p_get_proc, p_library, r_initialization);
init_obj.register_initializer(initialize_example_module);
init_obj.register_terminator(uninitialize_example_module);
init_obj.register_initializer(initialize_blitz_module);
init_obj.register_terminator(uninitialize_blitz_module);
init_obj.set_minimum_library_initialization_level(MODULE_INITIALIZATION_LEVEL_SCENE);
return init_obj.init();

View File

@@ -1,11 +0,0 @@
#ifndef GDEXAMPLE_REGISTER_TYPES_H
#define GDEXAMPLE_REGISTER_TYPES_H
#include <godot_cpp/core/class_db.hpp>
using namespace godot;
void initialize_example_module(ModuleInitializationLevel p_level);
void uninitialize_example_module(ModuleInitializationLevel p_level);
#endif