Browse Source

Add stud server and client globals

pull/8/head
Anton Tarasenko 2 years ago
parent
commit
4f9c3b134f
  1. 45
      sources/CoreRealm/ClientGlobal.uc
  2. 8
      sources/CoreRealm/Global.uc
  3. 45
      sources/CoreRealm/ServerGlobal.uc
  4. 26
      sources/Types/AcediaActor.uc
  5. 26
      sources/Types/AcediaObject.uc

45
sources/CoreRealm/ClientGlobal.uc

@ -0,0 +1,45 @@
/**
* Class for an object that will provide an access to a Acedia's
* client-specific functionality by giving a reference to this object to all
* Acedia's objects and actors, emulating a global API namespace.
* Copyright 2022 Anton Tarasenko
*------------------------------------------------------------------------------
* 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/>.
*/
class ClientGlobal extends Object;
// `Global` is expected to behave like a singleton and will store it's
// main instance in this variable's default value.
var protected ClientGlobal myself;
public final static function ClientGlobal 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.
default.myself = new class'ClientGlobal';
}
return default.myself;
}
protected function Initialize()
{
}
defaultproperties
{
}

8
sources/CoreRealm/Global.uc

@ -1,8 +1,8 @@
/** /**
* Class for an object that will provide an access to a Acedia's functionality * Class for an object that will provide an access to a Acedia's functionality
* by giving a reference to this object to all Acedia's objects and actors, * that is common for both clients and servers by giving a reference to this
* emulating a global API namespace. * object to all Acedia's objects and actors, emulating a global API namespace.
* Copyright 2020 - 2021 Anton Tarasenko * Copyright 2020-2022 Anton Tarasenko
*------------------------------------------------------------------------------ *------------------------------------------------------------------------------
* This file is part of Acedia. * This file is part of Acedia.
* *
@ -50,7 +50,7 @@ var public KFFrontend kf;
public final static function Global GetInstance() public final static function Global GetInstance()
{ {
if (default.myself == none) { if (default.myself == none) {
// `Global` is special and exists outside main Acedia's // `...Global`s are special and exist outside main Acedia's
// object infrastructure, so we allocate it without using API methods. // object infrastructure, so we allocate it without using API methods.
default.myself = new class'Global'; default.myself = new class'Global';
default.myself.Initialize(); default.myself.Initialize();

45
sources/CoreRealm/ServerGlobal.uc

@ -0,0 +1,45 @@
/**
* Class for an object that will provide an access to a Acedia's
* server-specific functionality by giving a reference to this object to all
* Acedia's objects and actors, emulating a global API namespace.
* Copyright 2022 Anton Tarasenko
*------------------------------------------------------------------------------
* 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/>.
*/
class ServerGlobal extends Object;
// `Global` is expected to behave like a singleton and will store it's
// main instance in this variable's default value.
var protected ServerGlobal myself;
public final static function ServerGlobal 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.
default.myself = new class'ServerGlobal';
}
return default.myself;
}
protected function Initialize()
{
}
defaultproperties
{
}

26
sources/Types/AcediaActor.uc

@ -23,8 +23,10 @@
class AcediaActor extends Actor class AcediaActor extends Actor
abstract; abstract;
// Reference to Acedia's APIs for simple access. // References to Acedia's APIs for simple access.
var protected Global _; var protected Global _;
var protected ServerGlobal _server;
var protected ClientGlobal _client;
// To make logic simpler and increase efficiency, we allow storing a reference // To make logic simpler and increase efficiency, we allow storing a reference
// to any actors in many different places. To know when we can actually // to any actors in many different places. To know when we can actually
@ -74,6 +76,8 @@ public function _constructor()
_isAllocated = true; _isAllocated = true;
_refCounter = 1; _refCounter = 1;
_ = class'Global'.static.GetInstance(); _ = class'Global'.static.GetInstance();
_server = class'ServerGlobal'.static.GetInstance();
_client = class'ClientGlobal'.static.GetInstance();
if (!default._staticConstructorWasCalled) if (!default._staticConstructorWasCalled)
{ {
CreateTextCache(); CreateTextCache();
@ -99,6 +103,8 @@ public function _finalizer()
_refCounter = 0; _refCounter = 0;
Finalizer(); Finalizer();
_ = none; _ = none;
_server = none;
_client = none;
} }
/** /**
@ -409,6 +415,24 @@ public static final function Global __()
return class'Global'.static.GetInstance(); return class'Global'.static.GetInstance();
} }
/**
* Static method accessor to server API namespace, necessary for Acedia's
* implementation.
*/
public static final function ServerGlobal __server()
{
return class'ServerGlobal'.static.GetInstance();
}
/**
* Static method accessor to client API namespace, necessary for Acedia's
* implementation.
*/
public static final function ClientGlobal __client()
{
return class'ClientGlobal'.static.GetInstance();
}
/** /**
* If you are overloading this event - you have to first call * If you are overloading this event - you have to first call
* `super.PreBeginPlay()`, otherwise Acedia might not function properly. * `super.PreBeginPlay()`, otherwise Acedia might not function properly.

26
sources/Types/AcediaObject.uc

@ -23,8 +23,10 @@
class AcediaObject extends Object class AcediaObject extends Object
abstract; abstract;
// Reference to Acedia's APIs for simple access. // References to Acedia's APIs for simple access.
var protected Global _; var protected Global _;
var protected ServerGlobal _server;
var protected ClientGlobal _client;
// Object pool to store objects of a particular class // Object pool to store objects of a particular class
var private AcediaObjectPool _objectPool; var private AcediaObjectPool _objectPool;
// Does this class even use object pool? // Does this class even use object pool?
@ -116,6 +118,8 @@ public final function _constructor()
_lifeVersion += 1; _lifeVersion += 1;
_refCounter = 1; _refCounter = 1;
_ = class'Global'.static.GetInstance(); _ = class'Global'.static.GetInstance();
_server = class'ServerGlobal'.static.GetInstance();
_client = class'ClientGlobal'.static.GetInstance();
if (!default._staticConstructorWasCalled) if (!default._staticConstructorWasCalled)
{ {
CreateTextCache(); CreateTextCache();
@ -140,6 +144,8 @@ public final function _finalizer()
_refCounter = 0; _refCounter = 0;
Finalizer(); Finalizer();
_ = none; _ = none;
_server = none;
_client = none;
} }
/** /**
@ -483,6 +489,24 @@ public static final function Global __()
return class'Global'.static.GetInstance(); return class'Global'.static.GetInstance();
} }
/**
* Static method accessor to server API namespace, necessary for Acedia's
* implementation.
*/
public static final function ServerGlobal __server()
{
return class'ServerGlobal'.static.GetInstance();
}
/**
* Static method accessor to client API namespace, necessary for Acedia's
* implementation.
*/
public static final function ClientGlobal __client()
{
return class'ClientGlobal'.static.GetInstance();
}
/** /**
* This function is called upon Acedia's shutdown, if `StaticConstructor()` * This function is called upon Acedia's shutdown, if `StaticConstructor()`
* was called for this class. * was called for this class.

Loading…
Cancel
Save