|
|
|
@ -1,8 +1,8 @@
|
|
|
|
|
/** |
|
|
|
|
* Class for an object that will provide an access to a Acedia's functionality |
|
|
|
|
* that is common for both clients and servers by giving a reference to this |
|
|
|
|
* object to all Acedia's objects and actors, emulating a global API namespace. |
|
|
|
|
* Copyright 2020-2023 Anton Tarasenko |
|
|
|
|
* Author: dkanus |
|
|
|
|
* Home repo: https://www.insultplayers.ru/git/AcediaFramework/AcediaCore |
|
|
|
|
* License: GPL |
|
|
|
|
* Copyright 2020-2023 Anton Tarasenko |
|
|
|
|
*------------------------------------------------------------------------------ |
|
|
|
|
* This file is part of Acedia. |
|
|
|
|
* |
|
|
|
@ -21,8 +21,18 @@
|
|
|
|
|
*/ |
|
|
|
|
class Global extends Object; |
|
|
|
|
|
|
|
|
|
// `Global` is expected to behave like a singleton and will store it's |
|
|
|
|
// main instance in this variable's default value. |
|
|
|
|
//! Class singleton instance of an object that would hold references to any API that do not depend |
|
|
|
|
//! on [`Actor`]s. |
|
|
|
|
//! |
|
|
|
|
//! To overcome cumbersome syntax of UnrealScript we gather all functions we want to be global into |
|
|
|
|
//! special "API objects" and store their single references inside this one, [`Global`]'s instance. |
|
|
|
|
//! Providing reference to properly initialized [`Global`] object to all [`AcediaObject`]s and |
|
|
|
|
//! [`AcediaActor`]s will give them convenient accessors to all Acedia API. |
|
|
|
|
//! |
|
|
|
|
//! [`Global`] is expected to behave like a singleton and will store its main instance in this |
|
|
|
|
//! variable's default value. |
|
|
|
|
|
|
|
|
|
// For getting instance of [`Global`] from any object. |
|
|
|
|
var protected Global myself; |
|
|
|
|
|
|
|
|
|
var public RefAPI ref; |
|
|
|
@ -38,64 +48,73 @@ var public ChatAPI chat;
|
|
|
|
|
var public ColorAPI color; |
|
|
|
|
var public UserAPI users; |
|
|
|
|
var public PlayersAPI players; |
|
|
|
|
var public JSONAPI json; |
|
|
|
|
var public JsonAPI json; |
|
|
|
|
var public SchedulerAPI scheduler; |
|
|
|
|
var public AvariceAPI avarice; |
|
|
|
|
|
|
|
|
|
var public AcediaEnvironment environment; |
|
|
|
|
|
|
|
|
|
public final static function Global GetInstance() |
|
|
|
|
{ |
|
|
|
|
/// Returns instance of the [`Global`] object. |
|
|
|
|
/// |
|
|
|
|
/// [`Global`] is supposed to be used as a singleton, meaning that only one instance of it should be |
|
|
|
|
/// created. |
|
|
|
|
/// This method creates and returns such instance. |
|
|
|
|
/// In case it was already created, that instance will be returned from now one. |
|
|
|
|
public final static function Global GetInstance() { |
|
|
|
|
if (default.myself == none) { |
|
|
|
|
// `...Global`s are special and exist outside main Acedia's |
|
|
|
|
// object infrastructure, so we allocate it without using API methods. |
|
|
|
|
// `...Global`s are special and exist outside main Acedia's object infrastructure, |
|
|
|
|
//so we allocate it without using [`MemoryAPI`] methods. |
|
|
|
|
default.myself = new class'Global'; |
|
|
|
|
default.myself.Initialize(); |
|
|
|
|
} |
|
|
|
|
return default.myself; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected function Initialize() |
|
|
|
|
{ |
|
|
|
|
/// Initializes [`Global`] by creating all API from base realm. |
|
|
|
|
protected function Initialize() { |
|
|
|
|
// Special case that we cannot spawn with memory API since it obviously |
|
|
|
|
// does not exist yet! |
|
|
|
|
memory = new class'MemoryAPI'; |
|
|
|
|
memory._constructor(); |
|
|
|
|
// `TextAPI` and `CollectionsAPI` need to be loaded before `LoggerAPI` |
|
|
|
|
ref = RefAPI(memory.Allocate(class'RefAPI')); |
|
|
|
|
box = BoxAPI(memory.Allocate(class'BoxAPI')); |
|
|
|
|
text = TextAPI(memory.Allocate(class'TextAPI')); |
|
|
|
|
math = MathAPI(memory.Allocate(class'MathAPI')); |
|
|
|
|
ref = RefAPI(memory.Allocate(class'RefAPI')); |
|
|
|
|
box = BoxAPI(memory.Allocate(class'BoxAPI')); |
|
|
|
|
text = TextAPI(memory.Allocate(class'TextAPI')); |
|
|
|
|
math = MathAPI(memory.Allocate(class'MathAPI')); |
|
|
|
|
collections = CollectionsAPI(memory.Allocate(class'CollectionsAPI')); |
|
|
|
|
json = JSONAPI(memory.Allocate(class'JSONAPI')); |
|
|
|
|
logger = LoggerAPI(memory.Allocate(class'LoggerAPI')); |
|
|
|
|
color = ColorAPI(memory.Allocate(class'ColorAPI')); |
|
|
|
|
alias = AliasesAPI(memory.Allocate(class'AliasesAPI')); |
|
|
|
|
console = ConsoleAPI(memory.Allocate(class'ConsoleAPI')); |
|
|
|
|
chat = ChatAPI(memory.Allocate(class'ChatAPI')); |
|
|
|
|
users = UserAPI(memory.Allocate(class'UserAPI')); |
|
|
|
|
players = PlayersAPI(memory.Allocate(class'PlayersAPI')); |
|
|
|
|
scheduler = SchedulerAPI(memory.Allocate(class'SchedulerAPI')); |
|
|
|
|
avarice = AvariceAPI(memory.Allocate(class'AvariceAPI')); |
|
|
|
|
json = JsonAPI(memory.Allocate(class'JsonAPI')); |
|
|
|
|
logger = LoggerAPI(memory.Allocate(class'LoggerAPI')); |
|
|
|
|
color = ColorAPI(memory.Allocate(class'ColorAPI')); |
|
|
|
|
alias = AliasesAPI(memory.Allocate(class'AliasesAPI')); |
|
|
|
|
console = ConsoleAPI(memory.Allocate(class'ConsoleAPI')); |
|
|
|
|
chat = ChatAPI(memory.Allocate(class'ChatAPI')); |
|
|
|
|
users = UserAPI(memory.Allocate(class'UserAPI')); |
|
|
|
|
players = PlayersAPI(memory.Allocate(class'PlayersAPI')); |
|
|
|
|
scheduler = SchedulerAPI(memory.Allocate(class'SchedulerAPI')); |
|
|
|
|
avarice = AvariceAPI(memory.Allocate(class'AvariceAPI')); |
|
|
|
|
environment = AcediaEnvironment(memory.Allocate(class'AcediaEnvironment')); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function DropCoreAPI() |
|
|
|
|
{ |
|
|
|
|
memory = none; |
|
|
|
|
ref = none; |
|
|
|
|
box = none; |
|
|
|
|
text = none; |
|
|
|
|
/// Drops references to all API from base realm, including self-reference, previously returned by |
|
|
|
|
/// [`Global::GetInstance()`] method. |
|
|
|
|
public function DropCoreAPI() { |
|
|
|
|
memory = none; |
|
|
|
|
ref = none; |
|
|
|
|
box = none; |
|
|
|
|
text = none; |
|
|
|
|
collections = none; |
|
|
|
|
logger = none; |
|
|
|
|
alias = none; |
|
|
|
|
console = none; |
|
|
|
|
chat = none; |
|
|
|
|
color = none; |
|
|
|
|
users = none; |
|
|
|
|
players = none; |
|
|
|
|
json = none; |
|
|
|
|
scheduler = none; |
|
|
|
|
avarice = none; |
|
|
|
|
logger = none; |
|
|
|
|
alias = none; |
|
|
|
|
console = none; |
|
|
|
|
chat = none; |
|
|
|
|
color = none; |
|
|
|
|
users = none; |
|
|
|
|
players = none; |
|
|
|
|
json = none; |
|
|
|
|
scheduler = none; |
|
|
|
|
avarice = none; |
|
|
|
|
default.myself = none; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
defaultproperties { |
|
|
|
|
} |