| @ -0,0 +1,6 @@ | ||||
| #include "CSEngineSubsystem.h" | ||||
|  | ||||
| bool UCSEngineSubsystem::K2_ShouldCreateSubsystem_Implementation() const | ||||
| { | ||||
| 	return true; | ||||
| } | ||||
| @ -0,0 +1,90 @@ | ||||
| // Fill out your copyright notice in the Description page of Project Settings. | ||||
|  | ||||
| #pragma once | ||||
|  | ||||
| #include "CoreMinimal.h" | ||||
| #include "SubsystemCollectionBaseRef.h" | ||||
| #include "Subsystems/EngineSubsystem.h" | ||||
| #include "CSEngineSubsystem.generated.h" | ||||
|  | ||||
| UCLASS(Blueprintable, BlueprintType, Abstract) | ||||
| class UCSEngineSubsystem : public UEngineSubsystem, public FTickableGameObject | ||||
| { | ||||
| 	GENERATED_BODY() | ||||
|  | ||||
| 	// USubsystem Begin | ||||
|  | ||||
| 	virtual void Initialize(FSubsystemCollectionBase& Collection) override | ||||
| 	{ | ||||
| 		Super::Initialize(Collection); | ||||
| 		K2_Initialize(Collection); | ||||
| 	} | ||||
|  | ||||
| 	virtual void Deinitialize() override | ||||
| 	{ | ||||
| 		Super::Deinitialize(); | ||||
| 		K2_Deinitialize(); | ||||
| 	} | ||||
|  | ||||
| 	virtual bool ShouldCreateSubsystem(UObject* Outer) const override | ||||
| 	{ | ||||
| 		if (!Super::ShouldCreateSubsystem(Outer)) | ||||
| 		{ | ||||
| 			return false; | ||||
| 		} | ||||
|  | ||||
| 		return K2_ShouldCreateSubsystem(); | ||||
| 	} | ||||
|  | ||||
| 	// End | ||||
|  | ||||
| 	// FTickableGameObject Begin | ||||
|  | ||||
| 	virtual void Tick(float DeltaTime) override | ||||
| 	{ | ||||
| 		K2_Tick(DeltaTime); | ||||
| 	} | ||||
|  | ||||
| 	virtual ETickableTickType GetTickableTickType() const override | ||||
| 	{ | ||||
| 		return ETickableTickType::Conditional; | ||||
| 	} | ||||
|  | ||||
| 	virtual bool IsTickable() const override | ||||
| 	{ | ||||
| 		return bIsTickable; | ||||
| 	} | ||||
|  | ||||
| 	virtual TStatId GetStatId() const override | ||||
| 	{ | ||||
| 		RETURN_QUICK_DECLARE_CYCLE_STAT(UCSEngineSubsystem, STATGROUP_Tickables); | ||||
| 	} | ||||
|  | ||||
| 	// End | ||||
|  | ||||
| public: | ||||
|  | ||||
| 	UPROPERTY(EditAnywhere, Category = "Managed Subsystems") | ||||
| 	bool bIsTickable; | ||||
|  | ||||
| 	UFUNCTION(BlueprintCallable, Category = "Managed Subsystems") | ||||
| 	void SetIsTickable(bool bInIsTickable) | ||||
| 	{ | ||||
| 		bIsTickable = bInIsTickable; | ||||
| 	} | ||||
|  | ||||
| protected: | ||||
|  | ||||
| 	UFUNCTION(BlueprintNativeEvent, meta = (ScriptName = "ShouldCreateSubsystem"), Category = "Managed Subsystems") | ||||
| 	bool K2_ShouldCreateSubsystem() const; | ||||
|  | ||||
| 	UFUNCTION(BlueprintImplementableEvent, meta = (ScriptName = "Initialize"), Category = "Managed Subsystems") | ||||
| 	void K2_Initialize(FSubsystemCollectionBaseRef Collection); | ||||
|  | ||||
| 	UFUNCTION(BlueprintImplementableEvent, meta = (ScriptName = "Deinitialize"), Category = "Managed Subsystems") | ||||
| 	void K2_Deinitialize(); | ||||
|  | ||||
| 	UFUNCTION(BlueprintImplementableEvent, meta = (ScriptName = "Tick"), Category = "Managed Subsystems") | ||||
| 	void K2_Tick(float DeltaTime); | ||||
|  | ||||
| }; | ||||
| @ -0,0 +1,6 @@ | ||||
| #include "CSGameInstanceSubsystem.h" | ||||
|  | ||||
| bool UCSGameInstanceSubsystem::K2_ShouldCreateSubsystem_Implementation() const | ||||
| { | ||||
| 	return true; | ||||
| } | ||||
| @ -0,0 +1,95 @@ | ||||
| // Fill out your copyright notice in the Description page of Project Settings. | ||||
|  | ||||
| #pragma once | ||||
|  | ||||
| #include "CoreMinimal.h" | ||||
| #include "SubsystemCollectionBaseRef.h" | ||||
| #include "Subsystems/GameInstanceSubsystem.h" | ||||
| #include "CSGameInstanceSubsystem.generated.h" | ||||
|  | ||||
| UCLASS(Blueprintable, BlueprintType, Abstract) | ||||
| class UCSGameInstanceSubsystem : public UGameInstanceSubsystem, public FTickableGameObject | ||||
| { | ||||
| 	GENERATED_BODY() | ||||
|  | ||||
| 	// USubsystem Begin | ||||
|  | ||||
| 	virtual void Initialize(FSubsystemCollectionBase& Collection) override | ||||
| 	{ | ||||
| 		Super::Initialize(Collection); | ||||
| 		K2_Initialize(Collection); | ||||
| 	} | ||||
|  | ||||
| 	virtual void Deinitialize() override | ||||
| 	{ | ||||
| 		Super::Deinitialize(); | ||||
| 		K2_Deinitialize(); | ||||
| 	} | ||||
|  | ||||
| 	virtual bool ShouldCreateSubsystem(UObject* Outer) const override | ||||
| 	{ | ||||
| 		if (!Super::ShouldCreateSubsystem(Outer)) | ||||
| 		{ | ||||
| 			return false; | ||||
| 		} | ||||
|  | ||||
| 		return K2_ShouldCreateSubsystem(); | ||||
| 	} | ||||
|  | ||||
| 	// End | ||||
|  | ||||
| 	// FTickableGameObject Begin | ||||
|  | ||||
| 	virtual void Tick(float DeltaTime) override | ||||
| 	{ | ||||
| 		K2_Tick(DeltaTime); | ||||
| 	} | ||||
|  | ||||
| 	virtual ETickableTickType GetTickableTickType() const override | ||||
| 	{ | ||||
| 		return ETickableTickType::Conditional; | ||||
| 	} | ||||
|  | ||||
| 	virtual bool IsTickable() const override | ||||
| 	{ | ||||
| 		return bIsTickable; | ||||
| 	} | ||||
|  | ||||
| 	virtual TStatId GetStatId() const override | ||||
| 	{ | ||||
| 		RETURN_QUICK_DECLARE_CYCLE_STAT(UCSGameInstanceSubsystem, STATGROUP_Tickables); | ||||
| 	} | ||||
|  | ||||
| 	// End | ||||
|  | ||||
| public: | ||||
|  | ||||
| 	UPROPERTY(EditAnywhere, Category = "Managed Subsystems") | ||||
| 	bool bIsTickable; | ||||
|  | ||||
| 	UFUNCTION(BlueprintCallable, Category = "Managed Subsystems") | ||||
| 	void SetIsTickable(bool bInIsTickable) | ||||
| 	{ | ||||
| 		bIsTickable = bInIsTickable; | ||||
| 	} | ||||
|  | ||||
| protected: | ||||
|  | ||||
| 	UFUNCTION(BlueprintCallable, meta = (ScriptName = "GetGameInstance"), DisplayName = "Get Game Instance", Category = "Managed Subsystems") | ||||
| 	UGameInstance* K2_GetGameInstance() const | ||||
| 	{ | ||||
| 		return GetGameInstance(); | ||||
| 	}; | ||||
|  | ||||
| 	UFUNCTION(BlueprintNativeEvent, meta = (ScriptName = "ShouldCreateSubsystem"), Category = "Managed Subsystems") | ||||
| 	bool K2_ShouldCreateSubsystem() const; | ||||
|  | ||||
| 	UFUNCTION(BlueprintImplementableEvent, meta = (ScriptName = "Initialize"), Category = "Managed Subsystems") | ||||
| 	void K2_Initialize(FSubsystemCollectionBaseRef Collection); | ||||
|  | ||||
| 	UFUNCTION(BlueprintImplementableEvent, meta = (ScriptName = "Deinitialize"), Category = "Managed Subsystems") | ||||
| 	void K2_Deinitialize(); | ||||
|  | ||||
| 	UFUNCTION(BlueprintImplementableEvent, meta = (ScriptName = "Tick"), Category = "Managed Subsystems") | ||||
| 	void K2_Tick(float DeltaTime); | ||||
| }; | ||||
| @ -0,0 +1,11 @@ | ||||
| #include "CSLocalPlayerSubsystem.h" | ||||
|  | ||||
| bool UCSLocalPlayerSubsystem::K2_ShouldCreateSubsystem_Implementation() const | ||||
| { | ||||
| 	return true; | ||||
| } | ||||
|  | ||||
| ULocalPlayer* UCSLocalPlayerSubsystem::K2_GetLocalPlayer() const | ||||
| { | ||||
| 	return GetLocalPlayer(); | ||||
| } | ||||
| @ -0,0 +1,103 @@ | ||||
| // Fill out your copyright notice in the Description page of Project Settings. | ||||
|  | ||||
| #pragma once | ||||
|  | ||||
| #include "CoreMinimal.h" | ||||
| #include "SubsystemCollectionBaseRef.h" | ||||
| #include "Subsystems/LocalPlayerSubsystem.h" | ||||
| #include "CSLocalPlayerSubsystem.generated.h" | ||||
|  | ||||
| UCLASS(Blueprintable, BlueprintType, Abstract) | ||||
| class UCSLocalPlayerSubsystem : public ULocalPlayerSubsystem, public FTickableGameObject | ||||
| { | ||||
| 	GENERATED_BODY() | ||||
|  | ||||
| 	// USubsystem Begin | ||||
|  | ||||
| 	virtual void Initialize(FSubsystemCollectionBase& Collection) override | ||||
| 	{ | ||||
| 		Super::Initialize(Collection); | ||||
| 		K2_Initialize(Collection); | ||||
| 	} | ||||
|  | ||||
| 	virtual void Deinitialize() override | ||||
| 	{ | ||||
| 		Super::Deinitialize(); | ||||
| 		K2_Deinitialize(); | ||||
| 	} | ||||
|  | ||||
| 	virtual bool ShouldCreateSubsystem(UObject* Outer) const override | ||||
| 	{ | ||||
| 		if (!Super::ShouldCreateSubsystem(Outer)) | ||||
| 		{ | ||||
| 			return false; | ||||
| 		} | ||||
|  | ||||
| 		return K2_ShouldCreateSubsystem(); | ||||
| 	} | ||||
|  | ||||
| 	// End | ||||
|  | ||||
| 	// ULocalPlayerSubsystem | ||||
| 	virtual void PlayerControllerChanged(APlayerController* NewPlayerController) override | ||||
| 	{ | ||||
| 		Super::PlayerControllerChanged(NewPlayerController); | ||||
| 		K2_PlayerControllerChanged(NewPlayerController); | ||||
| 	} | ||||
| 	// End | ||||
|  | ||||
| 	// FTickableGameObject Begin | ||||
|  | ||||
| 	virtual void Tick(float DeltaTime) override | ||||
| 	{ | ||||
| 		K2_Tick(DeltaTime); | ||||
| 	} | ||||
|  | ||||
| 	virtual ETickableTickType GetTickableTickType() const override | ||||
| 	{ | ||||
| 		return ETickableTickType::Conditional; | ||||
| 	} | ||||
|  | ||||
| 	virtual bool IsTickable() const override | ||||
| 	{ | ||||
| 		return bIsTickable; | ||||
| 	} | ||||
|  | ||||
| 	virtual TStatId GetStatId() const override | ||||
| 	{ | ||||
| 		RETURN_QUICK_DECLARE_CYCLE_STAT(UCSLocalPlayerSubsystem, STATGROUP_Tickables); | ||||
| 	} | ||||
|  | ||||
| 	// End | ||||
|  | ||||
| public: | ||||
|  | ||||
| 	UPROPERTY(EditAnywhere, Category = "Managed Subsystems") | ||||
| 	bool bIsTickable; | ||||
|  | ||||
| 	UFUNCTION(BlueprintCallable, Category = "Managed Subsystems") | ||||
| 	void SetIsTickable(bool bInIsTickable) | ||||
| 	{ | ||||
| 		bIsTickable = bInIsTickable; | ||||
| 	} | ||||
|  | ||||
| protected: | ||||
|  | ||||
| 	UFUNCTION(BlueprintImplementableEvent, meta = (ScriptName = "PlayerControllerChanged"), Category = "Managed Subsystems") | ||||
| 	bool K2_PlayerControllerChanged(APlayerController* NewPlayerController) const; | ||||
|  | ||||
| 	UFUNCTION(BlueprintNativeEvent, meta = (ScriptName = "ShouldCreateSubsystem"), Category = "Managed Subsystems") | ||||
| 	bool K2_ShouldCreateSubsystem() const; | ||||
|  | ||||
| 	UFUNCTION(BlueprintImplementableEvent, meta = (ScriptName = "Initialize"), Category = "Managed Subsystems") | ||||
| 	void K2_Initialize(FSubsystemCollectionBaseRef Collection); | ||||
|  | ||||
| 	UFUNCTION(BlueprintImplementableEvent, meta = (ScriptName = "Deinitialize"), Category = "Managed Subsystems") | ||||
| 	void K2_Deinitialize(); | ||||
|  | ||||
| 	UFUNCTION(BlueprintImplementableEvent, meta = (ScriptName = "Tick"), Category = "Managed Subsystems") | ||||
| 	void K2_Tick(float DeltaTime); | ||||
|  | ||||
| 	UFUNCTION(meta = (ScriptMethod)) | ||||
| 	ULocalPlayer* K2_GetLocalPlayer() const; | ||||
| }; | ||||
| @ -0,0 +1,33 @@ | ||||
| #include "CSWorldSubsystem.h" | ||||
| #include "SubsystemUtils.h" | ||||
|  | ||||
| bool UCSWorldSubsystem::K2_ShouldCreateSubsystem_Implementation() const | ||||
| { | ||||
| 	return true; | ||||
| } | ||||
|  | ||||
| void UCSWorldSubsystem::BeginDestroy() | ||||
| { | ||||
| #if UE_VERSION >= 5 | ||||
| #if WITH_EDITOR | ||||
| 	// Edge case in reinstancing world subsystems. Can't call Super as it leads to an ensure, but we do the same thing. | ||||
| 	if (CSSubsystemUtils::IsReinstancingClass(GetClass())) | ||||
| 	{ | ||||
| 		SetTickableTickType(ETickableTickType::Never); | ||||
| 		UObject::BeginDestroy(); | ||||
| 		return; | ||||
| 	} | ||||
| #endif | ||||
| #endif | ||||
| 	Super::BeginDestroy(); | ||||
| } | ||||
|  | ||||
| bool UCSWorldSubsystem::GetIsInitialized() const | ||||
| { | ||||
| 	return IsInitialized(); | ||||
| } | ||||
|  | ||||
| bool UCSWorldSubsystem::K2_DoesSupportWorldType_Implementation(const ECSWorldType WorldType) const | ||||
| { | ||||
|     return true; | ||||
| } | ||||
| @ -0,0 +1,167 @@ | ||||
| #pragma once | ||||
|  | ||||
| #include "CoreMinimal.h" | ||||
| #if ENGINE_MINOR_VERSION >= 5 | ||||
| #include "Streaming/StreamingWorldSubsystemInterface.h" | ||||
| #endif | ||||
| #include "SubsystemCollectionBaseRef.h" | ||||
| #include "Subsystems/WorldSubsystem.h" | ||||
| #include "CSWorldSubsystem.generated.h" | ||||
|  | ||||
| UENUM(BlueprintType) | ||||
| enum class ECSWorldType : uint8 | ||||
| { | ||||
|     /** An untyped world, in most cases this will be the vestigial worlds of streamed in sub-levels */ | ||||
|     None = EWorldType::None, | ||||
|  | ||||
|     /** The game world */ | ||||
|     Game = EWorldType::Game, | ||||
|  | ||||
|     /** A world being edited in the editor */ | ||||
|     Editor = EWorldType::Editor, | ||||
|  | ||||
|     /** A Play In Editor world */ | ||||
|     PIE = EWorldType::PIE, | ||||
|  | ||||
|     /** A preview world for an editor tool */ | ||||
|     EditorPreview = EWorldType::EditorPreview, | ||||
|  | ||||
|     /** A preview world for a game */ | ||||
|     GamePreview = EWorldType::GamePreview, | ||||
|  | ||||
|     /** A minimal RPC world for a game */ | ||||
|     GameRPC = EWorldType::GameRPC, | ||||
|  | ||||
|     /** An editor world that was loaded but not currently being edited in the level editor */ | ||||
|     Inactive = EWorldType::Inactive, | ||||
| }; | ||||
|  | ||||
|  | ||||
| UCLASS(Blueprintable, BlueprintType, Abstract) | ||||
| class UCSWorldSubsystem : public UTickableWorldSubsystem | ||||
| #if ENGINE_MINOR_VERSION >= 5 | ||||
| 	, public IStreamingWorldSubsystemInterface | ||||
| #endif | ||||
| { | ||||
| 	GENERATED_BODY() | ||||
|  | ||||
| 	// USubsystem Begin | ||||
|  | ||||
| 	virtual void Initialize(FSubsystemCollectionBase& Collection) override | ||||
| 	{ | ||||
| 		Super::Initialize(Collection); | ||||
| 		K2_Initialize(Collection); | ||||
| 	} | ||||
|  | ||||
| 	virtual void Deinitialize() override | ||||
| 	{ | ||||
| 		if (IsInitialized()) | ||||
| 		{ | ||||
| 			Super::Deinitialize(); | ||||
| 			K2_Deinitialize(); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	virtual bool ShouldCreateSubsystem(UObject* Outer) const override | ||||
| 	{ | ||||
| 		if (!Super::ShouldCreateSubsystem(Outer)) | ||||
| 		{ | ||||
| 			return false; | ||||
| 		} | ||||
|  | ||||
| 		return K2_ShouldCreateSubsystem(); | ||||
| 	} | ||||
|  | ||||
|     virtual bool DoesSupportWorldType(const EWorldType::Type WorldType) const override | ||||
| 	{ | ||||
| 	    if (!Super::DoesSupportWorldType(WorldType)) | ||||
| 	    { | ||||
| 	        return false; | ||||
| 	    } | ||||
|  | ||||
| 	    return K2_DoesSupportWorldType(static_cast<ECSWorldType>(WorldType)); | ||||
| 	} | ||||
|  | ||||
| 	virtual void BeginDestroy() override; | ||||
|  | ||||
| 	// End | ||||
|  | ||||
| 	// UWorldSubsystem begin | ||||
| 	virtual void PostInitialize() override | ||||
| 	{ | ||||
| 		Super::PostInitialize(); | ||||
| 		K2_PostInitialize(); | ||||
| 	} | ||||
|  | ||||
| 	virtual void OnWorldBeginPlay(UWorld& InWorld) override | ||||
| 	{ | ||||
| 		Super::OnWorldBeginPlay(InWorld); | ||||
| 		K2_OnWorldBeginPlay(); | ||||
| 	} | ||||
|  | ||||
| 	virtual void OnWorldComponentsUpdated(UWorld& World) override | ||||
| 	{ | ||||
| 		Super::OnWorldComponentsUpdated(World); | ||||
| 		K2_OnWorldComponentsUpdated(); | ||||
| 	} | ||||
|  | ||||
| #if ENGINE_MINOR_VERSION >= 5 | ||||
| 	virtual void OnUpdateStreamingState() override | ||||
| 	{ | ||||
|         K2_UpdateStreamingState(); | ||||
| 	} | ||||
| #else | ||||
| 	virtual void UpdateStreamingState() override | ||||
| 	{ | ||||
| 		Super::UpdateStreamingState(); | ||||
| 		K2_UpdateStreamingState(); | ||||
| 	} | ||||
| #endif | ||||
|  | ||||
| 	virtual TStatId GetStatId() const override | ||||
| 	{ | ||||
| 		RETURN_QUICK_DECLARE_CYCLE_STAT(UCSWorldSubsystem, STATGROUP_Tickables); | ||||
| 	} | ||||
|  | ||||
| 	virtual void Tick(float DeltaTime) override | ||||
| 	{ | ||||
| 		Super::Tick(DeltaTime); | ||||
| 		K2_Tick(DeltaTime); | ||||
| 	} | ||||
|  | ||||
| 	// End | ||||
|  | ||||
| 	/** Returns true if Initialize has been called but Deinitialize has not */ | ||||
| 	UFUNCTION(meta = (ScriptMethod)) | ||||
| 	bool GetIsInitialized() const; | ||||
|  | ||||
| protected: | ||||
|  | ||||
| 	UFUNCTION(BlueprintImplementableEvent, meta = (ScriptName = "PostInitialize"), Category = "Managed Subsystems") | ||||
| 	void K2_PostInitialize(); | ||||
|  | ||||
| 	UFUNCTION(BlueprintImplementableEvent, meta = (ScriptName = "Tick"), Category = "Managed Subsystems") | ||||
| 	void K2_Tick(float DeltaTime); | ||||
|  | ||||
| 	UFUNCTION(BlueprintImplementableEvent, meta = (ScriptName = "OnWorldBeginPlay"), Category = "Managed Subsystems") | ||||
| 	void K2_OnWorldBeginPlay(); | ||||
|  | ||||
| 	UFUNCTION(BlueprintImplementableEvent, meta = (ScriptName = "OnWorldComponentsUpdated"), Category = "Managed Subsystems") | ||||
| 	void K2_OnWorldComponentsUpdated(); | ||||
|  | ||||
| 	UFUNCTION(BlueprintImplementableEvent, meta = (ScriptName = "UpdateStreamingState"), Category = "Managed Subsystems") | ||||
| 	void K2_UpdateStreamingState(); | ||||
|  | ||||
| 	UFUNCTION(BlueprintNativeEvent, meta = (ScriptName = "ShouldCreateSubsystem"), Category = "Managed Subsystems") | ||||
| 	bool K2_ShouldCreateSubsystem() const; | ||||
|  | ||||
|     UFUNCTION(BlueprintNativeEvent, meta = (ScriptName = "DoesSupportWorldType"), Category = "Managed Subsystems") | ||||
|     bool K2_DoesSupportWorldType(const ECSWorldType WorldType) const; | ||||
|  | ||||
| 	UFUNCTION(BlueprintImplementableEvent, meta = (ScriptName = "Initialize"), Category = "Managed Subsystems") | ||||
| 	void K2_Initialize(FSubsystemCollectionBaseRef Collection); | ||||
|  | ||||
| 	UFUNCTION(BlueprintImplementableEvent, meta = (ScriptName = "Deinitialize"), Category = "Managed Subsystems") | ||||
| 	void K2_Deinitialize(); | ||||
|  | ||||
| }; | ||||
| @ -0,0 +1,18 @@ | ||||
| // Fill out your copyright notice in the Description page of Project Settings. | ||||
|  | ||||
| #pragma once | ||||
|  | ||||
| #include "CoreMinimal.h" | ||||
| #include "SubsystemCollectionBaseRef.generated.h" | ||||
|  | ||||
| USTRUCT(BlueprintType) | ||||
| struct FSubsystemCollectionBaseRef | ||||
| { | ||||
|     GENERATED_BODY() | ||||
|  | ||||
|     FSubsystemCollectionBaseRef() = default; | ||||
|     explicit(false) FSubsystemCollectionBaseRef(FSubsystemCollectionBase &Base) : Base(&Base) {} | ||||
|  | ||||
| private: | ||||
|     FSubsystemCollectionBase *Base; | ||||
| }; | ||||
| @ -0,0 +1,7 @@ | ||||
| #include "SubsystemUtils.h" | ||||
|  | ||||
| bool CSSubsystemUtils::IsReinstancingClass(const UClass* Class) | ||||
| { | ||||
| 	FString ClassName = Class->GetName(); | ||||
| 	return ClassName.StartsWith(TEXT("REINST_")); | ||||
| } | ||||
| @ -0,0 +1,6 @@ | ||||
| #pragma once | ||||
|  | ||||
| namespace CSSubsystemUtils | ||||
| { | ||||
| 	UNREALSHARPCORE_API bool IsReinstancingClass(const UClass* Class); | ||||
| }; | ||||
		Reference in New Issue
	
	Block a user