Browse Source

Change `TimeAPI` to choose class from adapter

pull/8/head
Anton Tarasenko 2 years ago
parent
commit
38b024d2ce
  1. 2
      sources/ServerRealm/API/Time/Events/Timer_OnElapsed_Signal.uc
  2. 0
      sources/ServerRealm/API/Time/Events/Timer_OnElapsed_Slot.uc
  3. 0
      sources/ServerRealm/API/Time/RealTimer.uc
  4. 63
      sources/ServerRealm/API/Time/ServerTimeAPI.uc
  5. 44
      sources/ServerRealm/API/Time/ServerTimeAPIBase.uc
  6. 0
      sources/ServerRealm/API/Time/Timer.uc
  7. 2
      sources/ServerRealm/ServerAcediaAdapter.uc
  8. 9
      sources/ServerRealm/ServerGlobal.uc

2
sources/Time/Events/Timer_OnElapsed_Signal.uc → sources/ServerRealm/API/Time/Events/Timer_OnElapsed_Signal.uc

@ -19,7 +19,7 @@
*/
class Timer_OnElapsed_Signal extends Signal;
public final function Emit(Timer source)
public function Emit(Timer source)
{
local Slot nextSlot;
StartIterating();

0
sources/Time/Events/Timer_OnElapsed_Slot.uc → sources/ServerRealm/API/Time/Events/Timer_OnElapsed_Slot.uc

0
sources/Time/RealTimer.uc → sources/ServerRealm/API/Time/RealTimer.uc

63
sources/ServerRealm/API/Time/ServerTimeAPI.uc

@ -0,0 +1,63 @@
/**
* Acedia's default `ServerTimeAPIBase` API implementation
* Copyright 2021-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 ServerTimeAPI extends ServerTimeAPIBase;
public function Timer NewTimer(
optional float interval,
optional bool autoReset)
{
return Timer(_.memory.Allocate(class'Timer'))
.SetInterval(interval)
.SetAutoReset(autoReset);
}
public function Timer StartTimer(float interval, optional bool autoReset)
{
return Timer(_.memory.Allocate(class'Timer'))
.SetInterval(interval)
.SetAutoReset(autoReset)
.Start();
}
public function RealTimer NewRealTimer(
optional float interval,
optional bool autoReset)
{
local RealTimer newTimer;
newTimer = RealTimer(_.memory.Allocate(class'RealTimer'));
newTimer.SetInterval(interval).SetAutoReset(autoReset);
return newTimer;
}
public function RealTimer StartRealTimer(
float interval,
optional bool autoReset)
{
local RealTimer newTimer;
newTimer = RealTimer(_.memory.Allocate(class'RealTimer'));
newTimer.SetInterval(interval)
.SetAutoReset(autoReset)
.Start();
return newTimer;
}
defaultproperties
{
}

44
sources/Time/TimeAPI.uc → sources/ServerRealm/API/Time/ServerTimeAPIBase.uc

@ -1,6 +1,6 @@
/**
* API that provides time-related methods.
* Copyright 2021 Anton Tarasenko
* Copyright 2021-2022 Anton Tarasenko
*------------------------------------------------------------------------------
* This file is part of Acedia.
*
@ -17,7 +17,8 @@
* You should have received a copy of the GNU General Public License
* along with Acedia. If not, see <https://www.gnu.org/licenses/>.
*/
class TimeAPI extends AcediaObject;
class ServerTimeAPIBase extends AcediaObject
abstract;
/**
* Creates new `Timer`. Does not start it.
@ -30,14 +31,9 @@ class TimeAPI extends AcediaObject;
* @return `Timer`, configured to emit `OnElapsed()` every `interval` seconds.
* Not started. Guaranteed to be not `none`.
*/
public final function Timer NewTimer(
public function Timer NewTimer(
optional float interval,
optional bool autoReset)
{
return Timer(_.memory.Allocate(class'Timer'))
.SetInterval(interval)
.SetAutoReset(autoReset);
}
optional bool autoReset);
/**
* Creates and starts new `Timer`.
@ -50,13 +46,7 @@ public final function Timer NewTimer(
* @return `Timer`, configured to emit `OnElapsed()` every `interval` seconds.
* Guaranteed to be not `none`.
*/
public final function Timer StartTimer(float interval, optional bool autoReset)
{
return Timer(_.memory.Allocate(class'Timer'))
.SetInterval(interval)
.SetAutoReset(autoReset)
.Start();
}
public function Timer StartTimer(float interval, optional bool autoReset);
/**
* Creates new `RealTimer`. Does not start it.
@ -69,15 +59,9 @@ public final function Timer StartTimer(float interval, optional bool autoReset)
* @return `RealTimer`, configured to emit `OnElapsed()` every `interval`
* seconds. Not started. Guaranteed to be not `none`.
*/
public final function RealTimer NewRealTimer(
public function RealTimer NewRealTimer(
optional float interval,
optional bool autoReset)
{
local RealTimer newTimer;
newTimer = RealTimer(_.memory.Allocate(class'RealTimer'));
newTimer.SetInterval(interval).SetAutoReset(autoReset);
return newTimer;
}
optional bool autoReset);
/**
* Creates and starts new `RealTimer`.
@ -91,17 +75,9 @@ public final function RealTimer NewRealTimer(
* @return `RealTimer`, configured to emit `OnElapsed()` every `interval`
* seconds. Guaranteed to be not `none`.
*/
public final function RealTimer StartRealTimer(
public function RealTimer StartRealTimer(
float interval,
optional bool autoReset)
{
local RealTimer newTimer;
newTimer = RealTimer(_.memory.Allocate(class'RealTimer'));
newTimer.SetInterval(interval)
.SetAutoReset(autoReset)
.Start();
return newTimer;
}
optional bool autoReset);
defaultproperties
{

0
sources/Time/Timer.uc → sources/ServerRealm/API/Time/Timer.uc

2
sources/ServerRealm/ServerAcediaAdapter.uc

@ -22,6 +22,7 @@
class ServerAcediaAdapter extends AcediaAdapter
abstract;
var public const class<ServerTimeAPIBase> serverTimeAPIClass;
var public const class<ServerUnrealAPIBase> serverUnrealAPIClass;
var public const class<BroadcastAPIBase> serverBroadcastAPIClass;
var public const class<GameRulesAPIBase> serverGameRulesAPIClass;
@ -30,6 +31,7 @@ var public const class<MutatorAPIBase> serverMutatorAPIClass;
defaultproperties
{
serverTimeAPIClass = class'ServerTimeAPI'
serverUnrealAPIClass = class'ServerUnrealAPI'
serverBroadcastAPIClass = class'BroadcastAPI'
serverGameRulesAPIClass = class'GameRulesAPI'

9
sources/ServerRealm/ServerGlobal.uc

@ -25,9 +25,9 @@ class ServerGlobal extends CoreGlobal;
// main instance in this variable's default value.
var protected ServerGlobal myself;
var public KFFrontend kf;
var public ServerUnrealAPI unreal;
var public TimeAPI time;
var public KFFrontend kf;
var public ServerUnrealAPIBase unreal;
var public ServerTimeAPIBase time;
var private LoggerAPI.Definition fatBadAdapterClass;
@ -67,7 +67,8 @@ protected function Initialize()
unreal = ServerUnrealAPI(
_.memory.Allocate(serverAdapterClass.default.serverUnrealAPIClass));
unreal.Initialize(serverAdapterClass);
time = TimeAPI(_.memory.Allocate(class'TimeAPI'));
time = ServerTimeAPI(
_.memory.Allocate(serverAdapterClass.default.serverTimeAPIClass));
kf = KFFrontend(_.memory.Allocate(class'KF1_Frontend'));
}

Loading…
Cancel
Save