chore: sync generated files after adding unreal-engine-cpp-pro skill
This commit is contained in:
43
skills/unreal-engine-cpp-pro/examples/ExampleActor.cpp
Normal file
43
skills/unreal-engine-cpp-pro/examples/ExampleActor.cpp
Normal file
@@ -0,0 +1,43 @@
|
||||
#include "ExampleActor.h"
|
||||
#include "Components/BoxComponent.h"
|
||||
#include "Kismet/GameplayStatics.h"
|
||||
|
||||
// Define a static log category for this specific file/module
|
||||
DEFINE_LOG_CATEGORY_STATIC(LogExampleActor, Log, All);
|
||||
|
||||
AExampleActor::AExampleActor()
|
||||
{
|
||||
// Default to strict settings
|
||||
PrimaryActorTick.bCanEverTick = false;
|
||||
PrimaryActorTick.bStartWithTickEnabled = false;
|
||||
|
||||
RootCollision = CreateDefaultSubobject<UBoxComponent>(TEXT("RootCollision"));
|
||||
RootComponent = RootCollision;
|
||||
|
||||
bIsActive = true;
|
||||
}
|
||||
|
||||
void AExampleActor::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
|
||||
// Cache references here, not in Tick
|
||||
CachedPC = UGameplayStatics::GetPlayerController(this, 0);
|
||||
|
||||
if (bIsActive)
|
||||
{
|
||||
UE_LOG(LogExampleActor, Log, TEXT("ExampleActor %s started!"), *GetName());
|
||||
}
|
||||
}
|
||||
|
||||
void AExampleActor::EndPlay(const EEndPlayReason::Type EndPlayReason)
|
||||
{
|
||||
// Clean up any strict delegates or handles here
|
||||
Super::EndPlay(EndPlayReason);
|
||||
}
|
||||
|
||||
void AExampleActor::Tick(float DeltaTime)
|
||||
{
|
||||
Super::Tick(DeltaTime);
|
||||
// Ticking is disabled by default in constructor, so this won't run unless enabled explicitly.
|
||||
}
|
||||
57
skills/unreal-engine-cpp-pro/examples/ExampleActor.h
Normal file
57
skills/unreal-engine-cpp-pro/examples/ExampleActor.h
Normal file
@@ -0,0 +1,57 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "GameFramework/Actor.h"
|
||||
#include "ExampleActor.generated.h"
|
||||
|
||||
// Forward overrides to reduce compile times
|
||||
class UBoxComponent;
|
||||
|
||||
/**
|
||||
* AExampleActor
|
||||
*
|
||||
* Demonstrates:
|
||||
* 1. Correct class prefix (A)
|
||||
* 2. UPROPERTY usage
|
||||
* 3. Soft references for assets
|
||||
*/
|
||||
UCLASS()
|
||||
class MYGAME_API AExampleActor : public AActor
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
// Sets default values for this actor's properties
|
||||
AExampleActor();
|
||||
|
||||
protected:
|
||||
// Called when the game starts or when spawned
|
||||
virtual void BeginPlay() override;
|
||||
|
||||
// Called when the game ends
|
||||
virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
|
||||
|
||||
public:
|
||||
// Called every frame
|
||||
virtual void Tick(float DeltaTime) override;
|
||||
|
||||
/** Component exposed to Blueprint, but immutable logic in C++ */
|
||||
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Components")
|
||||
UBoxComponent* RootCollision;
|
||||
|
||||
/**
|
||||
* Soft reference to an actor class to lazy load.
|
||||
* Prevents hard reference chains.
|
||||
*/
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Config")
|
||||
TSoftClassPtr<AActor> ActorTypeToSpawn;
|
||||
|
||||
/** Proper boolean naming convention 'b' */
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "State")
|
||||
uint8 bIsActive:1;
|
||||
|
||||
private:
|
||||
/** Cached reference, not exposed to Blueprints */
|
||||
UPROPERTY(Transient)
|
||||
APlayerController* CachedPC;
|
||||
};
|
||||
Reference in New Issue
Block a user