第一次提交
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "UObject/Interface.h"
|
||||
#include "GIS_EquipmentActorInterface.generated.h"
|
||||
|
||||
class UGIS_EquipmentInstance;
|
||||
|
||||
// This class does not need to be modified.
|
||||
UINTERFACE()
|
||||
class UGIS_EquipmentActorInterface : public UInterface
|
||||
{
|
||||
GENERATED_BODY()
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class GENERICINVENTORYSYSTEM_API IGIS_EquipmentActorInterface
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
UFUNCTION(BlueprintNativeEvent, Category="GIS|EquipmentActor", meta=(BlueprintProtected))
|
||||
void ReceiveSourceEquipment(UGIS_EquipmentInstance* NewEquipmentInstance, int32 Idx);
|
||||
virtual void ReceiveSourceEquipment_Implementation(UGIS_EquipmentInstance* NewEquipmentInstance, int32 Idx);
|
||||
|
||||
UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category="GIS|EquipmentActor")
|
||||
UGIS_EquipmentInstance* GetSourceEquipment() const;
|
||||
virtual UGIS_EquipmentInstance* GetSourceEquipment_Implementation() const;
|
||||
|
||||
UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category = "GIS|EquipmentActor")
|
||||
UPrimitiveComponent* GetPrimitiveComponent() const;
|
||||
virtual UPrimitiveComponent* GetPrimitiveComponent_Implementation() const;
|
||||
|
||||
UFUNCTION(BlueprintNativeEvent, Category="GIS|EquipmentActor", meta=(BlueprintProtected))
|
||||
void ReceiveEquipmentBeginPlay();
|
||||
virtual void ReceiveEquipmentBeginPlay_Implementation();
|
||||
|
||||
UFUNCTION(BlueprintNativeEvent, Category="GIS|EquipmentActor", meta=(BlueprintProtected))
|
||||
void ReceiveEquipmentEndPlay();
|
||||
virtual void ReceiveEquipmentEndPlay_Implementation();
|
||||
};
|
||||
@@ -0,0 +1,247 @@
|
||||
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Engine/TimerHandle.h"
|
||||
#include "GIS_EquipmentInterface.h"
|
||||
#include "GIS_EquipmentStructLibrary.h"
|
||||
#include "GIS_EquipmentInstance.generated.h"
|
||||
|
||||
class UGIS_EquipmentSystemComponent;
|
||||
class AActor;
|
||||
class APawn;
|
||||
struct FFrame;
|
||||
|
||||
/**
|
||||
* Delegate triggered when the active state of the equipment instance changes.
|
||||
* 当装备实例的激活状态改变时触发的委托。
|
||||
* @param bNewState The new active state of the equipment. 装备的新激活状态。
|
||||
*/
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FGIS_ActiveStateChangedSignature, bool, bNewState);
|
||||
|
||||
/**
|
||||
* An equipment instance is a UObject tasked with managing the internal logic and runtime states of equipment.
|
||||
* 装备实例是一个UObject,负责管理装备的内部逻辑和运行时状态。
|
||||
* @attention This is the default implementation of EquipmentInterface. You can use other types of classes as equipment.
|
||||
* @注意 这是EquipmentInterface的默认实现,你可以使用其他类作为装备实例。
|
||||
*/
|
||||
UCLASS(BlueprintType, Blueprintable)
|
||||
class GENERICINVENTORYSYSTEM_API UGIS_EquipmentInstance : public UObject, public IGIS_EquipmentInterface
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
/**
|
||||
* Constructor for the equipment instance.
|
||||
* 装备实例的构造函数。
|
||||
* @param ObjectInitializer The object initializer. 对象初始化器。
|
||||
*/
|
||||
UGIS_EquipmentInstance(const FObjectInitializer& ObjectInitializer = FObjectInitializer::Get());
|
||||
|
||||
//~UObject interface
|
||||
/**
|
||||
* Checks if the equipment instance supports networking.
|
||||
* 检查装备实例是否支持网络。
|
||||
* @return True if networking is supported, false otherwise. 如果支持网络则返回true,否则返回false。
|
||||
*/
|
||||
virtual bool IsSupportedForNetworking() const override;
|
||||
|
||||
/**
|
||||
* Gets the world this equipment instance belongs to.
|
||||
* 获取装备实例所属的世界。
|
||||
* @return The world, or nullptr if not set. 世界,如果未设置则返回nullptr。
|
||||
*/
|
||||
virtual UWorld* GetWorld() const override final;
|
||||
|
||||
/**
|
||||
* Gets the properties that should be replicated for this object.
|
||||
* 获取需要为此对象复制的属性。
|
||||
* @param OutLifetimeProps Array to store the replicated properties. 存储复制属性的数组。
|
||||
*/
|
||||
virtual void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override;
|
||||
//~End of UObject interface
|
||||
|
||||
// Begin IGIS_EquipmentInterface interface
|
||||
virtual APawn* GetOwningPawn_Implementation() const override;
|
||||
virtual UGIS_ItemInstance* GetSourceItem_Implementation() const override;
|
||||
virtual bool IsEquipmentActive_Implementation() const override;
|
||||
//EndIGIS_EquipmentInterface interface
|
||||
|
||||
/**
|
||||
* Gets the owning pawn cast to a specific type.
|
||||
* 获取转换为特定类型的所属Pawn。
|
||||
* @param PawnType The desired pawn class. 期望的Pawn类。
|
||||
* @return The owning pawn cast to the specified type, or nullptr if not valid. 转换为指定类型的所属Pawn,如果无效则返回nullptr。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category="GIS|EquipmentInstance", meta=(DeterminesOutputType=PawnType))
|
||||
APawn* GetTypedOwningPawn(TSubclassOf<APawn> PawnType) const;
|
||||
|
||||
/**
|
||||
* Determines if the equipment can be activated. Override in Blueprint for custom logic.
|
||||
* 判断装备是否可以激活,可在蓝图中重写以实现自定义逻辑。
|
||||
* @return True if the equipment can be activated, false otherwise. 如果装备可以激活则返回true,否则返回false。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, BlueprintNativeEvent, Category="GIS|EquipmentInstance")
|
||||
bool CanActivate() const;
|
||||
|
||||
/**
|
||||
* Gets all actors spawned by this equipment instance.
|
||||
* 获取由此装备实例生成的所有Actor。
|
||||
* @return Array of spawned actors. 生成的Actor数组。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category="GIS|EquipmentInstance")
|
||||
TArray<AActor*> GetEquipmentActors() const { return EquipmentActors; }
|
||||
|
||||
/**
|
||||
* Get the index of specified equipment actor managed by this equipment instance.获取由此装备实例所管理的装备Actor的下标。
|
||||
* @param InEquipmentActor The equipment actor of this equipment instance. 此装备实例的其中一个装备Actor。
|
||||
* @return -1 if passed-in actor not created by this instance. 如果传入Actor不是该EquipmentInstance创建的。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category="GIS|EquipmentInstance")
|
||||
int32 GetIndexOfEquipmentActor(const AActor* InEquipmentActor) const;
|
||||
|
||||
/**
|
||||
* Gets the first spawned actor matching the desired class (including subclasses).
|
||||
* 获取第一个匹配指定类型(包括子类)的由装备实例生成的Actor。
|
||||
* @param DesiredClass The desired actor class. 期望的Actor类。
|
||||
* @return The matching actor, or nullptr if not found. 匹配的Actor,如果未找到则返回nullptr。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category="GIS|EquipmentInstance", meta=(DeterminesOutputType="DesiredClass", DynamicOutputParam="ReturnValue"))
|
||||
AActor* GetTypedEquipmentActor(TSubclassOf<AActor> DesiredClass) const;
|
||||
|
||||
/**
|
||||
* Event triggered when the active state of the equipment changes.
|
||||
* 装备激活状态改变时触发的事件。
|
||||
*/
|
||||
UPROPERTY(BlueprintAssignable, Category="EquipmentInstance")
|
||||
FGIS_ActiveStateChangedSignature OnActiveStateChangedEvent;
|
||||
|
||||
protected:
|
||||
// Begin IGIS_EquipmentInterface interface
|
||||
virtual void ReceiveOwningPawn_Implementation(APawn* NewPawn) override;
|
||||
virtual void ReceiveSourceItem_Implementation(UGIS_ItemInstance* NewItem) override;
|
||||
virtual void OnEquipmentBeginPlay_Implementation() override;
|
||||
virtual void OnEquipmentTick_Implementation(float DeltaSeconds) override;
|
||||
virtual void OnEquipmentEndPlay_Implementation() override;
|
||||
virtual void OnActiveStateChanged_Implementation(bool NewActiveState) override;
|
||||
//EndIGIS_EquipmentInterface interface
|
||||
|
||||
protected:
|
||||
#if UE_WITH_IRIS
|
||||
/**
|
||||
* Registers replication fragments for networking (Iris-specific).
|
||||
* 为网络注册复制片段(特定于Iris)。
|
||||
* @param Context The fragment registration context. 片段注册上下文。
|
||||
* @param RegistrationFlags The registration flags. 注册标志。
|
||||
*/
|
||||
virtual void RegisterReplicationFragments(UE::Net::FFragmentRegistrationContext& Context, UE::Net::EFragmentRegistrationFlags RegistrationFlags) override;
|
||||
#endif // UE_WITH_IRIS
|
||||
|
||||
/**
|
||||
* Gets the scene component to which spawned actors will attach.
|
||||
* 获取生成Actor将附加到的场景组件。
|
||||
* @param Pawn The pawn owning this equipment instance. 拥有此装备实例的Pawn。
|
||||
* @return The scene component to attach to, or nullptr if not applicable. 要附加到的场景组件,如果不适用则返回nullptr。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintNativeEvent, BlueprintPure, Category="GIS|EquipmentInstance")
|
||||
USceneComponent* GetAttachParentForSpawnedActors(APawn* Pawn) const;
|
||||
|
||||
#pragma region Equipment Actors
|
||||
|
||||
/**
|
||||
* Spawns and sets up actors associated with this equipment instance.
|
||||
* 生成并设置与此装备实例关联的Actor。
|
||||
* @param ActorsToSpawn The actors to spawn. 要生成的Actor。
|
||||
*/
|
||||
virtual void SpawnAndSetupEquipmentActors(const TArray<FGIS_EquipmentActorToSpawn>& ActorsToSpawn);
|
||||
|
||||
/**
|
||||
* Destroys all actors associated with this equipment instance.
|
||||
* 销毁与此装备实例关联的所有Actor。
|
||||
*/
|
||||
virtual void DestroyEquipmentActors();
|
||||
|
||||
/**
|
||||
* Called before an actor is spawned to allow additional setup.
|
||||
* 在Actor生成前调用以允许额外设置。
|
||||
* @param SpawningActor The actor about to be spawned. 即将生成的Actor。
|
||||
*/
|
||||
UFUNCTION(BlueprintNativeEvent, Category="GIS|EquipmentInstance")
|
||||
void BeforeSpawningActor(AActor* SpawningActor) const;
|
||||
|
||||
/**
|
||||
* Sets up actors after they have been spawned.
|
||||
* 在Actor生成后进行设置。
|
||||
* @param InActors The spawned actors to configure. 已生成的Actor,需进行配置。
|
||||
*/
|
||||
UFUNCTION(BlueprintNativeEvent, Category="GIS|EquipmentInstance")
|
||||
void SetupEquipmentActors(const TArray<AActor*>& InActors);
|
||||
|
||||
/**
|
||||
* Implementation of SetupEquipmentActors.
|
||||
* SetupEquipmentActors 的实现。
|
||||
* @param InActors The spawned actors to configure. 已生成的Actor,需进行配置。
|
||||
*/
|
||||
virtual void SetupEquipmentActors_Implementation(const TArray<AActor*>& InActors);
|
||||
|
||||
/**
|
||||
* Called when the equipment actors are replicated.
|
||||
* 装备Actor复制时调用。
|
||||
*/
|
||||
UFUNCTION()
|
||||
void OnRep_EquipmentActors();
|
||||
|
||||
/**
|
||||
* Checks if the specified number of equipment actors is valid.
|
||||
* 检查指定数量的装备Actor是否有效。
|
||||
* @param Num The number of actors to check. 要检查的Actor数量。
|
||||
* @return True if the number of actors is valid, false otherwise. 如果Actor数量有效则返回true,否则返回false。
|
||||
*/
|
||||
bool IsEquipmentActorsValid(int32 Num) const;
|
||||
|
||||
/**
|
||||
* Propagates initial state to all equipment actors.
|
||||
* 将初始状态传播到所有装备Actor。
|
||||
* @param InActors The actors to set up. 要设置的Actor。
|
||||
*/
|
||||
virtual void SetupInitialStateForEquipmentActors(const TArray<AActor*>& InActors);
|
||||
|
||||
/**
|
||||
* Propagates active state to all equipment actors.
|
||||
* 将激活状态传播到所有装备Actor。
|
||||
* @param InActors The actors to set up. 要设置的Actor。
|
||||
*/
|
||||
virtual void SetupActiveStateForEquipmentActors(const TArray<AActor*>& InActors) const;
|
||||
|
||||
#pragma endregion
|
||||
|
||||
protected:
|
||||
/**
|
||||
* The pawn that owns this equipment instance.
|
||||
* 拥有此装备实例的Pawn。
|
||||
*/
|
||||
UPROPERTY(VisibleInstanceOnly, BlueprintReadOnly, Category="EquipmentInstance")
|
||||
TObjectPtr<APawn> OwningPawn;
|
||||
|
||||
/**
|
||||
* The source item associated with this equipment instance.
|
||||
* 与此装备实例关联的源道具。
|
||||
*/
|
||||
UPROPERTY(VisibleInstanceOnly, BlueprintReadOnly, Category="EquipmentInstance")
|
||||
TObjectPtr<UGIS_ItemInstance> SourceItem;
|
||||
|
||||
/**
|
||||
* Indicates whether the equipment instance is currently active.
|
||||
* 指示装备实例当前是否处于激活状态。
|
||||
*/
|
||||
UPROPERTY(VisibleInstanceOnly, BlueprintReadOnly, Category="EquipmentInstance")
|
||||
bool bIsActive;
|
||||
|
||||
/**
|
||||
* Array of actors spawned by this equipment instance.
|
||||
* 由此装备实例生成的Actor数组。
|
||||
*/
|
||||
UPROPERTY(VisibleInstanceOnly, BlueprintReadOnly, Category="EquipmentInstance", ReplicatedUsing=OnRep_EquipmentActors)
|
||||
TArray<TObjectPtr<AActor>> EquipmentActors;
|
||||
};
|
||||
@@ -0,0 +1,119 @@
|
||||
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "UObject/Interface.h"
|
||||
#include "GIS_EquipmentInterface.generated.h"
|
||||
|
||||
class UGIS_ItemInstance;
|
||||
class Apawn;
|
||||
|
||||
/**
|
||||
* Interface class for objects that can act as equipment instances (no modifications needed).
|
||||
* 可作为装备实例的对象的接口类(无需修改)。
|
||||
*/
|
||||
UINTERFACE()
|
||||
class UGIS_EquipmentInterface : public UInterface
|
||||
{
|
||||
GENERATED_BODY()
|
||||
};
|
||||
|
||||
/**
|
||||
* Interface for objects that wish to function as equipment instances.
|
||||
* 希望用作装备实例的对象应实现的接口。
|
||||
* @details Any object implementing this interface can be used as an equipment instance in the equipment system.
|
||||
* @细节 实现此接口的任何对象都可在装备系统中用作装备实例。
|
||||
*/
|
||||
class GENERICINVENTORYSYSTEM_API IGIS_EquipmentInterface
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
/**
|
||||
* Receives the pawn owning this equipment.
|
||||
* 接收拥有此装备的Pawn。
|
||||
* @param NewPawn The pawn with the equipment system component attached. 挂载了装备系统组件的Pawn。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category="GIS|Equipment")
|
||||
void ReceiveOwningPawn(APawn* NewPawn);
|
||||
virtual void ReceiveOwningPawn_Implementation(APawn* NewPawn);
|
||||
|
||||
/**
|
||||
* Gets the pawn owning this equipment.
|
||||
* 获取拥有此装备的Pawn。
|
||||
* @return The owning pawn, or nullptr if none. 所属Pawn,如果没有则返回nullptr。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category="GIS|Equipment")
|
||||
APawn* GetOwningPawn() const;
|
||||
virtual APawn* GetOwningPawn_Implementation() const;
|
||||
|
||||
/**
|
||||
* Receives the source item from which the equipment was created.
|
||||
* 接收创建此装备的源道具。
|
||||
* @param NewItem The source item instance. 源道具实例。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category="GIS|Equipment")
|
||||
void ReceiveSourceItem(UGIS_ItemInstance* NewItem);
|
||||
virtual void ReceiveSourceItem_Implementation(UGIS_ItemInstance* NewItem);
|
||||
|
||||
/**
|
||||
* Gets the source item from which the equipment was created.
|
||||
* 获取创建此装备的源道具。
|
||||
* @return The source item instance, or nullptr if none. 源道具实例,如果没有则返回nullptr。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category="GIS|Equipment")
|
||||
UGIS_ItemInstance* GetSourceItem() const;
|
||||
virtual UGIS_ItemInstance* GetSourceItem_Implementation() const;
|
||||
|
||||
/**
|
||||
* Called after the equipment is added to the equipment system's equipment list.
|
||||
* 在装备被添加到装备系统的装备列表后调用。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category="GIS|Equipment")
|
||||
void OnEquipmentBeginPlay();
|
||||
virtual void OnEquipmentBeginPlay_Implementation();
|
||||
|
||||
UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category="GIS|Equipment")
|
||||
void OnEquipmentTick(float DeltaSeconds);
|
||||
virtual void OnOnEquipmentTick_Implementation(float DeltaSeconds);
|
||||
|
||||
/**
|
||||
* Called before the equipment is removed from the equipment system's equipment list.
|
||||
* 在从装备系统的装备列表移除装备之前调用。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category="GIS|Equipment")
|
||||
void OnEquipmentEndPlay();
|
||||
virtual void OnEquipmentEndPlay_Implementation();
|
||||
|
||||
/**
|
||||
* Responds to changes in the equipment's active state.
|
||||
* 响应装备激活状态的变化。
|
||||
* @param bNewActiveState The new active state of the equipment. 装备的新激活状态。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category="GIS|Equipment")
|
||||
void OnActiveStateChanged(bool bNewActiveState);
|
||||
virtual void OnActiveStateChanged_Implementation(bool bNewActiveState);
|
||||
|
||||
/**
|
||||
* Checks if the equipment is active.
|
||||
* 检查装备是否处于激活状态。
|
||||
* @return True if the equipment is active, false otherwise. 如果装备处于激活状态则返回true,否则返回false。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category="GIS|Equipment")
|
||||
bool IsEquipmentActive() const;
|
||||
virtual bool IsEquipmentActive_Implementation() const;
|
||||
|
||||
/**
|
||||
* Checks if the equipment instance's replication is managed by the equipment system.
|
||||
* 检查装备实例的复制是否由装备系统管理。
|
||||
* @details By default, the equipment system manages only GIS_EquipmentInstance and its subclasses.
|
||||
* @细节 默认情况下,装备系统仅管理GIS_EquipmentInstance及其子类。
|
||||
* @attention Do not override this method unless you fully understand its implications.
|
||||
* @注意 除非完全了解其影响,否则不要覆写此方法。
|
||||
* @return True if replication is managed by the equipment system, false otherwise. 如果复制由装备系统管理则返回true,否则返回false。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category="GIS|Equipment")
|
||||
bool IsReplicationManaged();
|
||||
virtual bool IsReplicationManaged_Implementation();
|
||||
};
|
||||
@@ -0,0 +1,270 @@
|
||||
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "GameplayTagContainer.h"
|
||||
#include "Net/Serialization/FastArraySerializer.h"
|
||||
#include "UObject/Object.h"
|
||||
#include "GIS_EquipmentStructLibrary.generated.h"
|
||||
|
||||
USTRUCT(BlueprintType)
|
||||
struct GENERICINVENTORYSYSTEM_API FGIS_EquipmentActorToSpawn
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
FGIS_EquipmentActorToSpawn()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Actor class must implements GIS_EquipmentActorInterface!
|
||||
*/
|
||||
UPROPERTY(EditAnywhere, BlueprintReadonly, Category = Equipment, meta=(MustImplement="/Script/GenericInventorySystem.GIS_EquipmentActorInterface"))
|
||||
TSoftClassPtr<AActor> ActorToSpawn;
|
||||
|
||||
/**
|
||||
* If the spawned actor will attach to equipment owner?
|
||||
*/
|
||||
UPROPERTY(EditAnywhere, Category = Equipment)
|
||||
bool bShouldAttach{true};
|
||||
|
||||
/**
|
||||
* The socket to attach to.
|
||||
*/
|
||||
UPROPERTY(EditAnywhere, Category = Equipment, meta = (EditCondition = "bShouldAttach", EditConditionHides))
|
||||
FName AttachSocket;
|
||||
|
||||
/**
|
||||
* The relative transform to attach to.
|
||||
*/
|
||||
UPROPERTY(EditAnywhere, Category = Equipment, meta = (EditCondition = "bShouldAttach", EditConditionHides))
|
||||
FTransform AttachTransform;
|
||||
};
|
||||
|
||||
class UGIS_ItemInstance;
|
||||
class UGIS_EquipmentInstance;
|
||||
class UGIS_EquipItemInstance;
|
||||
class UGIS_ItemDefinition;
|
||||
class UGIS_EquipmentSystemComponent;
|
||||
struct FGIS_EquipmentContainer;
|
||||
|
||||
/**
|
||||
* Structure representing an equipment entry in the container.
|
||||
* 表示容器中装备条目的结构体。
|
||||
*/
|
||||
USTRUCT()
|
||||
struct GENERICINVENTORYSYSTEM_API FGIS_EquipmentEntry : public FFastArraySerializerItem
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
/**
|
||||
* Default constructor for equipment entry.
|
||||
* 装备条目的默认构造函数。
|
||||
*/
|
||||
FGIS_EquipmentEntry()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a debug string representation of the equipment entry.
|
||||
* 获取装备条目的调试字符串表示。
|
||||
* @return The debug string. 调试字符串。
|
||||
*/
|
||||
FString GetDebugString() const;
|
||||
|
||||
private:
|
||||
friend FGIS_EquipmentContainer;
|
||||
friend UGIS_EquipmentSystemComponent;
|
||||
|
||||
/**
|
||||
* The equipment instance.
|
||||
* 装备实例。
|
||||
*/
|
||||
UPROPERTY(VisibleAnywhere, Category = "Equipment", meta = (ShowInnerProperties))
|
||||
TObjectPtr<UObject> Instance = nullptr;
|
||||
|
||||
/**
|
||||
* The item instance associated with this equipment.
|
||||
* 与此装备关联的道具实例。
|
||||
*/
|
||||
UPROPERTY(VisibleAnywhere, Category = "Equipment")
|
||||
TObjectPtr<UGIS_ItemInstance> ItemInstance{nullptr};
|
||||
|
||||
/**
|
||||
* The slot where the equipment is equipped.
|
||||
* 装备所在的装备槽。
|
||||
*/
|
||||
UPROPERTY(VisibleAnywhere, Category = "Equipment")
|
||||
FGameplayTag EquippedSlot;
|
||||
|
||||
/**
|
||||
* Which group the equipment belongs to.
|
||||
* 此装备属于哪个组?
|
||||
*/
|
||||
UPROPERTY(VisibleAnywhere, Category = "Equipment")
|
||||
FGameplayTag EquippedGroup;
|
||||
|
||||
/**
|
||||
* Indicates whether the equipment is active.
|
||||
* 指示装备是否处于激活状态。
|
||||
*/
|
||||
UPROPERTY(VisibleAnywhere, Category = "Equipment")
|
||||
bool bActive{false};
|
||||
|
||||
/**
|
||||
* Previous active state (not replicated).
|
||||
* 上一个激活状态(不复制)。
|
||||
*/
|
||||
UPROPERTY(VisibleAnywhere, Category = "Equipment", NotReplicated)
|
||||
bool bPrevActive = false;
|
||||
|
||||
UPROPERTY(VisibleAnywhere, Category = "Equipment", NotReplicated)
|
||||
FGameplayTag PrevEquippedGroup;
|
||||
|
||||
bool CheckClientDataReady() const;
|
||||
|
||||
/**
|
||||
* Checks if the equipment entry is valid.
|
||||
* 检查装备条目是否有效。
|
||||
* @return True if the entry is valid, false otherwise. 如果条目有效则返回true,否则返回false。
|
||||
*/
|
||||
bool IsValidEntry() const;
|
||||
};
|
||||
|
||||
/**
|
||||
* Container for a list of applied equipment.
|
||||
* 存储已应用装备列表的容器。
|
||||
*/
|
||||
USTRUCT()
|
||||
struct GENERICINVENTORYSYSTEM_API FGIS_EquipmentContainer : public FFastArraySerializer
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
/**
|
||||
* Default constructor for equipment container.
|
||||
* 装备容器的默认构造函数。
|
||||
*/
|
||||
FGIS_EquipmentContainer()
|
||||
: OwningComponent(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for equipment container with an owning component.
|
||||
* 使用所属组件构造装备容器。
|
||||
* @param InComponent The owning equipment system component. 所属的装备系统组件。
|
||||
*/
|
||||
FGIS_EquipmentContainer(UGIS_EquipmentSystemComponent* InComponent)
|
||||
: OwningComponent(InComponent)
|
||||
{
|
||||
}
|
||||
|
||||
//~FFastArraySerializer contract
|
||||
/**
|
||||
* Called before equipment entries are removed during replication.
|
||||
* 复制期间在移除装备条目前调用。
|
||||
* @param RemovedIndices The indices of removed entries. 移除条目的索引。
|
||||
* @param FinalSize The final size of the array after removal. 移除后数组的最终大小。
|
||||
*/
|
||||
void PreReplicatedRemove(const TArrayView<int32> RemovedIndices, int32 FinalSize);
|
||||
|
||||
/**
|
||||
* Called after equipment entries are added during replication.
|
||||
* 复制期间在添加装备条目后调用。
|
||||
* @param AddedIndices The indices of added entries. 添加条目的索引。
|
||||
* @param FinalSize The final size of the array after addition. 添加后数组的最终大小。
|
||||
*/
|
||||
void PostReplicatedAdd(const TArrayView<int32> AddedIndices, int32 FinalSize);
|
||||
|
||||
/**
|
||||
* Called after equipment entries are changed during replication.
|
||||
* 复制期间在装备条目更改后调用。
|
||||
* @param ChangedIndices The indices of changed entries. 更改条目的索引。
|
||||
* @param FinalSize The final size of the array after changes. 更改后数组的最终大小。
|
||||
*/
|
||||
void PostReplicatedChange(const TArrayView<int32> ChangedIndices, int32 FinalSize);
|
||||
//~End of FFastArraySerializer contract
|
||||
|
||||
/**
|
||||
* Handles delta serialization for the equipment container.
|
||||
* 处理装备容器的增量序列化。
|
||||
* @param DeltaParms The serialization parameters. 序列化参数。
|
||||
* @return True if serialization was successful, false otherwise. 如果序列化成功则返回true,否则返回false。
|
||||
*/
|
||||
bool NetDeltaSerialize(FNetDeltaSerializeInfo& DeltaParms)
|
||||
{
|
||||
return FastArrayDeltaSerialize<FGIS_EquipmentEntry, FGIS_EquipmentContainer>(Entries, DeltaParms, *this);
|
||||
}
|
||||
|
||||
int32 IndexOfBySlot(const FGameplayTag& Slot) const;
|
||||
|
||||
//check if any equipment's group matches this group.
|
||||
int32 IndexOfByGroup(const FGameplayTag& Group) const;
|
||||
|
||||
int32 IndexOfByInstance(const UObject* Instance) const;
|
||||
|
||||
int32 IndexOfByItem(const UGIS_ItemInstance* Item) const;
|
||||
|
||||
int32 IndexOfByItemId(const FGuid& ItemId) const;
|
||||
|
||||
/**
|
||||
* Replicated list of equipment entries.
|
||||
* 复制的装备条目列表。
|
||||
*/
|
||||
UPROPERTY(VisibleAnywhere, Category = "EquipmentSystem", meta = (ShowOnlyInnerProperties, DisplayName = "Equipments"))
|
||||
TArray<FGIS_EquipmentEntry> Entries;
|
||||
|
||||
/**
|
||||
* The equipment system component that owns this container.
|
||||
* 拥有此容器的装备系统组件。
|
||||
*/
|
||||
UPROPERTY()
|
||||
TObjectPtr<UGIS_EquipmentSystemComponent> OwningComponent;
|
||||
};
|
||||
|
||||
/**
|
||||
* Template specialization to enable network delta serialization for the equipment container.
|
||||
* 为装备容器启用网络增量序列化的模板特化。
|
||||
*/
|
||||
template <>
|
||||
struct TStructOpsTypeTraits<FGIS_EquipmentContainer> : TStructOpsTypeTraitsBase2<FGIS_EquipmentContainer>
|
||||
{
|
||||
enum
|
||||
{
|
||||
WithNetDeltaSerializer = true
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Structure representing a group active index entry.
|
||||
* 表示组激活索引条目的结构体。
|
||||
*/
|
||||
USTRUCT()
|
||||
struct GENERICINVENTORYSYSTEM_API FGIS_EquipmentGroupEntry : public FFastArraySerializerItem
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
/**
|
||||
* The group tag.
|
||||
* 组标签。
|
||||
*/
|
||||
UPROPERTY(VisibleAnywhere, Category = "EquipmentGroup")
|
||||
FGameplayTag GroupTag;
|
||||
|
||||
/**
|
||||
* The active slot within the group.
|
||||
* 组内的激活槽位。
|
||||
*/
|
||||
UPROPERTY(VisibleAnywhere, Category = "EquipmentGroup")
|
||||
FGameplayTag ActiveSlot;
|
||||
|
||||
UPROPERTY(NotReplicated)
|
||||
FGameplayTag LastSlot;
|
||||
|
||||
/**
|
||||
* Checks if the entry is valid.
|
||||
* 检查条目是否有效。
|
||||
*/
|
||||
bool IsValid() const { return GroupTag.IsValid(); }
|
||||
};
|
||||
@@ -0,0 +1,753 @@
|
||||
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "GameplayTagContainer.h"
|
||||
#include "GIS_CoreStructLibray.h"
|
||||
#include "GIS_EquipmentStructLibrary.h"
|
||||
#include "GIS_InventoryMeesages.h"
|
||||
#include "Items/GIS_ItemInfo.h"
|
||||
#include "Components/PawnComponent.h"
|
||||
#include "GIS_EquipmentSystemComponent.generated.h"
|
||||
|
||||
class UGIS_ItemSlotCollectionDefinition;
|
||||
class UGIS_InventorySystemComponent;
|
||||
class UGIS_EquipmentInstance;
|
||||
class UGIS_ItemSlotCollection;
|
||||
class UGIS_EquipItemInstance;
|
||||
|
||||
/**
|
||||
* Delegate triggered when the equipment system is initialized.
|
||||
* 装备系统初始化时触发的委托。
|
||||
*/
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FGIS_Equipment_InitializedSignature);
|
||||
|
||||
/**
|
||||
* Delegate triggered when an equipment's state changes (equipped or unequipped).
|
||||
* 装备状态更改(装备或卸下)时触发的委托。
|
||||
* @param Equipment The equipment instance. 装备实例。
|
||||
* @param SlotTag The slot tag associated with the equipment. 与装备关联的槽标签。
|
||||
* @param bEquipped Whether the equipment is equipped. 装备是否已装备。
|
||||
*/
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_ThreeParams(FGIS_Equipment_StateChangedSignature, UObject *, Equipment, FGameplayTag, SlotTag, bool, bEquipped);
|
||||
|
||||
/**
|
||||
* Delegate triggered when an equipment's active state changes.
|
||||
* 装备激活状态更改时触发的委托。
|
||||
* @param Equipment The equipment instance. 装备实例。
|
||||
* @param SlotTag The slot tag associated with the equipment. 与装备关联的槽标签。
|
||||
* @param bActive Whether the equipment is active. 装备是否激活。
|
||||
*/
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_ThreeParams(FGIS_Equipment_ActiveStateChangedSignature, UObject *, Equipment, FGameplayTag, SlotTag, bool, bActive);
|
||||
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_ThreeParams(FGIS_Equipment_GroupStateChangedSignature, UObject *, Equipment, FGameplayTag, SlotTag, FGameplayTag, GroupTag);
|
||||
|
||||
/**
|
||||
* Dynamic delegate for equipment system initialization events.
|
||||
* 装备系统初始化事件的动态委托。
|
||||
*/
|
||||
UDELEGATE()
|
||||
DECLARE_DYNAMIC_DELEGATE(FGIS_EquipmentSystem_Initialized_DynamicEvent);
|
||||
|
||||
/**
|
||||
* Manager of equipment instances for a pawn.
|
||||
* 管理棋子装备实例的组件。
|
||||
*/
|
||||
UCLASS(ClassGroup = (GIS), meta = (BlueprintSpawnableComponent))
|
||||
class GENERICINVENTORYSYSTEM_API UGIS_EquipmentSystemComponent : public UPawnComponent
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
friend FGIS_EquipmentContainer;
|
||||
friend FGIS_EquipmentEntry;
|
||||
|
||||
public:
|
||||
/**
|
||||
* Sets default values for this component's properties.
|
||||
* 为组件的属性设置默认值。
|
||||
* @param ObjectInitializer The object initializer. 对象初始化器。
|
||||
*/
|
||||
UGIS_EquipmentSystemComponent(const FObjectInitializer& ObjectInitializer = FObjectInitializer::Get());
|
||||
|
||||
//~UObject interface
|
||||
/**
|
||||
* Gets the properties that should be replicated for this object.
|
||||
* 获取需要为此对象复制的属性。
|
||||
* @param OutLifetimeProps Array to store the replicated properties. 存储复制属性的数组。
|
||||
*/
|
||||
virtual void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override;
|
||||
|
||||
/**
|
||||
* Replicates subobjects for this component.
|
||||
* 为此组件复制子对象。
|
||||
* @param Channel The actor channel. 演员通道。
|
||||
* @param Bunch The replication data bunch. 复制数据束。
|
||||
* @param RepFlags The replication flags. 复制标志。
|
||||
* @return True if subobjects were replicated, false otherwise. 如果子对象被复制则返回true,否则返回false。
|
||||
*/
|
||||
virtual bool ReplicateSubobjects(class UActorChannel* Channel, class FOutBunch* Bunch, FReplicationFlags* RepFlags) override;
|
||||
//~End of UObject interface
|
||||
|
||||
//~UActorComponent interface
|
||||
/**
|
||||
* Called when the component is registered.
|
||||
* 组件注册时调用。
|
||||
*/
|
||||
virtual void OnRegister() override;
|
||||
|
||||
/**
|
||||
* Initializes the component.
|
||||
* 初始化组件。
|
||||
*/
|
||||
virtual void InitializeComponent() override;
|
||||
|
||||
/**
|
||||
* Prepares the component for replication.
|
||||
* 为组件的复制做准备。
|
||||
*/
|
||||
virtual void ReadyForReplication() override;
|
||||
|
||||
/**
|
||||
* Called when the game starts.
|
||||
* 游戏开始时调用。
|
||||
*/
|
||||
virtual void BeginPlay() override;
|
||||
|
||||
/**
|
||||
* Updates the component each frame.
|
||||
* 每帧更新组件。
|
||||
* @param DeltaTime Time since the last tick. 上次tick以来的时间。
|
||||
* @param TickType The type of tick. tick类型。
|
||||
* @param ThisTickFunction The tick function. tick函数。
|
||||
*/
|
||||
virtual void TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
|
||||
|
||||
/**
|
||||
* Uninitializes the component.
|
||||
* 取消初始化组件。
|
||||
*/
|
||||
virtual void UninitializeComponent() override;
|
||||
|
||||
/**
|
||||
* Called when the game ends.
|
||||
* 游戏结束时调用。
|
||||
* @param EndPlayReason The reason the game ended. 游戏结束的原因。
|
||||
*/
|
||||
virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
|
||||
//~End of UActorComponent interface
|
||||
|
||||
#pragma region Equipment System
|
||||
/**
|
||||
* Gets the equipment system component from the specified actor.
|
||||
* 从指定演员获取装备系统组件。
|
||||
* @param Actor The actor to query. 要查询的演员。
|
||||
* @return The equipment system component, or nullptr if not found. 装备系统组件,如果未找到则返回nullptr。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "GIS|EquipmentSystem", Meta = (DefaultToSelf = "Actor"))
|
||||
static UGIS_EquipmentSystemComponent* GetEquipmentSystemComponent(const AActor* Actor);
|
||||
|
||||
/**
|
||||
* Finds the equipment system component on the specified actor.
|
||||
* 在指定演员上查找装备系统组件。
|
||||
* @param Actor The actor to search for the component. 要查找组件的演员。
|
||||
* @param Component The found equipment system component (output). 找到的装备系统组件(输出)。
|
||||
* @return True if the component was found, false otherwise. 如果找到组件则返回true,否则返回false。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "GIS|EquipmentSystem", Meta = (DefaultToSelf = "Actor", ExpandBoolAsExecs = "ReturnValue"))
|
||||
static bool FindEquipmentSystemComponent(const AActor* Actor, UGIS_EquipmentSystemComponent*& Component);
|
||||
|
||||
/**
|
||||
* Finds a typed equipment system component on the specified actor.
|
||||
* 在指定演员上查找类型化的装备系统组件。
|
||||
* @param Actor The actor to search for the component. 要查找组件的演员。
|
||||
* @param DesiredClass The desired class of the component. 组件的期望类。
|
||||
* @param Component The found equipment system component (output). 找到的装备系统组件(输出)。
|
||||
* @return True if the component was found, false otherwise. 如果找到组件则返回true,否则返回false。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "GIS|EquipmentSystem",
|
||||
meta = (DefaultToSelf = "Actor", DynamicOutputParam = "Component", DeterminesOutputType = "DesiredClass", ExpandBoolAsExecs = "ReturnValue"))
|
||||
static bool FindTypedEquipmentSystemComponent(AActor* Actor, TSubclassOf<UGIS_EquipmentSystemComponent> DesiredClass, UGIS_EquipmentSystemComponent*& Component);
|
||||
|
||||
/**
|
||||
* Initializes the equipment system.
|
||||
* 初始化装备系统。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintAuthorityOnly, Category = "GIS|EquipmentSystem")
|
||||
virtual void InitializeEquipmentSystem();
|
||||
|
||||
/**
|
||||
* Initializes the equipment system with a specified inventory system.
|
||||
* 使用指定的库存系统初始化装备系统。
|
||||
* @param InventorySystem The inventory system to associate with. 要关联的库存系统。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintAuthorityOnly, Category = "GIS|EquipmentSystem")
|
||||
virtual void InitializeEquipmentSystemWithInventory(UGIS_InventorySystemComponent* InventorySystem);
|
||||
|
||||
/**
|
||||
* Resets the equipment system.
|
||||
* 重置装备系统。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintAuthorityOnly, Category = "GIS|EquipmentSystem")
|
||||
virtual void ResetEquipmentSystem();
|
||||
|
||||
/**
|
||||
* Gets the target collection tag for equipment monitoring.
|
||||
* 获取用于装备监控的目标集合标签。
|
||||
* @return The target collection tag. 目标集合标签。
|
||||
*/
|
||||
FGameplayTag GetTargetCollectionTag() const { return TargetCollectionTag; };
|
||||
|
||||
/**
|
||||
* Checks if the equipment system is initialized.
|
||||
* 检查装备系统是否已初始化。
|
||||
* @return True if initialized, false otherwise. 如果已初始化则返回true,否则返回false。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "GIS|InventorySystem")
|
||||
bool IsEquipmentSystemInitialized() const;
|
||||
|
||||
/**
|
||||
* Binds a delegate to be called when the equipment system is initialized.
|
||||
* 绑定一个委托,在装备系统初始化时调用。
|
||||
* @param Delegate The delegate to bind. 要绑定的委托。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "GIS|InventorySystem")
|
||||
void BindToEquipmentSystemInitialized(FGIS_EquipmentSystem_Initialized_DynamicEvent Delegate);
|
||||
|
||||
/**
|
||||
* Removes all equipment instances from the system.
|
||||
* 从系统中移除所有装备实例。
|
||||
*/
|
||||
virtual void RemoveAllEquipments();
|
||||
|
||||
/**
|
||||
* Equips an item to a specific slot.
|
||||
* 将道具装备到指定槽。
|
||||
* @param Item The item instance to equip. 要装备的道具实例。
|
||||
* @param SlotTag The slot tag to equip the item to. 装备道具的槽标签。
|
||||
*/
|
||||
virtual void EquipItemToSlot(UGIS_ItemInstance* Item, const FGameplayTag& SlotTag);
|
||||
|
||||
/**
|
||||
* Unequips an item from a specific slot.
|
||||
* 从指定槽卸下装备。
|
||||
* @param SlotTag The slot tag to unequip. 要卸下的槽标签。
|
||||
*/
|
||||
virtual void UnequipBySlot(FGameplayTag SlotTag);
|
||||
|
||||
/**
|
||||
* Unequips an item by its ID.
|
||||
* 通过道具ID卸下装备。
|
||||
* @param ItemId The ID of the item to unequip. 要卸下的道具ID。
|
||||
*/
|
||||
virtual void UnequipByItem(const FGuid& ItemId);
|
||||
|
||||
/**
|
||||
* Checks if the owning actor has authority.
|
||||
* 检查拥有者演员是否具有权限。
|
||||
* @return True if the owner has authority, false otherwise. 如果拥有者有权限则返回true,否则返回false。
|
||||
*/
|
||||
bool OwnerHasAuthority() const;
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Called when the target collection's item stacks change.
|
||||
* 目标集合的道具堆栈更改时调用。
|
||||
* @param Message The update message containing stack details. 包含堆栈详细信息的更新消息。
|
||||
*/
|
||||
UFUNCTION()
|
||||
virtual void OnTargetCollectionChanged(const FGIS_InventoryStackUpdateMessage& Message);
|
||||
|
||||
/**
|
||||
* Called when the target collection is removed.
|
||||
* 目标集合移除时调用。
|
||||
* @param Collection The removed collection. 移除的集合。
|
||||
*/
|
||||
UFUNCTION()
|
||||
virtual void OnTargetCollectionRemoved(UGIS_ItemCollection* Collection);
|
||||
|
||||
/**
|
||||
* Called when the equipment system is initialized.
|
||||
* 装备系统初始化时调用。
|
||||
*/
|
||||
UFUNCTION(BlueprintNativeEvent, Category = "GIS|EquipmentSystem")
|
||||
void OnEquipmentSystemInitialized();
|
||||
|
||||
/**
|
||||
* List of delegates for equipment system initialization.
|
||||
* 装备系统初始化的委托列表。
|
||||
*/
|
||||
UPROPERTY()
|
||||
TArray<FGIS_EquipmentSystem_Initialized_DynamicEvent> InitializedDelegates;
|
||||
|
||||
#pragma endregion
|
||||
|
||||
#pragma region Equipments Query
|
||||
|
||||
public:
|
||||
/**
|
||||
* Gets all equipment instances matching the specified conditions.
|
||||
* 获取匹配指定条件的所有装备实例。
|
||||
* @param InstanceType The type of equipment instance to query. 要查询的装备实例类型。
|
||||
* @param SlotQuery The gameplay tag query for slots. 槽的游戏标签查询。
|
||||
* @return Array of matching equipment instances, or empty if none found. 匹配的装备实例数组,如果未找到则返回空。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure = false, Category = "GIS|EquipmentSystem", meta = (DeterminesOutputType = InstanceType, DynamicOutputParam = ReturnValue))
|
||||
TArray<UObject*> GetEquipments(UPARAM(meta = (MustImplement = "/Script/GenericInventorySystem.GIS_EquipmentInterface", AllowAbstract = "false"))
|
||||
TSubclassOf<UObject>
|
||||
InstanceType,
|
||||
UPARAM(meta=(Categories="GIS.Slots")) FGameplayTagQuery SlotQuery) const;
|
||||
|
||||
/**
|
||||
* Gets all active equipment instances matching the specified conditions.
|
||||
* 获取匹配指定条件的激活装备实例。
|
||||
* @param InstanceType The type of equipment instance to query. 要查询的装备实例类型。
|
||||
* @param SlotQuery The gameplay tag query for slots. 槽的游戏标签查询。
|
||||
* @return Array of active equipment instances, or empty if none found. 激活的装备实例数组,如果未找到则返回空。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure = false, Category = "GIS|EquipmentSystem",
|
||||
meta = (DeterminesOutputType = InstanceType, DynamicOutputParam = ReturnValue))
|
||||
TArray<UObject*> GetActiveEquipments(UPARAM(meta = (MustImplement = "/Script/GenericInventorySystem.GIS_EquipmentInterface", AllowAbstract = "false"))
|
||||
TSubclassOf<UObject>
|
||||
InstanceType,
|
||||
UPARAM(meta=(Categories="GIS.Slots")) FGameplayTagQuery SlotQuery) const;
|
||||
|
||||
/**
|
||||
* Gets the first equipment instance matching the specified query.
|
||||
* 获取匹配指定查询的第一个装备实例。
|
||||
* @param InstanceType The type of equipment instance to query. 要查询的装备实例类型。
|
||||
* @param SlotQuery The gameplay tag query for slots. 槽的游戏标签查询。
|
||||
* @return The first matching equipment instance, or nullptr if none found. 第一个匹配的装备实例,如果未找到则返回nullptr。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure = false, Category = "GIS|EquipmentSystem", meta = (DeterminesOutputType = InstanceType, DynamicOutputParam = ReturnValue))
|
||||
UObject* GetEquipment(UPARAM(meta = (MustImplement = "/Script/GenericInventorySystem.GIS_EquipmentInterface", AllowAbstract = "false"))
|
||||
TSubclassOf<UObject>
|
||||
InstanceType,
|
||||
UPARAM(meta=(Categories="GIS.Slots")) FGameplayTagQuery SlotQuery) const;
|
||||
|
||||
/**
|
||||
* Gets the first active equipment instance matching the specified query.
|
||||
* 获取匹配指定查询的第一个激活装备实例。
|
||||
* @param InstanceType The type of equipment instance to query. 要查询的装备实例类型。
|
||||
* @param SlotQuery The gameplay tag query for slots. 槽的游戏标签查询。
|
||||
* @return The first active equipment instance, or nullptr if none found. 第一个激活的装备实例,如果未找到则返回nullptr。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure = false, Category = "GIS|EquipmentSystem", meta = (DeterminesOutputType = InstanceType, DynamicOutputParam = ReturnValue))
|
||||
UObject* GetActiveEquipment(UPARAM(meta = (MustImplement = "/Script/GenericInventorySystem.GIS_EquipmentInterface", AllowAbstract = "false"))
|
||||
TSubclassOf<UObject>
|
||||
InstanceType,
|
||||
UPARAM(meta=(Categories="GIS.Slots")) FGameplayTagQuery SlotQuery) const;
|
||||
|
||||
/**
|
||||
* Gets the active equipment within specified equipment group.
|
||||
* 获取指定组中的激活装备。
|
||||
* @param GroupTag The equipment group to look for. 要查询的装备组。
|
||||
* @param bExactMatch If true, the group tag has to be exactly present. 如果为真,对组标签进行绝对匹配。
|
||||
* @return active equipment in group. 组中激活的装备。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure = false, Category = "GIS|EquipmentSystem")
|
||||
UObject* GetActiveEquipmentInGroup(UPARAM(meta=(Categories="GIS.Slots")) FGameplayTag GroupTag, bool bExactMatch = true) const;
|
||||
|
||||
/**
|
||||
* Gets the equipment instance that spawned the specified equipment actor.
|
||||
* 获取生成指定装备演员的装备实例。
|
||||
* @param EquipmentActor The equipment actor to query. 要查询的装备演员。
|
||||
* @return The equipment instance, or nullptr if not found. 装备实例,如果未找到则返回nullptr。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure = false, Category = "GIS|EquipmentSystem", meta = (DefaultToSelf = "EquipmentActor"))
|
||||
UGIS_EquipmentInstance* GetEquipmentInstanceOfActor(AActor* EquipmentActor) const;
|
||||
|
||||
/**
|
||||
* Gets the typed equipment instance that spawned the specified equipment actor.
|
||||
* 获取生成指定装备演员的类型化装备实例。
|
||||
* @param InstanceType The desired type of equipment instance. 期望的装备实例类型。
|
||||
* @param EquipmentActor The equipment actor to query. 要查询的装备演员。
|
||||
* @return The typed equipment instance, or nullptr if not found. 类型化的装备实例,如果未找到则返回nullptr。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure = false, Category = "GIS|EquipmentSystem",
|
||||
meta = (DefaultToSelf = "EquipmentActor", DeterminesOutputType = InstanceType, DynamicOutputParam = ReturnValue))
|
||||
UGIS_EquipmentInstance* GetTypedEquipmentInstanceOfActor(TSubclassOf<UGIS_EquipmentInstance> InstanceType, AActor* EquipmentActor) const;
|
||||
|
||||
/**
|
||||
* Gets the equipment instance in a specific slot.
|
||||
* 获取特定槽中的装备实例。
|
||||
* @param SlotTag The slot tag to query. 要查询的槽标签。
|
||||
* @return The equipment instance in the slot, or nullptr if none. 槽中的装备实例,如果没有则返回nullptr。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "GIS|EquipmentSystem")
|
||||
UObject* GetEquipmentInSlot(UPARAM(meta=(Categories="GIS.Slots")) FGameplayTag SlotTag) const;
|
||||
|
||||
/**
|
||||
* Gets the equipment instance associated with a specific item instance.
|
||||
* 获取与特定道具实例关联的装备实例。
|
||||
* @param Item The item instance to query. 要查询的道具实例。
|
||||
* @return The equipment instance, or nullptr if none. 装备实例,如果没有则返回nullptr。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "GIS|EquipmentSystem")
|
||||
UObject* GetEquipmentByItem(const UGIS_ItemInstance* Item);
|
||||
|
||||
#pragma endregion
|
||||
|
||||
#pragma region Equipments Activation/Deactivation
|
||||
/**
|
||||
* Sets the active state of equipment in a specific slot.
|
||||
* 设置特定槽中装备的激活状态。
|
||||
* @param SlotTag The slot tag of the equipment. 装备的槽标签。
|
||||
* @param NewActiveState The new active state. 新的激活状态。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintAuthorityOnly, Category = "GIS|EquipmentSystem")
|
||||
virtual void SetEquipmentActiveState(UPARAM(meta=(Categories="GIS.Slots")) FGameplayTag SlotTag, bool NewActiveState);
|
||||
|
||||
/**
|
||||
* Server-side function to set the active state of an equipment in a specific slot.
|
||||
* 服务器端函数,设置特定槽中装备的激活状态。
|
||||
* @param SlotTag The slot tag of the equipment. 装备的槽标签。
|
||||
* @param NewActiveState The new active state. 新的激活状态。
|
||||
*/
|
||||
UFUNCTION(Server, Reliable, BlueprintCallable, BlueprintAuthorityOnly, Category = "GIS|EquipmentSystem")
|
||||
void ServerSetEquipmentActiveState(UPARAM(meta=(Categories="GIS.Slots")) FGameplayTag SlotTag, bool NewActiveState);
|
||||
virtual void ServerSetEquipmentActiveState_Implementation(FGameplayTag SlotTag, bool NewActiveState);
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Directly update the active state and group state for equipment entry at Idx.
|
||||
* 直接设置装备的激活状态和分组。
|
||||
* @param Idx The index of the equipment entry. 装备条目索引。
|
||||
* @param NewActiveState The new active state. 新的激活状态。
|
||||
* @param NewGroup The new group state. 新的组状态。
|
||||
*
|
||||
*/
|
||||
virtual void UpdateEquipmentState(int32 Idx, bool NewActiveState, FGameplayTag NewGroup);
|
||||
|
||||
#pragma endregion
|
||||
|
||||
#pragma region Events
|
||||
|
||||
public:
|
||||
/**
|
||||
* Event triggered when the equipment system is initialized.
|
||||
* 装备系统初始化时触发的事件。
|
||||
*/
|
||||
UPROPERTY(BlueprintAssignable)
|
||||
FGIS_Equipment_InitializedSignature OnEquipmentSystemInitializedEvent;
|
||||
|
||||
/**
|
||||
* Event triggered when an equipment's state changes.
|
||||
* 装备状态更改时触发的事件。
|
||||
* @attention Called after equipping, before unequipping.
|
||||
* @attention 在装备后、卸下前调用。
|
||||
*/
|
||||
UPROPERTY(BlueprintAssignable)
|
||||
FGIS_Equipment_StateChangedSignature OnEquipmentStateChangedEvent;
|
||||
|
||||
/**
|
||||
* Event triggered when an equipment's active state changes.
|
||||
* 装备激活状态更改时触发的事件。
|
||||
*/
|
||||
UPROPERTY(BlueprintAssignable)
|
||||
FGIS_Equipment_ActiveStateChangedSignature OnEquipmentActiveStateChangedEvent;
|
||||
|
||||
UPROPERTY(BlueprintAssignable)
|
||||
FGIS_Equipment_GroupStateChangedSignature OnEquipmentGroupStateChangedEvent;
|
||||
|
||||
#pragma endregion
|
||||
|
||||
#pragma region Slot Query
|
||||
/**
|
||||
* Checks if a specific slot is equipped.
|
||||
* 检查特定槽是否已装备。
|
||||
* @param SlotTag The slot tag to check. 要检查的槽标签。
|
||||
* @return True if the slot is equipped, false otherwise. 如果槽已装备则返回true,否则返回false。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "GIS|EquipmentSystem")
|
||||
bool IsSlotEquipped(UPARAM(meta=(Categories="GIS.Slots")) FGameplayTag SlotTag) const;
|
||||
|
||||
/**
|
||||
* Gets the slot where the equipment instance was equipped to.
|
||||
* 获取特定装备实例所装备的位置。
|
||||
* @param Equipment The equipment to look for. 与要查询装备实例。
|
||||
* @return Invalid slot if not found. 如果没查到则返回无效标签。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "GIS|EquipmentSystem")
|
||||
FGameplayTag GetSlotByEquipment(UObject* Equipment) const;
|
||||
|
||||
/**
|
||||
* Gets the slot where the equipment instance associated with a specific item instance was equipped to.
|
||||
* 获取与特定物品实例关联的装备实例所装备的位置。
|
||||
* @param Item The item instance which the equipment instance was associated with. 与要查询装备实例关联的道具实例。
|
||||
* @return Invalid slot if not found. 如果没查到则返回无效标签。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "GIS|EquipmentSystem")
|
||||
FGameplayTag GetSlotByItem(const UGIS_ItemInstance* Item) const;
|
||||
|
||||
/**
|
||||
* Converts a slot tag to the corresponding equipment entry index.
|
||||
* 将槽标签转换为对应的装备条目索引。
|
||||
* @param InSlotTag The slot tag to convert. 要转换的槽标签。
|
||||
* @return The equipment entry index, or INDEX_NONE if not found. 装备条目索引,如果未找到则返回INDEX_NONE。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "GIS|EquipmentSystem")
|
||||
int32 SlotTagToEquipmentInex(UPARAM(meta=(Categories="GIS.Slots")) FGameplayTag InSlotTag) const;
|
||||
|
||||
/**
|
||||
* Converts an item ID to the corresponding equipment entry index.
|
||||
* 将道具ID转换为对应的装备条目索引。
|
||||
* @param InItemId The item ID to convert. 要转换的道具ID。
|
||||
* @return The equipment entry index, or INDEX_NONE if not found. 装备条目索引,如果未找到则返回INDEX_NONE。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "GIS|EquipmentSystem")
|
||||
int32 ItemIdToEquipmentInex(FGuid InItemId) const;
|
||||
|
||||
#pragma endregion
|
||||
|
||||
#pragma region Equipment Entries
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Adds an equipment entry to the system.
|
||||
* 将装备条目添加到系统中。
|
||||
* @param NewEntry The new equipment entry to add. 要添加的新装备条目。
|
||||
*/
|
||||
virtual void AddEquipmentEntry(const FGIS_EquipmentEntry& NewEntry);
|
||||
|
||||
/**
|
||||
* Ticks all the equipment instances in this container.
|
||||
* 更新所有装备实例。
|
||||
* @param DeltaTime The time between frames. 每帧的间隔时间(秒)
|
||||
*/
|
||||
virtual void TickEquipmentEntries(float DeltaTime);
|
||||
|
||||
/**
|
||||
* Removes an equipment entry by its index.
|
||||
* 通过索引移除装备条目。
|
||||
* @param Idx The index of the equipment entry to remove. 要移除的装备条目索引。
|
||||
*/
|
||||
virtual void RemoveEquipmentEntry(int32 Idx);
|
||||
|
||||
/**
|
||||
* Creates an equipment instance for the specified item.
|
||||
* 为指定道具创建装备实例。
|
||||
* @attention The returned instance must implement GIS_EquipmentInterface.
|
||||
* @attention 返回的实例必须实现GIS_EquipmentInterface。
|
||||
* @param Owner The owning actor of the created equipment instance. 创建的装备实例的所属演员。
|
||||
* @param ItemInstance The item instance containing equipment-related data. 包含装备相关数据的道具实例。
|
||||
* @return The created equipment instance (UObject or AActor based on design). 创建的装备实例(根据设计为UObject或AActor)。
|
||||
*/
|
||||
UFUNCTION(BlueprintNativeEvent, Category = "GIS|EquipmentSystem")
|
||||
UObject* CreateEquipmentInstance(AActor* Owner, UGIS_ItemInstance* ItemInstance) const;
|
||||
|
||||
/**
|
||||
* Called when an equipment entry is added.
|
||||
* 装备条目添加时调用。
|
||||
* @param Entry The added equipment entry. 添加的装备条目。
|
||||
* @param Idx The index of the added entry. 添加条目的索引。
|
||||
*/
|
||||
virtual void OnEquipmentEntryAdded(const FGIS_EquipmentEntry& Entry, int32 Idx);
|
||||
|
||||
/**
|
||||
* Called when an equipment entry is changed.
|
||||
* 装备条目更改时调用。
|
||||
* @param Entry The changed equipment entry. 更改的装备条目。
|
||||
* @param Idx The index of the changed entry. 更改条目的索引。
|
||||
*/
|
||||
virtual void OnEquipmentEntryChanged(const FGIS_EquipmentEntry& Entry, int32 Idx);
|
||||
|
||||
/**
|
||||
* Called when an equipment entry is removed.
|
||||
* 装备条目移除时调用。
|
||||
* @param Entry The removed equipment entry. 移除的装备条目。
|
||||
* @param Idx The index of the removed entry. 移除条目的索引。
|
||||
*/
|
||||
virtual void OnEquipmentEntryRemoved(const FGIS_EquipmentEntry& Entry, int32 Idx);
|
||||
|
||||
/**
|
||||
* Adds a replicated equipment object to the system.
|
||||
* 将复制的装备对象添加到系统中。
|
||||
* @param Instance The equipment instance to add. 要添加的装备实例。
|
||||
*/
|
||||
virtual void AddReplicatedEquipmentObject(TObjectPtr<UObject> Instance);
|
||||
|
||||
/**
|
||||
* Removes a replicated equipment object from the system.
|
||||
* 从系统中移除复制的装备对象。
|
||||
* @param Instance The equipment instance to remove. 要移除的装备实例。
|
||||
*/
|
||||
virtual void RemoveReplicatedEquipmentObject(TObjectPtr<UObject> Instance);
|
||||
|
||||
/**
|
||||
* Processes pending equipment entries.
|
||||
* 处理待处理的装备条目。
|
||||
*/
|
||||
virtual void ProcessPendingEquipments();
|
||||
|
||||
/**
|
||||
* List of pending replicated equipment objects.
|
||||
* 待复制的装备对象列表。
|
||||
*/
|
||||
TArray<TObjectPtr<UObject>> PendingReplicatedEquipments;
|
||||
|
||||
/**
|
||||
* Map of pending equipment entries.
|
||||
* 待处理装备条目的映射。
|
||||
*/
|
||||
TMap<int32, FGIS_EquipmentEntry> PendingEquipmentEntries;
|
||||
|
||||
#pragma endregion
|
||||
|
||||
#pragma region Equipment Groups
|
||||
|
||||
public:
|
||||
/**
|
||||
* Gets the layout of an equipment group.
|
||||
* 获取装备组的布局。
|
||||
* @param GroupTag The tag of the equipment group. 装备组的标签。
|
||||
* @return Map of indices to slot tags in the group. 组内索引到槽标签的映射。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "GIS|EquipmentSystem")
|
||||
virtual TMap<int32, FGameplayTag> GetLayoutOfGroup(UPARAM(meta=(Categories="GIS.Slots")) FGameplayTag GroupTag) const;
|
||||
|
||||
/**
|
||||
* Gets the layout of an equipment group.
|
||||
* 获取装备组的布局。
|
||||
* @param GroupTag The tag of the equipment group. 装备组的标签。
|
||||
* @return Map of indices to slot tags in the group. 组内索引到槽标签的映射。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "GIS|EquipmentSystem")
|
||||
virtual TMap<FGameplayTag, int32> GetSlottedLayoutOfGroup(UPARAM(meta=(Categories="GIS.Slots")) FGameplayTag GroupTag) const;
|
||||
|
||||
/**
|
||||
* Get the matching equipment group tag for equipment slot. 获取装备槽所在的装备组。
|
||||
* @param SlotTag The equipment slot to check. 要检查的装备槽。
|
||||
* @return The equipment group tag, none if not groupped. 装备组标签,如果没有组,返回None
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "GIS|EquipmentSystem")
|
||||
FGameplayTag FindMatchingGroupForSlot(UPARAM(meta=(Categories="GIS.Slots")) FGameplayTag SlotTag) const;
|
||||
|
||||
/**
|
||||
* Gets all equipment instances in an equipment group.
|
||||
* 获取装备组中的所有装备实例。
|
||||
* @param GroupTag The tag of the equipment group. 装备组的标签。
|
||||
* @return Map of indices to equipment instances in the group. 组内索引到装备实例的映射。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "GIS|EquipmentSystem")
|
||||
virtual TMap<int32, UObject*> GetEquipmentsOfGroup(UPARAM(meta=(Categories="GIS.Slots")) FGameplayTag GroupTag) const;
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "GIS|EquipmentSystem")
|
||||
virtual TMap<FGameplayTag, UObject*> GetSlottedEquipmentsOfGroup(UPARAM(meta=(Categories="GIS.Slots")) FGameplayTag GroupTag) const;
|
||||
|
||||
/**
|
||||
* Sets the active slot within an equipment group.
|
||||
* 设置装备组中的激活槽。
|
||||
* @param GroupTag The tag of the equipment group. 装备组的标签。
|
||||
* @param NewSlot The new active slot. 新的激活槽。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintAuthorityOnly, Category = "GIS|EquipmentSystem")
|
||||
virtual void SetGroupActiveSlot(UPARAM(meta=(Categories="GIS.Slots")) FGameplayTag GroupTag, FGameplayTag NewSlot);
|
||||
|
||||
/**
|
||||
* Server-side function to set the active slot within an equipment group.
|
||||
* 服务器端函数,设置装备组中的激活槽位。
|
||||
* @param GroupTag The tag of the equipment group. 装备组的标签。
|
||||
* @param NewSlot The new active slot. 新的激活槽位。
|
||||
*/
|
||||
UFUNCTION(Server, Reliable, BlueprintCallable, Category = "GIS|EquipmentSystem")
|
||||
virtual void ServerSetGroupActiveSlot(UPARAM(meta=(Categories="GIS.Slots")) FGameplayTag GroupTag, FGameplayTag NewSlot);
|
||||
|
||||
/**
|
||||
* Cycles the active index within an equipment group in the specified direction.
|
||||
* 按指定方向在装备组中循环激活索引。
|
||||
* @param GroupTag The tag of the equipment group. 装备组的标签。
|
||||
* @param bDirection The cycle direction (true for right, false for left). 循环方向(true为右,false为左)。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintAuthorityOnly, Category = "GIS|EquipmentSystem")
|
||||
virtual void CycleGroupActiveSlot(UPARAM(meta=(Categories="GIS.Slots")) FGameplayTag GroupTag, bool bDirection = true);
|
||||
|
||||
virtual FGameplayTag CycleGroupNextSlot(FGameplayTag GroupTag, FGameplayTag PrevSlot, bool bDirection = true);
|
||||
|
||||
/**
|
||||
* Server-side function to cycle the active slot within an equipment group.
|
||||
* 服务器端函数,按指定方向在装备组中循环激活槽位。
|
||||
* @param GroupTag The tag of the equipment group. 装备组的标签。
|
||||
* @param bDirection The cycle direction (true for right, false for left). 循环方向(true为右,false为左)。
|
||||
*/
|
||||
UFUNCTION(Server, Reliable, BlueprintCallable, Category = "GIS|EquipmentSystem")
|
||||
virtual void ServerCycleGroupActiveSlot(UPARAM(meta=(Categories="GIS.Slots")) FGameplayTag GroupTag, bool bDirection = true);
|
||||
|
||||
protected:
|
||||
#pragma endregion
|
||||
|
||||
#pragma region Properties
|
||||
/**
|
||||
* Whether to initialize the equipment system automatically on BeginPlay.
|
||||
* 是否在BeginPlay时自动初始化装备系统。
|
||||
*/
|
||||
UPROPERTY(EditDefaultsOnly, Category = "EquipmentSystem")
|
||||
bool bInitializeOnBeginPlay = false;
|
||||
|
||||
/**
|
||||
* Indicates if the equipment system is initialized.
|
||||
* 指示装备系统是否已初始化。
|
||||
*/
|
||||
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "EquipmentSystem", ReplicatedUsing = OnEquipmentSystemInitialized)
|
||||
bool bEquipmentSystemInitialized = false;
|
||||
|
||||
/**
|
||||
* The target collection tag for monitoring equipment-related items.
|
||||
* 用于监控装备相关道具的目标集合标签。
|
||||
* @attention Monitors the specified item slot collection in the actor's inventory and generates/removes equipment instances based on changes.
|
||||
* @attention 监听同一演员库存中的指定道具槽集合,并根据变化生成/移除装备实例。
|
||||
*/
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "EquipmentSystem", meta = (AllowPrivateAccess = True, Categories = "GIS.Collection"))
|
||||
FGameplayTag TargetCollectionTag;
|
||||
|
||||
/**
|
||||
* Container for the equipment entries.
|
||||
* 装备条目的容器。
|
||||
*/
|
||||
UPROPERTY(VisibleInstanceOnly, Category = "EquipmentSystem", Replicated, meta = (ShowOnlyInnerProperties))
|
||||
FGIS_EquipmentContainer Container;
|
||||
|
||||
/**
|
||||
* The definition of the target collection where equipment groups are defined.
|
||||
* 定义装备组的目标集合定义。
|
||||
*/
|
||||
UPROPERTY(VisibleInstanceOnly, Category = "EquipmentSystem", Replicated)
|
||||
TObjectPtr<const UGIS_ItemSlotCollectionDefinition> TargetCollectionDefinition;
|
||||
|
||||
// /**
|
||||
// * Container for group active indices.
|
||||
// * 组激活索引的容器。
|
||||
// */
|
||||
// UPROPERTY(VisibleInstanceOnly, Category = "EquipmentSystem", Replicated, meta = (ShowOnlyInnerProperties))
|
||||
// FGIS_EquipmentGroupContainer GroupActiveIndexContainer;
|
||||
|
||||
/**
|
||||
* Track which slot was equipped to which group.
|
||||
*/
|
||||
UPROPERTY(VisibleInstanceOnly, Category = "EquipmentSystem")
|
||||
TMap<FGameplayTag, FGameplayTag> GroupActiveSlots;
|
||||
|
||||
|
||||
/**
|
||||
* The associated inventory system component.
|
||||
* 关联的库存系统组件。
|
||||
*/
|
||||
UPROPERTY()
|
||||
TObjectPtr<UGIS_InventorySystemComponent> Inventory;
|
||||
|
||||
/**
|
||||
* The target item slot collection.
|
||||
* 目标道具槽集合。
|
||||
*/
|
||||
UPROPERTY()
|
||||
TObjectPtr<UGIS_ItemSlotCollection> TargetCollection;
|
||||
|
||||
/**
|
||||
* Mapping of slot tags to equipment entry indices.
|
||||
* 槽标签到装备条目索引的映射。
|
||||
*/
|
||||
UPROPERTY(VisibleInstanceOnly, Category = "EquipmentSystem", meta = (ForceInlineRow), Transient)
|
||||
TMap<FGameplayTag, TObjectPtr<UObject>> SlotToInstanceMap;
|
||||
|
||||
#pragma endregion
|
||||
};
|
||||
Reference in New Issue
Block a user