diff --git a/sources/ClientRealm/API/Unreal/ClientUnrealAPI.uc b/sources/ClientRealm/API/Unreal/ClientUnrealAPI.uc index beee114..7e54014 100644 --- a/sources/ClientRealm/API/Unreal/ClientUnrealAPI.uc +++ b/sources/ClientRealm/API/Unreal/ClientUnrealAPI.uc @@ -21,33 +21,17 @@ class ClientUnrealAPI extends ClientUnrealAPIBase; var private LoggerAPI.Definition fatalNoStalker; -protected function Constructor() -{ - _.environment.OnShutDownSystem(self).connect = HandleShutdown; -} - -protected function HandleShutdown() -{ - local ServerUnrealService service; - - service = ServerUnrealService( - class'ServerUnrealService'.static.GetInstance()); - // This has to clean up anything we've added - if (service != none) { - service.Destroy(); - } -} - /* SIGNAL */ -public function Unreal_OnTick_Slot OnTick( - AcediaObject receiver) +public function Unreal_OnTick_Slot OnTick(AcediaObject receiver) { - local Signal signal; - local ServerUnrealService service; + local AcediaInteraction acediaInteraction; - service = ServerUnrealService(class'ServerUnrealService'.static.Require()); - signal = service.GetSignal(class'Unreal_OnTick_Signal'); - return Unreal_OnTick_Slot(signal.NewSlot(receiver)); + // Simple redirect to `AcediaInteraction` + acediaInteraction = class'AcediaInteraction'.static.GetInstance(); + if (acediaInteraction != none) { + return acediaInteraction.OnTick(receiver); + } + return none; } /* SIGNAL */ diff --git a/sources/ClientRealm/AcediaInteraction.uc b/sources/ClientRealm/AcediaInteraction.uc index 84d5b5b..5f6ea15 100644 --- a/sources/ClientRealm/AcediaInteraction.uc +++ b/sources/ClientRealm/AcediaInteraction.uc @@ -19,17 +19,33 @@ */ class AcediaInteraction extends Interaction; -#exec OBJ LOAD FILE=KillingFloorHUD.utx -#exec OBJ LOAD FILE=KillingFloor2HUD.utx - var private Global _; var private ClientGlobal _client; var private AcediaInteraction myself; -var Texture shield; +var private Unreal_OnTick_Signal onTickSignal; var private Interaction_OnRender_Signal onPreRenderSignal; var private Interaction_OnRender_Signal onPostRenderSignal; +/** + * Signal that will be emitted every tick. + * + * [Signature] + * void (float delta, float dilationCoefficient) + * + * @param delta In-game time in seconds that has passed since + * the last tick. To obtain real time passed from the last tick divide + * `delta` by `dilationCoefficient`. + * @param dilationCoefficient How fast is in-game time flow compared to + * the real world's one? `2` means twice as fast and + * `0.5` means twice as slow. + */ +/* SIGNAL */ +public function Unreal_OnTick_Slot OnTick(AcediaObject receiver) +{ + return Unreal_OnTick_Slot(onTickSignal.NewSlot(receiver)); +} + /** * Called before rendering, when `Interaction`s receive their `PreRender()` * events @@ -71,6 +87,8 @@ public final function InitializeInteraction() default.myself = self; _ = class'Global'.static.GetInstance(); _client = class'ClientGlobal'.static.GetInstance(); + onTickSignal = Unreal_OnTick_Signal( + _.memory.Allocate(class'Unreal_OnTick_Signal')); onPreRenderSignal = Interaction_OnRender_Signal( _.memory.Allocate(class'Interaction_OnRender_Signal')); onPostRenderSignal = Interaction_OnRender_Signal( @@ -79,6 +97,12 @@ public final function InitializeInteraction() event NotifyLevelChange() { + _.memory.Free(onTickSignal); + _.memory.Free(onPreRenderSignal); + _.memory.Free(onPostRenderSignal); + onTickSignal = none; + onPreRenderSignal = none; + onPostRenderSignal = none; _.environment.ShutDown(); default.myself = none; _ = none; @@ -105,16 +129,24 @@ public function PreRender(Canvas canvas) public function PostRender(Canvas canvas) { - Log("dsfsdfs"); - canvas.SetPos(500, 500); - canvas.DrawTile(shield, 16, 16, 0, 0, shield.MaterialUSize(), shield.MaterialVSize()); if (onPostRenderSignal != none) { onPostRenderSignal.Emit(canvas); } } +public function Tick(float delta) +{ + local float dilationCoefficient; + + if (onTickSignal != none) + { + dilationCoefficient = _client.unreal.GetLevel().timeDilation / 1.1; + onTickSignal.Emit(delta, dilationCoefficient); + } +} + defaultproperties { - shield = Texture'KillingFloorHUD.HUD.Hud_Shield' - bVisible = true + bVisible = true + bRequiresTick = true } \ No newline at end of file diff --git a/sources/ServerRealm/API/Unreal/Events/Unreal_OnTick_Signal.uc b/sources/CoreRealm/API/UnrealAPI/Events/Unreal_OnTick_Signal.uc similarity index 93% rename from sources/ServerRealm/API/Unreal/Events/Unreal_OnTick_Signal.uc rename to sources/CoreRealm/API/UnrealAPI/Events/Unreal_OnTick_Signal.uc index e732be0..951e93f 100644 --- a/sources/ServerRealm/API/Unreal/Events/Unreal_OnTick_Signal.uc +++ b/sources/CoreRealm/API/UnrealAPI/Events/Unreal_OnTick_Signal.uc @@ -1,5 +1,5 @@ /** - * Signal class implementation for `ServerUnrealAPI`'s `OnTick` signal. + * Signal class implementation for `UnrealAPI`'s `OnTick` signal. * Copyright 2021 Anton Tarasenko *------------------------------------------------------------------------------ * This file is part of Acedia. diff --git a/sources/ServerRealm/API/Unreal/Events/Unreal_OnTick_Slot.uc b/sources/CoreRealm/API/UnrealAPI/Events/Unreal_OnTick_Slot.uc similarity index 93% rename from sources/ServerRealm/API/Unreal/Events/Unreal_OnTick_Slot.uc rename to sources/CoreRealm/API/UnrealAPI/Events/Unreal_OnTick_Slot.uc index 65931f7..3a4ad96 100644 --- a/sources/ServerRealm/API/Unreal/Events/Unreal_OnTick_Slot.uc +++ b/sources/CoreRealm/API/UnrealAPI/Events/Unreal_OnTick_Slot.uc @@ -1,5 +1,5 @@ /** - * Slot class implementation for `ServerUnrealAPI`'s `OnTick` signal. + * Slot class implementation for `UnrealAPI`'s `OnTick` signal. * Copyright 2021 Anton Tarasenko *------------------------------------------------------------------------------ * This file is part of Acedia.