You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
138 lines
4.9 KiB
138 lines
4.9 KiB
4 years ago
|
/**
|
||
|
* Class for an object that will provide an access to a Acedia's functionality
|
||
4 years ago
|
* by giving a reference to this object to all Acedia's objects and actors,
|
||
4 years ago
|
* emulating a global API namespace.
|
||
4 years ago
|
* Copyright 2020 - 2021 Anton Tarasenko
|
||
4 years ago
|
*------------------------------------------------------------------------------
|
||
|
* This file is part of Acedia.
|
||
|
*
|
||
|
* Acedia is free software: you can redistribute it and/or modify
|
||
|
* it under the terms of the GNU General Public License as published by
|
||
|
* the Free Software Foundation, version 3 of the License, or
|
||
|
* (at your option) any later version.
|
||
|
*
|
||
|
* Acedia is distributed in the hope that it will be useful,
|
||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
* GNU General Public License for more details.
|
||
|
*
|
||
|
* You should have received a copy of the GNU General Public License
|
||
|
* along with Acedia. If not, see <https://www.gnu.org/licenses/>.
|
||
|
*/
|
||
4 years ago
|
class Global extends Object;
|
||
4 years ago
|
|
||
4 years ago
|
// `Global` is expected to behave like a singleton and will store it's
|
||
|
// main instance in this variable's default value.
|
||
|
var protected Global myself;
|
||
4 years ago
|
|
||
2 years ago
|
var public RefAPI ref;
|
||
|
var public BoxAPI box;
|
||
|
var public LoggerAPI logger;
|
||
|
var public CollectionsAPI collections;
|
||
|
var public UnrealAPI unreal;
|
||
|
var public TimeAPI time;
|
||
|
var public AliasesAPI alias;
|
||
|
var public TextAPI text;
|
||
|
var public MemoryAPI memory;
|
||
|
var public ConsoleAPI console;
|
||
|
var public ChatAPI chat;
|
||
|
var public ColorAPI color;
|
||
|
var public UserAPI users;
|
||
|
var public PlayersAPI players;
|
||
|
var public JSONAPI json;
|
||
|
var public DBAPI db;
|
||
|
var public AvariceAPI avarice;
|
||
4 years ago
|
|
||
2 years ago
|
var public AcediaEnvironment environment;
|
||
|
|
||
|
var public KFFrontend kf;
|
||
4 years ago
|
|
||
4 years ago
|
public final static function Global GetInstance()
|
||
|
{
|
||
|
if (default.myself == none) {
|
||
|
// `Global` is special and exists outside main Acedia's
|
||
|
// object infrastructure, so we allocate it without using API methods.
|
||
|
default.myself = new class'Global';
|
||
|
default.myself.Initialize();
|
||
|
}
|
||
|
return default.myself;
|
||
|
}
|
||
|
|
||
|
protected function Initialize()
|
||
4 years ago
|
{
|
||
4 years ago
|
// Special case that we cannot spawn with memory API since it obviously
|
||
|
// does not exist yet!
|
||
|
memory = new class'MemoryAPI';
|
||
4 years ago
|
// `TextAPI` and `CollectionsAPI` need to be loaded before `LoggerAPI`
|
||
4 years ago
|
ref = RefAPI(memory.Allocate(class'RefAPI'));
|
||
|
box = BoxAPI(memory.Allocate(class'BoxAPI'));
|
||
4 years ago
|
text = TextAPI(memory.Allocate(class'TextAPI'));
|
||
4 years ago
|
collections = CollectionsAPI(memory.Allocate(class'CollectionsAPI'));
|
||
4 years ago
|
unreal = UnrealAPI(memory.Allocate(class'UnrealAPI'));
|
||
4 years ago
|
time = TimeAPI(memory.Allocate(class'TimeAPI'));
|
||
4 years ago
|
logger = LoggerAPI(memory.Allocate(class'LoggerAPI'));
|
||
4 years ago
|
alias = AliasesAPI(memory.Allocate(class'AliasesAPI'));
|
||
|
console = ConsoleAPI(memory.Allocate(class'ConsoleAPI'));
|
||
3 years ago
|
chat = ChatAPI(memory.Allocate(class'ChatAPI'));
|
||
4 years ago
|
color = ColorAPI(memory.Allocate(class'ColorAPI'));
|
||
|
users = UserAPI(memory.Allocate(class'UserAPI'));
|
||
4 years ago
|
players = PlayersAPI(memory.Allocate(class'PlayersAPI'));
|
||
4 years ago
|
json = JSONAPI(memory.Allocate(class'JSONAPI'));
|
||
3 years ago
|
db = DBAPI(memory.Allocate(class'DBAPI'));
|
||
3 years ago
|
avarice = AvariceAPI(memory.Allocate(class'AvariceAPI'));
|
||
4 years ago
|
kf = KFFrontend(memory.Allocate(class'KF1_Frontend'));
|
||
2 years ago
|
environment = AcediaEnvironment(memory.Allocate(class'AcediaEnvironment'));
|
||
2 years ago
|
class'InfoQueryHandler'.static.StaticConstructor();
|
||
2 years ago
|
}
|
||
|
|
||
|
public final function bool ConnectServerLevelCore()
|
||
|
{
|
||
|
if (class'ServerLevelCore'.static.GetInstance() == none) {
|
||
|
return false;
|
||
|
}
|
||
|
class'UnrealService'.static.Require();
|
||
|
class'ConnectionService'.static.Require();
|
||
2 years ago
|
// TODO: this is hack as fuck, needs to be redone
|
||
|
unreal.mutator.OnMutate(
|
||
|
ServiceAnchor(memory.Allocate(class'ServiceAnchor')))
|
||
|
.connect = EnableCommandsFeature;
|
||
2 years ago
|
return true;
|
||
3 years ago
|
}
|
||
|
|
||
|
public function DropGameplayAPI()
|
||
|
{
|
||
|
memory.Free(kf);
|
||
|
kf = none;
|
||
|
}
|
||
|
|
||
2 years ago
|
private final function EnableCommandsFeature(
|
||
|
string command,
|
||
|
PlayerController sendingPlayer)
|
||
|
{
|
||
|
if (command ~= "acediacommands") {
|
||
|
class'Commands_Feature'.static.EmergencyEnable();
|
||
|
}
|
||
|
}
|
||
|
|
||
3 years ago
|
public function DropCoreAPI()
|
||
|
{
|
||
|
memory = none;
|
||
|
ref = none;
|
||
|
box = none;
|
||
|
text = none;
|
||
|
collections = none;
|
||
|
unreal.DropAPI();
|
||
|
unreal = none;
|
||
|
time = none;
|
||
|
logger = none;
|
||
|
alias = none;
|
||
|
console = none;
|
||
3 years ago
|
chat = none;
|
||
3 years ago
|
color = none;
|
||
|
users = none;
|
||
|
players = none;
|
||
|
json = none;
|
||
|
db = none;
|
||
|
avarice = none;
|
||
|
default.myself = none;
|
||
4 years ago
|
}
|