diff --git a/sources/Time/Events/Timer_OnElapsed_Signal.uc b/sources/ServerRealm/API/Time/Events/Timer_OnElapsed_Signal.uc similarity index 96% rename from sources/Time/Events/Timer_OnElapsed_Signal.uc rename to sources/ServerRealm/API/Time/Events/Timer_OnElapsed_Signal.uc index ec2cc82..4d83f4a 100644 --- a/sources/Time/Events/Timer_OnElapsed_Signal.uc +++ b/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(); diff --git a/sources/Time/Events/Timer_OnElapsed_Slot.uc b/sources/ServerRealm/API/Time/Events/Timer_OnElapsed_Slot.uc similarity index 100% rename from sources/Time/Events/Timer_OnElapsed_Slot.uc rename to sources/ServerRealm/API/Time/Events/Timer_OnElapsed_Slot.uc diff --git a/sources/Time/RealTimer.uc b/sources/ServerRealm/API/Time/RealTimer.uc similarity index 100% rename from sources/Time/RealTimer.uc rename to sources/ServerRealm/API/Time/RealTimer.uc diff --git a/sources/ServerRealm/API/Time/ServerTimeAPI.uc b/sources/ServerRealm/API/Time/ServerTimeAPI.uc new file mode 100644 index 0000000..1461311 --- /dev/null +++ b/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 . + */ +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 +{ +} \ No newline at end of file diff --git a/sources/Time/TimeAPI.uc b/sources/ServerRealm/API/Time/ServerTimeAPIBase.uc similarity index 74% rename from sources/Time/TimeAPI.uc rename to sources/ServerRealm/API/Time/ServerTimeAPIBase.uc index 9bce64d..1f33bd0 100644 --- a/sources/Time/TimeAPI.uc +++ b/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 . */ -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 { diff --git a/sources/Time/Timer.uc b/sources/ServerRealm/API/Time/Timer.uc similarity index 100% rename from sources/Time/Timer.uc rename to sources/ServerRealm/API/Time/Timer.uc diff --git a/sources/ServerRealm/ServerAcediaAdapter.uc b/sources/ServerRealm/ServerAcediaAdapter.uc index 5e6d2a2..681a67f 100644 --- a/sources/ServerRealm/ServerAcediaAdapter.uc +++ b/sources/ServerRealm/ServerAcediaAdapter.uc @@ -22,6 +22,7 @@ class ServerAcediaAdapter extends AcediaAdapter abstract; +var public const class serverTimeAPIClass; var public const class serverUnrealAPIClass; var public const class serverBroadcastAPIClass; var public const class serverGameRulesAPIClass; @@ -30,6 +31,7 @@ var public const class serverMutatorAPIClass; defaultproperties { + serverTimeAPIClass = class'ServerTimeAPI' serverUnrealAPIClass = class'ServerUnrealAPI' serverBroadcastAPIClass = class'BroadcastAPI' serverGameRulesAPIClass = class'GameRulesAPI' diff --git a/sources/ServerRealm/ServerGlobal.uc b/sources/ServerRealm/ServerGlobal.uc index 6732851..8354eb3 100644 --- a/sources/ServerRealm/ServerGlobal.uc +++ b/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')); }