init commit
This commit is contained in:
commit
1497f114e6
47 files changed
+8358
No files matched your search
@@ -0,0 +1,39 @@
|
||||
#pragma once
|
||||
|
||||
#include <atomic>
|
||||
#include <functional>
|
||||
|
||||
#include "botcraft/AI/TemplatedBehaviourClient.hpp"
|
||||
|
||||
namespace Bilicraft
|
||||
{
|
||||
// CRTP keeps future behaviour-tree leaves typed as BilicraftClient, with access
|
||||
// to its custom fields as well as Botcraft's world/inventory/physics managers.
|
||||
class BilicraftClient : public Botcraft::TemplatedBehaviourClient<BilicraftClient>
|
||||
{
|
||||
public:
|
||||
~BilicraftClient() override;
|
||||
bool WasDisconnected() const;
|
||||
bool HasEnteredPlay() const;
|
||||
|
||||
// Synchronous .act execution: tasks yield to a main-thread cancellation/
|
||||
// pacing hook instead of starting the upstream behaviour worker. Never use
|
||||
// this mode concurrently with StartBehaviour/BehaviourStep/SyncAction.
|
||||
void SetActionYieldHandler(std::function<void()> handler);
|
||||
void Yield() override;
|
||||
|
||||
protected:
|
||||
using Botcraft::TemplatedBehaviourClient<BilicraftClient>::Handle;
|
||||
void Handle(ProtocolCraft::ClientboundLoginPacket &packet) override;
|
||||
void Handle(ProtocolCraft::ClientboundLoginDisconnectPacket &packet) override;
|
||||
void Handle(ProtocolCraft::ClientboundDisconnectConfigurationPacket &packet) override;
|
||||
void Handle(ProtocolCraft::ClientboundDisconnectPacket &packet) override;
|
||||
|
||||
private:
|
||||
// Main-thread-only hook; it is never called by network/physics handlers.
|
||||
std::function<void()> actionYieldHandler;
|
||||
// Do not use upstream's non-atomic should_be_closed as our cross-thread signal.
|
||||
std::atomic<bool> disconnected{false};
|
||||
std::atomic<bool> enteredPlay{false};
|
||||
};
|
||||
} // namespace Bilicraft
|
||||
Reference in new issue
Block a user