Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma once
- #include "CoreMinimal.h"
- #include "Components/InstancedStaticMeshComponent.h"
- #include "BuildingISMComponent.generated.h"
- UCLASS(ClassGroup = (Rendering, Common), hidecategories = (Object, Activation, "Components|Activation"),
- ShowCategories = (Mobility), editinlinenew, meta = (BlueprintSpawnableComponent))
- class LOFILIFESIM_API UBuildingISMComponent : public UInstancedStaticMeshComponent
- {
- GENERATED_BODY()
- public:
- DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnInstanceAdded, int32, InstanceIndex, FTransform, InstanceTransform);
- DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnInstanceRemoved, int32, InstanceIndex, FTransform, LastTransform);
- DECLARE_DYNAMIC_MULTICAST_DELEGATE_FourParams(FOnInstanceMoved, int32, OldIndex, FTransform, OldTransform, int32, NewIndex, FTransform, NewTransform);
- UBuildingISMComponent(const FObjectInitializer& ObjectInitializer = FObjectInitializer::Get());
- UPROPERTY(BlueprintAssignable, Category = "Instance Events")
- FOnInstanceAdded OnInstanceAdded;
- UPROPERTY(BlueprintAssignable, Category = "Instance Events")
- FOnInstanceRemoved OnInstanceRemoved;
- UPROPERTY(BlueprintAssignable, Category = "Instance Events")
- FOnInstanceMoved OnInstanceMoved;
- protected:
- virtual void BeginPlay() override;
- virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
- public:
- void HandleInstanceIndexUpdated(UInstancedStaticMeshComponent* InComponent, TArrayView<const FInstancedStaticMeshDelegates::FInstanceIndexUpdateData> InIndexUpdates);
- bool IsValidInstanceIndex(int32 Index) const;
- protected:
- // Internal delegate binding
- void BindToInternalDelegates();
- void UnbindFromInternalDelegates();
- private:
- // Track if we've bound to internal delegates
- bool bDelegatesBound;
- // Cache transforms to provide data for removal events
- UPROPERTY()
- TMap<int32, FTransform> CachedInstanceTransforms;
- };
Advertisement
Add Comment
Please, Sign In to add comment