Browse Source

Fix `_client.unreal` using server API's classes

pull/8/head
Anton Tarasenko 2 years ago
parent
commit
8c3729fbdc
  1. 32
      sources/ClientRealm/API/Unreal/ClientUnrealAPI.uc
  2. 50
      sources/ClientRealm/AcediaInteraction.uc
  3. 2
      sources/CoreRealm/API/UnrealAPI/Events/Unreal_OnTick_Signal.uc
  4. 2
      sources/CoreRealm/API/UnrealAPI/Events/Unreal_OnTick_Slot.uc

32
sources/ClientRealm/API/Unreal/ClientUnrealAPI.uc

@ -21,33 +21,17 @@ class ClientUnrealAPI extends ClientUnrealAPIBase;
var private LoggerAPI.Definition fatalNoStalker; 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 */ /* SIGNAL */
public function Unreal_OnTick_Slot OnTick( public function Unreal_OnTick_Slot OnTick(AcediaObject receiver)
AcediaObject receiver)
{ {
local Signal signal; local AcediaInteraction acediaInteraction;
local ServerUnrealService service;
service = ServerUnrealService(class'ServerUnrealService'.static.Require()); // Simple redirect to `AcediaInteraction`
signal = service.GetSignal(class'Unreal_OnTick_Signal'); acediaInteraction = class'AcediaInteraction'.static.GetInstance();
return Unreal_OnTick_Slot(signal.NewSlot(receiver)); if (acediaInteraction != none) {
return acediaInteraction.OnTick(receiver);
}
return none;
} }
/* SIGNAL */ /* SIGNAL */

50
sources/ClientRealm/AcediaInteraction.uc

@ -19,17 +19,33 @@
*/ */
class AcediaInteraction extends Interaction; class AcediaInteraction extends Interaction;
#exec OBJ LOAD FILE=KillingFloorHUD.utx
#exec OBJ LOAD FILE=KillingFloor2HUD.utx
var private Global _; var private Global _;
var private ClientGlobal _client; var private ClientGlobal _client;
var private AcediaInteraction myself; var private AcediaInteraction myself;
var Texture shield;
var private Unreal_OnTick_Signal onTickSignal;
var private Interaction_OnRender_Signal onPreRenderSignal; var private Interaction_OnRender_Signal onPreRenderSignal;
var private Interaction_OnRender_Signal onPostRenderSignal; var private Interaction_OnRender_Signal onPostRenderSignal;
/**
* Signal that will be emitted every tick.
*
* [Signature]
* void <slot>(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()` * Called before rendering, when `Interaction`s receive their `PreRender()`
* events * events
@ -71,6 +87,8 @@ public final function InitializeInteraction()
default.myself = self; default.myself = self;
_ = class'Global'.static.GetInstance(); _ = class'Global'.static.GetInstance();
_client = class'ClientGlobal'.static.GetInstance(); _client = class'ClientGlobal'.static.GetInstance();
onTickSignal = Unreal_OnTick_Signal(
_.memory.Allocate(class'Unreal_OnTick_Signal'));
onPreRenderSignal = Interaction_OnRender_Signal( onPreRenderSignal = Interaction_OnRender_Signal(
_.memory.Allocate(class'Interaction_OnRender_Signal')); _.memory.Allocate(class'Interaction_OnRender_Signal'));
onPostRenderSignal = Interaction_OnRender_Signal( onPostRenderSignal = Interaction_OnRender_Signal(
@ -79,6 +97,12 @@ public final function InitializeInteraction()
event NotifyLevelChange() event NotifyLevelChange()
{ {
_.memory.Free(onTickSignal);
_.memory.Free(onPreRenderSignal);
_.memory.Free(onPostRenderSignal);
onTickSignal = none;
onPreRenderSignal = none;
onPostRenderSignal = none;
_.environment.ShutDown(); _.environment.ShutDown();
default.myself = none; default.myself = none;
_ = none; _ = none;
@ -105,16 +129,24 @@ public function PreRender(Canvas canvas)
public function PostRender(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) { if (onPostRenderSignal != none) {
onPostRenderSignal.Emit(canvas); 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 defaultproperties
{ {
shield = Texture'KillingFloorHUD.HUD.Hud_Shield' bVisible = true
bVisible = true bRequiresTick = true
} }

2
sources/ServerRealm/API/Unreal/Events/Unreal_OnTick_Signal.uc → 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 * Copyright 2021 Anton Tarasenko
*------------------------------------------------------------------------------ *------------------------------------------------------------------------------
* This file is part of Acedia. * This file is part of Acedia.

2
sources/ServerRealm/API/Unreal/Events/Unreal_OnTick_Slot.uc → 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 * Copyright 2021 Anton Tarasenko
*------------------------------------------------------------------------------ *------------------------------------------------------------------------------
* This file is part of Acedia. * This file is part of Acedia.
Loading…
Cancel
Save