More actor and UObject progress

This commit is contained in:
AeonLucid
2022-01-17 23:02:10 +01:00
parent fe97b7a145
commit 458bae0523
24 changed files with 421 additions and 18 deletions
+39 -3
View File
@@ -1,11 +1,18 @@
using Prospect.Unreal.Core;
using Prospect.Unreal.Core.Objects;
using Prospect.Unreal.Runtime;
namespace Prospect.Unreal.Net.Actors;
public class AActor
public class AActor : UObject
{
private bool bActorInitialized;
// TODO: UPROPERTY(BlueprintReadWrite, ReplicatedUsing=OnRep_Instigator, meta=(ExposeOnSpawn=true, AllowPrivateAccess=true), Category=Actor)
/// <summary>
/// Pawn responsible for damage and other gameplay events caused by this actor.
/// </summary>
private APawn? _instigator;
/// <summary>
/// Sets the value of Role without causing other side effects to this instance.
@@ -36,9 +43,38 @@ public class AActor
throw new NotImplementedException();
}
public UWorld GetWorld()
public UWorld? GetWorld()
{
// if ()
if (!HasAnyFlags(EObjectFlags.RF_ClassDefaultObject))
{
var outer = GetOuter();
if (outer == null)
{
return null;
}
if (!outer.HasAnyFlags(EObjectFlags.RF_BeginDestroyed) &&
!outer.IsUnreachable())
{
var level = GetLevel();
if (level != null)
{
return level.OwningWorld;
}
}
}
return null;
}
public ULevel? GetLevel()
{
return GetTypedOuter<ULevel>();
}
public APawn? GetInstigator()
{
return _instigator;
}
public bool IsActorInitialized()
@@ -1,4 +1,5 @@
using Prospect.Unreal.Core;
using Prospect.Unreal.Core.Objects;
using Prospect.Unreal.Runtime;
namespace Prospect.Unreal.Net.Actors;
@@ -19,6 +20,12 @@ public class AGameModeBase : AInfo
public virtual void InitGame(string mapName, string options, out string errorMessage)
{
// Default error.
errorMessage = string.Empty;
// Find world.
var world = GetWorld();
// Save Options for future use
OptionsString = options;
@@ -28,7 +35,7 @@ public class AGameModeBase : AInfo
ObjectFlags = EObjectFlags.RF_Transient
};
GameSession = World.SpawnActor();
// GameSession = world.SpawnActor();
}
public virtual void InitGameState()
+6
View File
@@ -0,0 +1,6 @@
namespace Prospect.Unreal.Net.Actors;
public class APawn : AActor
{
}