diff --git a/modules/ROOT/pages/Development/Satisfactory/AbstractInstance.adoc b/modules/ROOT/pages/Development/Satisfactory/AbstractInstance.adoc index f960417b..c201fafc 100644 --- a/modules/ROOT/pages/Development/Satisfactory/AbstractInstance.adoc +++ b/modules/ROOT/pages/Development/Satisfactory/AbstractInstance.adoc @@ -46,9 +46,15 @@ You may also find the following properties useful: [id="Examples"] == Examples for Custom Implementations -`TArray< struct FInstanceHandle* > mInstanceHandles` All instance handlers (provided from `AFGBuildable` If you create a new actor, you should define something like that). +You may find the below examples useful +if you're planning to implement Abstract Instances on things that don't inherit from `AFGBuildable`. -=== Resolve Hit on Abstract Instances +=== Storing Instance Handles + +Custom implementations should define a field to hold instance handles. +Consider `TArray< struct FInstanceHandle* > mInstanceHandles` used by `AFGBuildable`. + +=== Resolve Hits on Abstract Instances [NOTE] ==== @@ -61,13 +67,13 @@ To resolve the hit, we have two options: - Overlap Result `bool ResolveOverlap( const FOverlapResult& Result, FInstanceHandle& OutHandle )` ```cpp -ASMLActor::ResolveHitResult(const FHitResult& Hit) { +AMyModActor::ResolveHitResult(const FHitResult& Hit) { AAbstractInstanceManager* Manager = AAbstractInstanceManager::Get(GetWorld()); fgcheck(Manager); FInstanceHandle OutHandle; if(Manager->ResolveHit(Hit, OutHandle)) { - // We hit a abstract instance to we can get informations like the owner from that + // We hit a abstract instance, so we can get information, like the owner, from that handle OutHandle.GetOwner() // AActor* who owns the Instance } // We don't hit a abstract instance so we can continue with the Hit @@ -79,7 +85,7 @@ ASMLActor::ResolveHitResult(const FHitResult& Hit) { ```cpp static void SetInstanceFromDataStatic( AActor* OwnerActor, const FTransform& ActorTransform, const FInstanceData& InstanceData, FInstanceHandle* &OutHandle, bool bInitializeHidden = false ); -ASMLActor::CreateInstanceFromMesh(UStaticMesh* Mesh) { +AMyModActor::CreateInstanceFromMesh(UStaticMesh* Mesh) { // Prepare the InstanceData with a given Mesh at the relative Transform 0. FInstanceData InstanceData; InstanceData.StaticMesh = Mesh; @@ -95,13 +101,13 @@ ASMLActor::CreateInstanceFromMesh(UStaticMesh* Mesh) { } ``` -=== Destory Abstract Instances at runtime +=== Destory Abstract Instances at Runtime ```cpp static void RemoveInstances( UObject* WorldContext, TArray& Handles, bool bEmptyHandleArray = true ); -ASMLActor::ClearInstances(UStaticMesh* Mesh) { +AMyModActor::ClearInstances(UStaticMesh* Mesh) { // Will remove/destroy all instances and empty mInstanceHandles. AAbstractInstanceManager::RemoveInstances( GetWorld( ), mInstanceHandles ); } -``` \ No newline at end of file +```