Actor progress

This commit is contained in:
AeonLucid
2022-01-16 23:05:53 +01:00
parent f3b7efca45
commit fe97b7a145
14 changed files with 431 additions and 22 deletions
+13
View File
@@ -1,9 +1,12 @@
using Prospect.Unreal.Core;
using Prospect.Unreal.Runtime;
namespace Prospect.Unreal.Net.Actors;
public class AActor
{
private bool bActorInitialized;
/// <summary>
/// Sets the value of Role without causing other side effects to this instance.
/// </summary>
@@ -32,4 +35,14 @@ public class AActor
// TODO: Implement
throw new NotImplementedException();
}
public UWorld GetWorld()
{
// if ()
}
public bool IsActorInitialized()
{
return bActorInitialized;
}
}
@@ -5,6 +5,37 @@ namespace Prospect.Unreal.Net.Actors;
public class AGameModeBase : AInfo
{
public AGameModeBase()
{
OptionsString = string.Empty;
}
/// <summary>
/// Save options string and parse it when needed
/// </summary>
public string OptionsString { get; set; }
public AGameSession? GameSession { get; set; }
public virtual void InitGame(string mapName, string options, out string errorMessage)
{
// Save Options for future use
OptionsString = options;
var spawnInfo = new FActorSpawnParameters
{
Instigator = GetInstigator(),
ObjectFlags = EObjectFlags.RF_Transient
};
GameSession = World.SpawnActor();
}
public virtual void InitGameState()
{
throw new NotImplementedException();
}
public void PreLogin(string options, string address, FUniqueNetIdRepl uniqueId, out string? errorMessage)
{
// Login unique id must match server expected unique id type OR No unique id could mean game doesn't use them
@@ -14,8 +45,21 @@ public class AGameModeBase : AInfo
public APlayerController? Login(UPlayer newPlayer, ENetRole inRemoteRole, string portal, string options, FUniqueNetIdRepl uniqueId, out string errorMessage)
{
errorMessage = string.Empty;
if (GameSession == null)
{
errorMessage = "Failed to spawn player controller, GameSession is null";
return null;
}
errorMessage = GameSession.ApproveLogin(options);
if (!string.IsNullOrEmpty(errorMessage))
{
return null;
}
throw new NotImplementedException();
return null;
}
public void PostLogin(APlayerController newPlayer)
@@ -0,0 +1,12 @@
namespace Prospect.Unreal.Net.Actors;
public class AGameSession : AInfo
{
public string ApproveLogin(string options)
{
// Check;
// - SpectatorOnly
// - SplitscreenCount
return string.Empty;
}
}
@@ -0,0 +1,10 @@
namespace Prospect.Unreal.Net;
public enum ESpawnActorCollisionHandlingMethod
{
Undefined,
AlwaysSpawn,
AdjustIfPossibleButAlwaysSpawn,
AdjustIfPossibleButDontSpawnIfColliding,
DontSpawnIfColliding
}
@@ -0,0 +1,24 @@
namespace Prospect.Unreal.Net;
public enum ESpawnActorNameMode
{
/// <summary>
/// Fatal if unavailable, application will assert
/// </summary>
Required_Fatal,
/// <summary>
/// Report an error return null if unavailable
/// </summary>
Required_ErrorAndReturnNull,
/// <summary>
/// Return null if unavailable
/// </summary>
Required_ReturnNull,
/// <summary>
/// If the supplied Name is already in use the generate an unused one using the supplied version as a base
/// </summary>
Requested
}
@@ -0,0 +1,105 @@
using Prospect.Unreal.Core;
using Prospect.Unreal.Core.Names;
using Prospect.Unreal.Net.Actors;
namespace Prospect.Unreal.Net;
public ref struct FActorSpawnParameters
{
/// <summary>
/// A name to assign as the Name of the Actor being spawned.
/// If no value is specified, the name of the spawned Actor will be automatically generated using the form [Class]_[Number].
/// </summary>
public FName? Name { get; set; }
/// <summary>
/// An Actor to use as a template when spawning the new Actor.
/// The spawned Actor will be initialized using the property values of the template Actor.
/// If left NULL the class default object (CDO) will be used to initialize the spawned Actor.
/// </summary>
public AActor? Template { get; set; }
/// <summary>
/// The Actor that spawned this Actor. (Can be left as NULL).
/// </summary>
public AActor? Owner { get; set; }
/// <summary>
/// The APawn that is responsible for damage done by the spawned Actor. (Can be left as NULL).
/// </summary>
public AActor? Instigator { get; set; }
/// <summary>
/// The ULevel to spawn the Actor in, i.e. the Outer of the Actor.
/// If left as NULL the Outer of the Owner is used. If the Owner is NULL the persistent level is used.
/// </summary>
public ULevel? OverrideLevel { get; set; }
/// <summary>
/// The UPackage to set the Actor in.
/// If left as NULL the Package will not be set and the actor will be saved in the same package as the persistent level.
/// </summary>
public UPackage? OverridePackage { get; set; }
// UChildActorComponent
/// <summary>
/// The Guid to set to this actor. Should only be set when reinstancing blueprint actors.
/// </summary>
public FGuid? OverrideActorGuid { get; set; }
/// <summary>
/// Method for resolving collisions at the spawn point. Undefined means no override, use the actor's setting.
/// </summary>
public ESpawnActorCollisionHandlingMethod SpawnCollisionHandlingOverride { get; set; }
/// <summary>
/// Is the actor remotely owned.
/// This should only be set true by the package map when it is creating an actor on a client that was replicated from the server.
/// </summary>
public bool bRemoteOwned { get; set; }
/// <summary>
/// Determines whether spawning will not fail if certain conditions are not met.
/// If true, spawning will not fail because the class being spawned is `bStatic=true` or because the class of the template Actor is not the same as the class of the Actor being spawned.
/// </summary>
public bool bNoFail { get; set; }
/// <summary>
/// Determines whether the construction script will be run.
/// If true, the construction script will not be run on the spawned Actor.
/// Only applicable if the Actor is being spawned from a Blueprint.
/// </summary>
public bool bDeferConstruction { get; set; }
/// <summary>
/// Determines whether or not the actor may be spawned when running a construction script.
/// If true spawning will fail if a construction script is being run.
/// </summary>
public bool bAllowDuringConstructionScript { get; set; }
/// <summary>
/// Determines whether the begin play cycle will run on the spawned actor when in the editor.
/// </summary>
public bool bTemporaryEditorActor { get; set; }
/// <summary>
/// Determines whether or not the actor should be hidden from the Scene Outliner
/// </summary>
public bool bHideFromSceneOutliner { get; set; }
/// <summary>
/// Determines whether to create a new package for the actor or not.
/// </summary>
public bool bCreateActorPackage { get; set; }
/// <summary>
/// In which way should SpawnActor should treat the supplied Name if not none.
/// </summary>
public ESpawnActorNameMode NameMode { get; set; }
/// <summary>
/// Flags used to describe the spawned actor/object instance.
/// </summary>
public EObjectFlags ObjectFlags { get; set; }
}