Sync variables
This commit is contained in:
parent
59918b86b1
commit
d592cef1a0
@ -1,12 +0,0 @@
|
||||
#pragma once
|
||||
#include <deerith/engine.h>
|
||||
|
||||
namespace deerith
|
||||
{
|
||||
template <typename T>
|
||||
class SyncBuffer
|
||||
{
|
||||
private:
|
||||
public:
|
||||
}
|
||||
}
|
||||
@ -3,8 +3,8 @@
|
||||
|
||||
// At
|
||||
#define UNIVERSE_SIMULATION_TICK_FREQ 50
|
||||
#define NETWORK_RELATIVE_UNIVERSE_TICK 2
|
||||
#define NETWORK_DELAY 6
|
||||
#define NETWORK_RELATIVE_TICK 2
|
||||
#define NETWORK_DELAY 10
|
||||
|
||||
namespace deerith
|
||||
{
|
||||
|
||||
29
deerith_engine_core/include/deerith/universe/sync_buffer.h
Normal file
29
deerith_engine_core/include/deerith/universe/sync_buffer.h
Normal file
@ -0,0 +1,29 @@
|
||||
#pragma once
|
||||
#include <deerith/engine.h>
|
||||
#include <glm/glm.hpp>
|
||||
#include <array>
|
||||
|
||||
#define BUFFER_SIZE (NETWORK_DELAY + 20)
|
||||
|
||||
namespace deerith
|
||||
{
|
||||
class sync_buffer
|
||||
{
|
||||
public:
|
||||
virtual ~sync_buffer() = default;
|
||||
};
|
||||
|
||||
class float_sync_data : public sync_buffer
|
||||
{
|
||||
public:
|
||||
private:
|
||||
std::array<float, BUFFER_SIZE> float_buffer;
|
||||
};
|
||||
|
||||
class vec2_sync_data : public sync_buffer
|
||||
{
|
||||
public:
|
||||
private:
|
||||
std::array<glm::vec2, BUFFER_SIZE> buffer;
|
||||
};
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
#pragma once
|
||||
#include <deerith/universe/user.h>
|
||||
#include <functional>
|
||||
|
||||
namespace deerith
|
||||
{
|
||||
|
||||
void define_client_callback(std::function<void(user &)>);
|
||||
}
|
||||
19
deerith_engine_core/include/deerith/universe/user.h
Normal file
19
deerith_engine_core/include/deerith/universe/user.h
Normal file
@ -0,0 +1,19 @@
|
||||
#pragma once
|
||||
#include <deerith/universe/sync_buffer.h>
|
||||
#include <functional>
|
||||
#include <vector>
|
||||
|
||||
namespace deerith
|
||||
{
|
||||
class user
|
||||
{
|
||||
public:
|
||||
void *user_data = nullptr;
|
||||
|
||||
void add_sync_buffer(sync_buffer *sync_buffer);
|
||||
|
||||
private:
|
||||
std::vector<sync_buffer *> sync_buffer_container;
|
||||
};
|
||||
|
||||
}
|
||||
@ -1,11 +0,0 @@
|
||||
#pragma once
|
||||
#include <functional>
|
||||
|
||||
namespace deerith
|
||||
{
|
||||
class Client
|
||||
{
|
||||
};
|
||||
|
||||
void define_client_callback(std::function<void(Client)>);
|
||||
}
|
||||
6
deerith_engine_core/src/user.cpp
Normal file
6
deerith_engine_core/src/user.cpp
Normal file
@ -0,0 +1,6 @@
|
||||
#include <deerith/universe/user.h>
|
||||
|
||||
namespace deerit
|
||||
{
|
||||
|
||||
}
|
||||
@ -1,5 +1,4 @@
|
||||
#include <deerith/universe.h>
|
||||
#include <deerith/universe_definition.h>
|
||||
|
||||
#include <deerith/core/tick.h>
|
||||
#include <deerith/core/log.h>
|
||||
|
||||
13
sandbox/src/common/common.h
Normal file
13
sandbox/src/common/common.h
Normal file
@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
#include <deerith/universe/user.h>
|
||||
#include <deerith/universe/sync_buffer.h>
|
||||
#include <deerith/universe/universe_definition.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
struct sandbox_user_data_t
|
||||
{
|
||||
deerith::vec2_sync_data position;
|
||||
};
|
||||
|
||||
void define_user();
|
||||
16
sandbox/src/common/user_definition.cpp
Normal file
16
sandbox/src/common/user_definition.cpp
Normal file
@ -0,0 +1,16 @@
|
||||
#include "common/common.h"
|
||||
#include <deerith/universe/universe_definition.h>
|
||||
#include <deerith/core/log.h>
|
||||
|
||||
void user_definition_function(deerith::user &user_data)
|
||||
{
|
||||
deerith_trace("adding user data to new user");
|
||||
|
||||
sandbox_user_data_t *sandbox_user_data = new sandbox_user_data_t();
|
||||
user_data.add_sync_buffer(&sandbox_user_data->position);
|
||||
}
|
||||
|
||||
void client_definition()
|
||||
{
|
||||
deerith::define_client_callback(user_definition_function);
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user