mirror of
https://github.com/luanti-org/luanti.git
synced 2025-09-30 19:22:14 +00:00
Add an SSCSM controller and environment skeleton
This commit is contained in:
parent
5f5ea13251
commit
7935a63ed4
13 changed files with 468 additions and 2 deletions
48
src/script/sscsm/sscsm_environment.cpp
Normal file
48
src/script/sscsm/sscsm_environment.cpp
Normal file
|
@ -0,0 +1,48 @@
|
|||
// SPDX-FileCopyrightText: 2024 Luanti authors
|
||||
//
|
||||
// SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
|
||||
#include "sscsm_environment.h"
|
||||
#include "sscsm_requests.h"
|
||||
#include "sscsm_events.h"
|
||||
#include "sscsm_stupid_channel.h"
|
||||
|
||||
|
||||
void *SSCSMEnvironment::run()
|
||||
{
|
||||
while (true) {
|
||||
auto next_event = requestPollNextEvent();
|
||||
|
||||
if (dynamic_cast<SSCSMEventTearDown *>(next_event.get())) {
|
||||
break;
|
||||
}
|
||||
|
||||
next_event->exec(this);
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
SerializedSSCSMAnswer SSCSMEnvironment::exchange(SerializedSSCSMRequest req)
|
||||
{
|
||||
return m_channel->exchangeA(std::move(req));
|
||||
}
|
||||
|
||||
std::unique_ptr<ISSCSMEvent> SSCSMEnvironment::requestPollNextEvent()
|
||||
{
|
||||
auto request = SSCSMRequestPollNextEvent{};
|
||||
auto answer = deserializeSSCSMAnswer<SSCSMRequestPollNextEvent::Answer>(
|
||||
exchange(serializeSSCSMRequest(request))
|
||||
);
|
||||
return std::move(answer.next_event);
|
||||
}
|
||||
|
||||
MapNode SSCSMEnvironment::requestGetNode(v3s16 pos)
|
||||
{
|
||||
auto request = SSCSMRequestGetNode{};
|
||||
request.pos = pos;
|
||||
auto answer = deserializeSSCSMAnswer<SSCSMRequestGetNode::Answer>(
|
||||
exchange(serializeSSCSMRequest(request))
|
||||
);
|
||||
return answer.node;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue