Browse Source

Add shutdown event for `LevelCore`

pull/8/head
Anton Tarasenko 2 years ago
parent
commit
02defb53db
  1. 21
      sources/CoreRealm/LevelCore.uc
  2. 7
      sources/ServerLevelCore.uc

21
sources/CoreRealm/LevelCore.uc

@ -53,11 +53,31 @@ var private bool blockSpawning;
// `LevelCore` // `LevelCore`
var private LevelCore activeInstance; var private LevelCore activeInstance;
var private SimpleSignal onShutdownSignal;
protected function Constructor()
{
onShutdownSignal = SimpleSignal(_.memory.Allocate(class'SimpleSignal'));
}
protected function Finalizer() protected function Finalizer()
{ {
_.memory.Free(onShutdownSignal);
default.activeInstance = none; default.activeInstance = none;
} }
/**
* Signal that will be emitted when caller level core is shut down.
*
* [Signature]
* void <slot>()
*/
/* SIGNAL */
public final function SimpleSlot OnShutdown(AcediaObject receiver)
{
return SimpleSlot(onShutdownSignal.NewSlot(receiver));
}
public static function LevelCore CreateLevelCore(Actor source) public static function LevelCore CreateLevelCore(Actor source)
{ {
if (GetInstance() != none) return none; if (GetInstance() != none) return none;
@ -95,6 +115,7 @@ event PreBeginPlay()
// Clean up // Clean up
event Destroyed() event Destroyed()
{ {
onShutdownSignal.Emit();
if (self == default.activeInstance) { if (self == default.activeInstance) {
default.activeInstance = none; default.activeInstance = none;
} }

7
sources/ServerLevelCore.uc

@ -18,6 +18,13 @@
*/ */
class ServerLevelCore extends LevelCore; class ServerLevelCore extends LevelCore;
protected function Constructor()
{
super.Constructor();
// TODO: this is hack, needs to be redone later
KF1_HealthComponent(_.kf.health).PresudoConstructor();
}
public static function LevelCore CreateLevelCore(Actor source) public static function LevelCore CreateLevelCore(Actor source)
{ {
if (source == none) return none; if (source == none) return none;

Loading…
Cancel
Save