Skip to content

GameCore.ItemSystem ​

DynamicModification 双端 ​

命名空间 GameCore.ItemSystem

csharp
public class DynamicModification

动态修改项,每个物品上对于特定槽位类型+属性+子类型的组合是唯一的

备注

DynamicModification 表示通过代码动态添加到物品上的属性修改。 每个物品上对于特定槽位类型+属性+子类型的组合只能有一个修改值,这确保了数据的一致性和同步的便利性。 动态修改与静态修改(数编表配置)不同,可以在运行时根据游戏逻辑动态增加、修改或移除。 在服务端和客户端都可以访问动态修改信息,服务端负责管理,客户端通过属性同步机制获取。

构造函数 ​

DynamicModification 双端 ​

csharp
public DynamicModification()

属性 ​

Key 双端 ​

csharp
public required DynamicModificationKey Key { get; set; }

修改的唯一标识符

Value 双端 ​

csharp
public double Value { get; set; }

修改值

Property 双端 ​

csharp
public IGameLink<GameDataUnitProperty> Property { get; }

属性链接(从Key中获取)

SubType 双端 ​

csharp
public PropertySubType SubType { get; }

属性子类型(从Key中获取)

SlotType 双端 ​

csharp
public ItemSlotType SlotType { get; }

槽位类型(从Key中获取)

HashKey 双端 ​

csharp
public int HashKey { get; }

生成哈希键,用于数据同步和云保存

备注

这个哈希值可以用于物品的同步属性以及云保存数据中

方法 ​

ToString 双端 ​

csharp
public override string ToString()

返回修改项的字符串表示

DynamicModificationKey 双端 ​

命名空间 GameCore.ItemSystem

csharp
public struct DynamicModificationKey : IEquatable<DynamicModificationKey>

动态修改的唯一标识符

  • SlotType — 槽位类型,指定该修改作用于哪个装备槽位
  • Property — 属性链接,指定该修改影响的单位属性
  • SubType — 属性子类型(如基础值、百分比加成等)
备注

DynamicModificationKey 用于唯一标识一个动态修改。 由槽位类型、属性和子类型三者组成,这三者的组合在一个物品上是唯一的。 此结构体实现为 record struct,提供了值相等性比较和不可变性。

构造函数 ​

DynamicModificationKey 双端 ​

csharp
public DynamicModificationKey(ItemSlotType SlotType, IGameLink<GameDataUnitProperty> Property, PropertySubType SubType)

动态修改的唯一标识符

  • SlotType — 槽位类型,指定该修改作用于哪个装备槽位
  • Property — 属性链接,指定该修改影响的单位属性
  • SubType — 属性子类型(如基础值、百分比加成等)
备注

DynamicModificationKey 用于唯一标识一个动态修改。 由槽位类型、属性和子类型三者组成,这三者的组合在一个物品上是唯一的。 此结构体实现为 record struct,提供了值相等性比较和不可变性。

属性 ​

SlotType 双端 ​

csharp
public ItemSlotType SlotType { get; set; }

槽位类型,指定该修改作用于哪个装备槽位

Property 双端 ​

csharp
public IGameLink<GameDataUnitProperty> Property { get; set; }

属性链接,指定该修改影响的单位属性

SubType 双端 ​

csharp
public PropertySubType SubType { get; set; }

属性子类型(如基础值、百分比加成等)

HashKey 双端 ​

csharp
public readonly int HashKey { get; }

生成哈希键,用于数据同步和云保存

备注

这个哈希值可以用于物品的同步属性以及云保存数据中

方法 ​

ToString 双端 ​

csharp
public override readonly string ToString()

返回键的字符串表示

operator != 双端 ​

csharp
public static bool operator !=(DynamicModificationKey left, DynamicModificationKey right)

operator == 双端 ​

csharp
public static bool operator ==(DynamicModificationKey left, DynamicModificationKey right)

GetHashCode 双端 ​

csharp
public override readonly int GetHashCode()

Equals 双端 ​

csharp
public override readonly bool Equals(object obj)

Equals 双端 ​

csharp
public readonly bool Equals(DynamicModificationKey other)

Deconstruct 双端 ​

csharp
public readonly void Deconstruct(out ItemSlotType SlotType, out IGameLink<GameDataUnitProperty> Property, out PropertySubType SubType)

DynamicModificationManager 仅服务端 ​

命名空间 GameCore.ItemSystem

csharp
public class DynamicModificationManager

动态修改管理器,管理物品的动态属性加成 每个槽位类型+属性+子类型的组合在物品上是唯一的

备注

DynamicModificationManager负责管理通过代码动态添加到物品上的属性修改。 它确保每个槽位类型+属性+子类型的组合在物品上是唯一的,便于数据同步和云保存。 管理器会根据物品的当前槽位状态自动应用或移除相应的修改。 仅在服务端使用,客户端通过属性同步机制获取属性值。

构造函数 ​

DynamicModificationManager 仅服务端 ​

csharp
public DynamicModificationManager()

属性 ​

CurrentSlotType 仅服务端 ​

csharp
public ItemSlotType? CurrentSlotType { get; set; }

当前槽位类型

AllModifications 仅服务端 ​

csharp
public IEnumerable<DynamicModification> AllModifications { get; }

获取所有动态修改

方法 ​

GetModifications 仅服务端 ​

csharp
public IEnumerable<DynamicModification> GetModifications(ItemSlotType slotType)

获取指定槽位类型的动态修改

  • slotType — 槽位类型

返回: 该槽位类型的所有动态修改

HasModification 仅服务端 ​

csharp
public bool HasModification(ItemSlotType slotType, IGameLink<GameDataUnitProperty> property, PropertySubType subType)

检查是否存在指定的动态修改

  • slotType — 槽位类型
  • property — 属性
  • subType — 属性子类型

返回: 是否存在该修改

GetModification 仅服务端 ​

csharp
public DynamicModification? GetModification(ItemSlotType slotType, IGameLink<GameDataUnitProperty> property, PropertySubType subType)

获取指定的动态修改

  • slotType — 槽位类型
  • property — 属性
  • subType — 属性子类型

返回: 动态修改,如果不存在则返回null

SetModification 仅服务端 ​

csharp
public void SetModification(ItemSlotType slotType, IGameLink<GameDataUnitProperty> property, double value, PropertySubType subType)

设置动态修改(如果存在则更新,不存在则创建)

  • slotType — 槽位类型
  • property — 要修改的属性
  • value — 修改值
  • subType — 属性子类型
备注

如果指定的槽位类型+属性+子类型组合已存在,会更新其值; 如果不存在,会创建新的修改项。 如果当前槽位类型与修改的槽位类型匹配,会自动应用修改。

AddModification 仅服务端 ​

csharp
public double AddModification(ItemSlotType slotType, IGameLink<GameDataUnitProperty> property, double value, PropertySubType subType)

增加动态修改值(如果存在则在原有基础上加值,否则设置值)

  • slotType — 槽位类型
  • property — 要修改的属性
  • value — 要增加的值
  • subType — 属性子类型

返回: 最终的值

备注

如果指定的槽位类型+属性+子类型组合已存在,会在原有值基础上增加指定值; 如果不存在,会创建新的修改项并设置为指定值。 如果当前槽位类型与修改的槽位类型匹配,会自动应用修改。

RemoveModification 仅服务端 ​

csharp
public bool RemoveModification(ItemSlotType slotType, IGameLink<GameDataUnitProperty> property, PropertySubType subType)

移除指定的动态修改

  • slotType — 槽位类型
  • property — 属性
  • subType — 属性子类型

返回: 是否成功移除

备注

如果当前槽位类型与修改的槽位类型匹配,会自动移除应用。

RemoveModificationsBySlot 仅服务端 ​

csharp
public void RemoveModificationsBySlot(ItemSlotType slotType)

移除指定槽位类型的所有动态修改

  • slotType — 槽位类型
备注

如果当前槽位类型与指定的槽位类型匹配,会自动移除应用。

ClearAll 仅服务端 ​

csharp
public void ClearAll()

清除所有动态修改

备注

如果当前有槽位类型,会先移除当前槽位的应用。

IPickUpItem 双端 ​

命名空间 GameCore.ItemSystem

csharp
public interface IPickUpItem

Defines an interface for items that can be picked up and added to inventories.

备注

This interface provides the contract for items that support pickup interactions with inventory systems. It includes validation to check if pickup is possible and methods to perform the actual pickup operation. Range checking is handled separately by the calling systems, allowing this interface to focus on item-specific pickup logic and inventory compatibility.

属性 ​

IsValid 双端 ​

csharp
public bool IsValid { get; }

Gets a value indicating whether this item is still valid and can participate in pickup operations.

备注

Invalid items (such as destroyed or disposed items) should not be available for pickup. This property allows the pickup system to filter out items that are no longer active.

方法 ​

CanPickUp 仅服务端 ​

csharp
CmdResult CanPickUp(InventoryManager manager, bool isRequest = false)

Determines whether the item can be picked up by the specified inventory manager.

  • manager — The inventory manager attempting to pick up the item.
  • isRequest — Whether this is a request operation from the player or a scipted pick order

返回: CmdResult.Ok if the item can be picked up.

备注

This method performs validation checks such as inventory space, item compatibility, and other pickup requirements. Range checking is explicitly ignored and should be handled by the calling system before invoking this method.

PickUp 仅服务端 ​

csharp
bool PickUp(InventoryManager manager, bool isRequest = false)

Attempts to pick up the item and add it to the specified inventory manager.

  • manager — The inventory manager that will receive the item.
  • isRequest — Whether this is a request operation (for validation) or an actual pickup.

返回: true if the pickup was successful; otherwise, false.

备注

This method performs the actual pickup operation, transferring the item to the inventory. Range checking is explicitly ignored and should be handled by the calling system. When is true, this may perform a dry-run validation without actually modifying the item or inventory state.

Item 双端 ​

命名空间 GameCore.ItemSystem

csharp
public abstract class Item : TagComponent, IAttachedObject, ISyncIdOwner, IDisposable, ICooldownOwner, IPropertyOwner, IDisplayInfo, IEventSender, IExecutionContext, IPropertyOwner<PropertyItem>, ISpendable, ITarget, ICommandTarget

所有物品的基类,挂载在单位上,管理品质、等级、分类和冷却。 具体子类包括 ItemMod(装备类物品,带属性修改和技能)、 ItemPickable(可拾取物品)和 ItemPowerUp(强化物品)等。

属性 ​

csharp
public IGameLink<GameDataItem> Link { get; }

Gets the game data link that defines this item's configuration and properties.

Cache 双端 ​

csharp
public GameDataItem Cache { get; }

Gets the cached game data for this item, providing access to configuration properties.

Unit 双端 ​

csharp
public Unit Unit { get; }

Gets the unit that owns this item.

备注

Items are always attached to units, which serve as their hosts and provide context for item functionality and interactions.

Quality 双端 ​

csharp
public uint Quality { get; set; }

Gets or sets the quality level of this item.

备注

Quality represents the tier or rarity of the item, affecting its properties and value. Changes to quality trigger quality change events and are synchronized between server and client. On the client side, this property can only be set internally through replication.

Level 双端 ​

csharp
public uint Level { get; set; }

Gets or sets the level of this item.

备注

Level represents the upgrade tier or enhancement level of the item, typically affecting its effectiveness and properties. Changes to level trigger level change events and are synchronized between server and client. On the client side, this property can only be set internally through replication.

Categories 双端 ​

csharp
public List<ItemCategory> Categories { get; }

Gets the list of categories this item belongs to.

备注

Categories are used for filtering, organizing, and applying rules to items. They help determine compatibility with inventories, abilities, and other game systems.

QualityConfiguration 双端 ​

csharp
public GameDataItemQuality? QualityConfiguration { get; }

获取当前物品品质对应的配置数据,用于确定品质相关的视觉表现和特效。

备注

此属性根据物品的Quality值从全局品质配置列表中查找对应的配置。 查找规则: 使用Quality值作为索引在ItemQualityList中查找 如果索引超出范围,返回列表中的最后一个配置 如果全局配置列表为空或null,返回null(物品将不显示品质特效) 此属性为只读计算属性,每次访问时动态获取最新的配置数据。

SyncId 仅客户端 ​

csharp
public new virtual int SyncId { get; set; }

Aggregator 双端 ​

csharp
public EventAggregator Aggregator { get; }

AggregatorWeakReference 双端 ​

csharp
public WeakReference<EventAggregator> AggregatorWeakReference { get; }

EffectCaster 双端 ​

csharp
protected virtual Entity EffectCaster { get; }

Position 双端 ​

csharp
public virtual ScenePoint Position { get; }

ApproachableTarget 双端 ​

csharp
public IApproachableTarget ApproachableTarget { get; }

InteractRadius 双端 ​

csharp
public float InteractRadius { get; }

PlacedItem 双端 ​

csharp
public PlacedItem? PlacedItem { get; set; }

IsChangingPosition 仅服务端 ​

csharp
public bool IsChangingPosition { get; }

方法 ​

ToString 双端 ​

csharp
public override string ToString()

Returns a string representation of this item including its type and friendly name.

返回: A formatted string describing this item.

HasCategory 双端 ​

csharp
public bool HasCategory(ItemCategory category)

Determines whether this item belongs to the specified category.

  • category — The category to check for.

返回: true if the item has the specified category; otherwise, false.

备注

This method provides a convenient way to check item compatibility and filtering rules based on category membership.

UpdateQualityActors 仅客户端 ​

csharp
public virtual void UpdateQualityActors()

更新物品的品质视觉特效,根据当前状态决定是否显示品质相关的Actor。

备注

此方法会根据物品当前状态自动管理品质特效的显示: 如果物品单位有效且存活,清除旧特效并创建新特效 如果物品单位无效或已死亡,仅清除特效 子类可以重写此方法来实现特定的品质特效逻辑(如ItemPickable只在地面时显示)。

ClearQualityActors 仅客户端 ​

csharp
protected void ClearQualityActors()

CreateQualityActors 仅客户端 ​

csharp
protected virtual void CreateQualityActors()

DisposeManaged 双端 ​

csharp
protected override void DisposeManaged()

ReplicateFromKeyValue 仅客户端 ​

csharp
public virtual bool ReplicateFromKeyValue(Enum propertyEnum, ReadOnlySpan<byte> value, bool isHostReplicating = false)

Dispose 双端 ​

csharp
protected override void Dispose(bool disposing)

Publish 双端 ​

csharp
public void Publish<TEvent>(TEvent eventToPublish)

GetPublisher 双端 ​

csharp
public Action<TEvent>? GetPublisher<TEvent>()

GetProperty 双端 ​

csharp
public TValue? GetProperty<TValue>(PropertyItem property)

CanBeSeen 双端 ​

csharp
public virtual bool CanBeSeen(Entity caster)

AngleTo 双端 ​

csharp
public Angle? AngleTo(ITarget target)

SetProperty 仅服务端 ​

csharp
public void SetProperty<TValue>(PropertyItem property, TValue value)

AddProperty 仅服务端 ​

csharp
public void AddProperty(PropertyItem property, double value)

事件 ​

OnPositionChangingStart 仅服务端 ​

csharp
public event Action<ITarget>? OnPositionChangingStart

OnPositionChangingEnd 仅服务端 ​

csharp
public event Action<ITarget>? OnPositionChangingEnd

字段 ​

QualityActors 仅客户端 ​

csharp
protected List<Actor>? QualityActors

存储当前激活的品质特效Actor列表,仅在客户端使用。

ItemExtension 双端 ​

命名空间 GameCore.ItemSystem

csharp
public static class ItemExtension

Provides extension methods for entity-based item component access.

备注

This class enables exclusive access to item components on entities, allowing the use of Entity.GetComponent<Item>() syntax to retrieve item components by their tag.

方法 ​

GetComponent 双端 ​

csharp
public static Item? GetComponent<TComponent>(this Entity entity) where TComponent : Item

Gets an item component of the specified type from the entity.

  • entity — The entity to search for the item component.

返回: The item component if found; otherwise, null.

备注

This extension method provides a convenient way to access item components on entities using generic type parameters and the standard component access pattern.

ItemMod 双端 ​

命名空间 GameCore.ItemSystem

csharp
public class ItemMod : ItemPickable, IDisplayInfo, IGameObject<GameDataItemMod>, IGameObject, IPropertyOwner<PropertyItemMod>, IPropertyOwner, ISyncIdOwner

Represents a modifier item that can be equipped and provides dynamic property modifications and abilities to the host unit.

备注

ItemMod is an advanced item type that can grant abilities, modify unit properties, and provide dynamic effects based on the equipped slot and current game state. Unlike static items, ItemMods have complex requirements, stack-based effects, and can enable/disable themselves based on conditions. They integrate with the modification system to provide property bonuses and state changes, and can grant temporary abilities while equipped. The item can have different effects based on which slot type it's equipped in, supporting versatile equipment systems.

构造函数 ​

ItemMod 双端 ​

csharp
public ItemMod(Unit entity, IGameLink<GameDataItemMod> link, bool initializeModificationData = true)

Initializes a new item mod instance with the specified configuration.

  • entity — The unit that will own this item mod.
  • link — The game data link defining this item mod's properties and effects.
  • initializeModificationData — Whether to immediately initialize modification managers for all slot types.
备注

This constructor sets up modification managers for each slot type defined in the item's configuration. If initializeModificationData is true, all managers are immediately initialized; otherwise, they are created but not activated until needed.

属性 ​

IsEnabled 双端 ​

csharp
public bool IsEnabled { get; }

Gets a value indicating whether this item mod is currently enabled and providing its effects.

备注

An enabled item mod actively applies its property modifications, state changes, and grants its ability. The enabled state depends on meeting all base requirements plus any additional item-specific requirements.

EffectCaster 双端 ​

csharp
protected override Entity EffectCaster { get; }

Gets the entity that serves as the caster for effects granted by this item mod.

备注

This property determines which entity is considered the source for abilities and effects granted by this item mod. It's important for targeting, ownership, and effect attribution.

MeetRequirement 双端 ​

csharp
public override bool MeetRequirement { get; }

Gets a value indicating whether this item mod meets all requirements for activation.

备注

Item mods can have additional requirements beyond basic item requirements, such as unit level, stats, or other conditions that must be met by the carrying unit.

Stack 双端 ​

csharp
public override uint Stack { get; }

Gets or sets the stack count for this item mod.

备注

Stack count affects the magnitude of property modifications and other effects. When the stack count changes, all modifications are updated to reflect the new values.

ModificationManagers 双端 ​

csharp
protected internal QuickDictionary<ItemSlotType, ModificationManager> ModificationManagers { get; }

ActiveAbility 双端 ​

csharp
public Ability? ActiveAbility { get; }

Gets the ability currently granted by this item mod, if any.

备注

Item mods can grant temporary abilities while equipped. The ability is automatically created when the item mod is properly equipped and meets requirements, and destroyed when conditions change. On the client side, this property reflects the server state.

ActiveModificationManager 双端 ​

csharp
public ModificationManager? ActiveModificationManager { get; }

Gets the modification manager currently active for this item mod based on its equipped slot.

备注

The active modification manager determines which set of property modifications and effects are currently being applied. This can change when the item is moved between different slots.

HostedActors 仅客户端 ​

csharp
protected List<Actor>? HostedActors { get; set; }
csharp
public new IGameLink<GameDataItemMod> Link { get; }

Cache 双端 ​

csharp
public new GameDataItemMod Cache { get; }

ModSeed 双端 ​

csharp
public SeedAccessor ModSeed { get; set; }

DynamicModifications 仅服务端 ​

csharp
public DynamicModificationManager DynamicModifications { get; }

动态修改管理器

备注

管理通过代码动态添加到物品上的属性修改。 每个槽位类型+属性+子类型的组合在物品上是唯一的。 仅在服务端使用,客户端通过属性同步机制获取属性值。

方法 ​

ReplicateFromKeyValue 仅客户端 ​

csharp
public override bool ReplicateFromKeyValue(Enum key, ReadOnlySpan<byte> value, bool isHostReplicating = false)

TestRequirement 双端 ​

csharp
public override bool TestRequirement(Unit unit)

Tests whether this item mod meets all requirements for the specified unit.

  • unit — The unit to test requirements against.

返回: True if the unit meets all requirements for this item mod; otherwise, false.

备注

This method checks both the base item requirements and any additional requirements specific to this item mod type, such as level, stats, or class restrictions.

GetModificationManager 双端 ​

csharp
public ModificationManager? GetModificationManager(ItemSlotType slotType)

Gets the modification manager for the specified slot type.

  • slotType — The slot type to get the modification manager for.

返回: The modification manager for the specified slot type, or null if not found.

备注

This method allows access to modification managers for specific slot types, which is useful for inspecting potential effects before equipping the item in different slots.

OnInternalAssigned 双端 ​

csharp
protected internal override void OnInternalAssigned(InventorySlot inventorySlot, ReasonItemAssign reason)

CreateSelfActors 仅客户端 ​

csharp
protected void CreateSelfActors()

物品本身是一种单位,因此它可能有自己的附属 Actor。 当物品被丢弃后,这些附属 Actor 需要被重新创建,以恢复物品的视觉表现。 参考 ClearSelfActors 方法的说明。

OnInternalDropped 双端 ​

csharp
protected internal override void OnInternalDropped(InventorySlot inventorySlot, ReasonItemDrop reason)

DynamicModificationHashLong 双端 ​

csharp
protected internal long DynamicModificationHashLong(DynamicModificationKey key)

HasDynamicModification 双端 ​

csharp
public bool HasDynamicModification(ItemSlotType slotType, IGameLink<GameDataUnitProperty> property, PropertySubType subType)

检查是否存在指定的动态修改(客户端版本)

  • slotType — 槽位类型,指定要检查哪个槽位的动态修改
  • property — 属性链接,指定要检查的单位属性
  • subType — 属性子类型(如基础值、百分比加成等)

返回: 如果存在指定的动态修改返回 true,否则返回 false

备注

客户端通过从服务端同步的属性数据来检查动态修改是否存在。 此方法会遍历所有同步的动态修改键来查找匹配项。 动态修改由槽位类型、属性和子类型三者共同唯一标识。

GetDynamicModification 双端 ​

csharp
public DynamicModification? GetDynamicModification(ItemSlotType slotType, IGameLink<GameDataUnitProperty> property, PropertySubType subType)

获取指定的动态修改(客户端版本)

  • slotType — 槽位类型,指定要获取哪个槽位的动态修改
  • property — 属性链接,指定要获取的单位属性
  • subType — 属性子类型(如基础值、百分比加成等)

返回: 如果找到匹配的动态修改,返回 DynamicModification 对象; 如果不存在则返回 null

备注

客户端通过从服务端同步的属性数据来获取动态修改信息。 此方法会遍历所有同步的动态修改键,找到匹配的键后获取对应的值。 动态修改由槽位类型、属性和子类型三者共同唯一标识。 返回的 DynamicModification 对象包含完整的修改信息,包括键和值。

GetDynamicModifications 双端 ​

csharp
public IEnumerable<DynamicModification> GetDynamicModifications(ItemSlotType slotType)

获取指定槽位类型的所有动态修改(客户端版本)

  • slotType — 槽位类型,指定要获取哪个槽位的所有动态修改

返回: 返回指定槽位的所有动态修改的枚举集合。 如果没有任何动态修改,返回空集合(不返回 null)

备注

客户端通过从服务端同步的属性数据来获取所有动态修改。 此方法会遍历所有同步的动态修改键,筛选出匹配指定槽位类型的所有修改。 返回的枚举集合可以用于遍历、统计或显示物品的所有动态属性加成。 此方法使用延迟执行(yield return),只在需要时才构建修改对象。

GetDynamicModificationKeys 仅客户端 ​

csharp
protected internal ProtoDynamicModificationKey[]? GetDynamicModificationKeys()

GetDynamicModificationValue 仅客户端 ​

csharp
protected internal double GetDynamicModificationValue(DynamicModificationKey key)

DisposeManaged 双端 ​

csharp
protected override void DisposeManaged()

GetProperty 双端 ​

csharp
public TValue? GetProperty<TValue>(PropertyItemMod property)

UpdateModifications 仅服务端 ​

csharp
public void UpdateModifications(bool forced = false)

Updates all modifications applied by this item mod based on current state.

  • forced — When true, forces all modification data to be re-evaluated, used for item level changes or state updates.
备注

This method refreshes the item mod's effects, including property modifications, state changes, and ability grants. It should be called whenever the item's context changes, such as when equipped, moved, or when the carrying unit's state changes. The forced parameter triggers a complete recalculation of all modification values.

SetDynamicModification 仅服务端 ​

csharp
public void SetDynamicModification(ItemSlotType slotType, IGameLink<GameDataUnitProperty> property, double value, PropertySubType subType)

设置动态修改(如果存在则更新,不存在则创建)

  • slotType — 槽位类型,指定该属性加成在哪种物品栏格子槽位下生效
  • property — 要修改的属性
  • value — 修改值,表示该属性的增加或减少量
  • subType — 属性子类型
备注

如果指定的槽位类型+属性+子类型组合已存在,会更新其值;如果不存在,会创建新的修改项。 此方法会自动同步到客户端,客户端可以通过相应的方法查询这些动态修改。 动态修改会影响装备该物品的单位的属性值,与物品的静态修改(数编表配置)叠加生效。

AddDynamicModification 仅服务端 ​

csharp
public double AddDynamicModification(ItemSlotType slotType, IGameLink<GameDataUnitProperty> property, double value, PropertySubType subType)

增加动态修改值(如果存在则在原有基础上加值,否则设置值)

  • slotType — 槽位类型,指定要修改哪个槽位的属性
  • property — 要修改的单位属性链接
  • value — 要增加的值,会与现有值相加
  • subType — 属性子类型(如基础值、百分比加成等)

返回: 返回增加后的最终值

备注

如果指定的动态修改已存在,会将传入的值与现有值相加;如果不存在,则直接设置该值。 此方法适用于累积型的属性加成,例如每次击杀敌人增加一定的属性值。 修改会自动同步到客户端。

RemoveDynamicModification 仅服务端 ​

csharp
public bool RemoveDynamicModification(ItemSlotType slotType, IGameLink<GameDataUnitProperty> property, PropertySubType subType)

移除指定的动态修改

  • slotType — 槽位类型,指定要移除哪个槽位的动态修改
  • property — 要移除的单位属性链接
  • subType — 属性子类型(如基础值、百分比加成等)

返回: 如果成功移除返回 true;如果指定的动态修改不存在返回 false

备注

移除后会自动同步到客户端。 移除动态修改不会影响物品的静态修改(数编表配置)。

RemoveDynamicModificationsBySlot 仅服务端 ​

csharp
public void RemoveDynamicModificationsBySlot(ItemSlotType slotType)

移除指定槽位类型的所有动态修改

  • slotType — 槽位类型,指定要清除哪个槽位的所有动态修改
备注

此方法会移除该物品上指定槽位的所有动态修改。 移除后会自动同步到客户端。 此操作不可撤销,请谨慎使用。

ClearDynamicModifications 仅服务端 ​

csharp
public void ClearDynamicModifications()

清除所有动态修改

备注

此方法会移除该物品上所有槽位的所有动态修改。 清除后会自动同步到客户端。 此操作不可撤销,请谨慎使用。

SetPropertyForDynamicModification 仅服务端 ​

csharp
protected internal void SetPropertyForDynamicModification(DynamicModification modification)

UpdatePropertyForDynamicModificationKeys 仅服务端 ​

csharp
protected internal void UpdatePropertyForDynamicModificationKeys()

SetProperty 仅服务端 ​

csharp
public void SetProperty<TValue>(PropertyItemMod property, TValue value)

AddProperty 仅服务端 ​

csharp
public void AddProperty(PropertyItemMod property, double value)

ItemPickable 双端 ​

命名空间 GameCore.ItemSystem

csharp
public class ItemPickable : Item, IGameObject<GameDataItemPickable>, IGameObject, IPickUpItem, ISpendable

属性 ​

Stack 双端 ​

csharp
public virtual uint Stack { get; set; }

CanStack 双端 ​

csharp
public virtual bool CanStack { get; }

AbsorbEnabled 双端 ​

csharp
public virtual bool AbsorbEnabled { get; }

MeetRequirement 双端 ​

csharp
public virtual bool MeetRequirement { get; }

Slot 双端 ​

csharp
public InventorySlot? Slot { get; set; }

SlotType 双端 ​

csharp
public ItemSlotType? SlotType { get; }

Carrier 双端 ​

csharp
public Unit? Carrier { get; }

Position 双端 ​

csharp
public override ScenePoint Position { get; }

StackMax 双端 ​

csharp
public uint? StackMax { get; }
csharp
public new IGameLink<GameDataItemPickable> Link { get; }

Cache 双端 ​

csharp
public new GameDataItemPickable Cache { get; }

ForceProlongedByChannelCount 仅服务端 ​

csharp
protected internal int ForceProlongedByChannelCount { get; set; }

Force the item to be prolonged by channel

备注

This is used to prevent the item from being destroyed by KillOnDepleted when it is prolonged by channel

方法 ​

AddStack 双端 ​

csharp
public uint AddStack(int stack)

CanAbsorb 双端 ​

csharp
public virtual bool CanAbsorb(ItemPickable inItem)

Check if the item can absorb the stack of another item

  • inItem — Item to be absorbed

返回:

Absorb 双端 ​

csharp
public uint Absorb(ItemPickable inItem)

Absorb the stack of another item

  • inItem — Item to be absorbed

返回: The amount of stack absorbed

TestRequirement 双端 ​

csharp
public virtual bool TestRequirement(Unit _)

CanBeSeen 双端 ​

csharp
public override bool CanBeSeen(Entity caster)

Drop 双端 ​

csharp
public bool Drop(ReasonItemDrop reason = ReasonItemDrop.DropToGround, InventorySlot? swapSource = null)

OnInternalAssigned 双端 ​

csharp
protected internal virtual void OnInternalAssigned(InventorySlot inventorySlot, ReasonItemAssign reason)

OnInternalDropped 双端 ​

csharp
protected internal virtual void OnInternalDropped(InventorySlot inventorySlot, ReasonItemDrop reason)

UpdateQualityActors 仅客户端 ​

csharp
public override void UpdateQualityActors()

重写品质特效更新逻辑,仅在物品掉落在地面时显示品质特效。

备注

可拾取物品的品质特效显示规则: 物品在地面时(Carrier 为 null):显示品质特效 物品在背包中时:不显示品质特效(清除所有特效) 物品单位死亡或无效时:清除所有特效 这种设计确保玩家只在需要识别地面物品品质时才看到特效,避免背包中的物品产生不必要的视觉干扰。

ReplicateFromKeyValue 仅客户端 ​

csharp
public override bool ReplicateFromKeyValue(Enum propertyEnum, ReadOnlySpan<byte> value, bool isHostReplicating = false)

Dispose 双端 ​

csharp
protected override void Dispose(bool disposing)

CanPickUp 双端 ​

csharp
public CmdResult CanPickUp(InventoryManager manager, bool isRequest = false)

CanBeAbsorbed 双端 ​

csharp
public bool CanBeAbsorbed(InventoryManager manager)

PickUp 双端 ​

csharp
public bool PickUp(InventoryManager manager, bool isRequest)

TryKillOnDepleted 仅服务端 ​

csharp
protected internal void TryKillOnDepleted()

事件 ​

Assigned 双端 ​

csharp
public event EventHandler<ItemAssignEventArgs>? Assigned

Dropped 双端 ​

csharp
public event EventHandler<ItemDropEventArgs>? Dropped

ItemPowerUp 双端 ​

命名空间 GameCore.ItemSystem

csharp
public class ItemPowerUp : Item, IGameObject<GameDataItemPowerUp>, IGameObject, IPickUpItem

属性 ​

csharp
public new IGameLink<GameDataItemPowerUp> Link { get; }

Cache 双端 ​

csharp
public new GameDataItemPowerUp Cache { get; }

Used 仅服务端 ​

csharp
public bool Used { get; }

方法 ​

CanPickUp 双端 ​

csharp
public CmdResult CanPickUp(InventoryManager manager, bool isRequest = false)

PickUp 仅服务端 ​

csharp
public bool PickUp(InventoryManager manager, bool isRequest = false)

GameDataItem 双端 ​

命名空间 GameCore.ItemSystem.Data

csharp
public abstract class GameDataItem : GameDataCategory<GameDataItem>, IAttachedData<GameDataItem>, IAttachedData, IGameData<GameDataItem>, IGameData, IDisplayInfoData, IEventSender, IGameDataCategory<GameDataItem>

Represents the base data class for item configurations, defining common properties and creation methods for all item types.

备注

This abstract class provides the foundation for all item data types in the game, including display information, unit associations, quality and level settings, and filtering capabilities. It defines the common interface for creating item instances and their associated units in the game world.

构造函数 ​

GameDataItem 双端 ​

csharp
public GameDataItem(GameLink<GameDataItem, GameDataItem> link)

GameDataItem 双端 ​

csharp
public GameDataItem(IGameLink<GameDataItem> link)

属性 ​

DisplayName 双端 ​

csharp
public LocalizedString? DisplayName { get; set; }

Gets or sets the localized display name for this item.

备注

This name is shown to players in the user interface and supports localization for different languages and regions.

Description 双端 ​

csharp
public LocalizedString? Description { get; set; }

Gets or sets the localized description text for this item.

备注

This description provides detailed information about the item's purpose, effects, and usage. It supports localization for different languages and regions.

Icon 双端 ​

csharp
public Icon? Icon { get; set; }

Gets or sets the icon used to represent this item in the user interface.

备注

The icon provides a visual representation of the item for display in inventories, tooltips, and other UI elements.

Unit 双端 ​

csharp
public required IGameLink<GameDataUnit> Unit { get; set; }

Gets or sets the unit data that defines the physical representation of this item in the game world.

备注

Every item is associated with a unit that provides its 3D model, collision, animations, and other physical properties when the item exists as an object in the game world.

Quality 双端 ​

csharp
public uint Quality { get; set; }

Gets or sets the default quality level for items created from this data.

备注

Quality represents the tier or rarity of the item, affecting its properties and value. Individual item instances can have their quality modified after creation.

Level 双端 ​

csharp
public uint Level { get; set; }

Gets or sets the default level for items created from this data.

备注

Level represents the upgrade tier or enhancement level of the item. Individual item instances can have their level modified after creation.

Filter 双端 ​

csharp
public TargetFilterComplex Filter { get; set; }

Gets or sets the targeting filters that determine which entities can interact with this item.

备注

These filters control pickup eligibility, usage restrictions, and other interaction rules based on entity properties, states, and other criteria.

SyncType 双端 ​

csharp
public SyncType SyncType { get; set; }

Categories 双端 ​

csharp
public List<ItemCategory> Categories { get; set; }

AggregatorWeakReference 双端 ​

csharp
public WeakReference<EventAggregator> AggregatorWeakReference { get; }

方法 ​

ReplicateItem 仅客户端 ​

csharp
protected virtual Item ReplicateItem(Unit unit, int? syncId)

CreateItem 双端 ​

csharp
protected abstract Item CreateItem(Unit unit)

CreateItem 仅服务端 ​

csharp
public Item CreateItem(ScenePoint scene, Player? player = null)

Creates an item instance at the specified location in the game world.

  • scene — The scene position where the item should be created.
  • player — The player that will own the item, or null to use the default player.

返回: A new item instance attached to a unit at the specified location.

备注

This method creates both the physical unit representation and the item component, providing a complete item that exists in the game world and can be interacted with.

CreateItemUnit 仅服务端 ​

csharp
protected Unit CreateItemUnit(ScenePoint scene, Player? player)

Creates the unit that will represent this item in the game world.

  • scene — The scene position where the unit should be created.
  • player — The player that will own the unit, or null to use the default player.

返回: A new unit instance configured according to this item's unit data.

备注

This method creates the physical representation of the item as a unit in the game world, which provides 3D model, collision, and other physical properties.

GameDataItemMod 双端 ​

命名空间 GameCore.ItemSystem.Data

csharp
public class GameDataItemMod : GameDataItemPickable, IResponseOwnerData, IGameData<GameDataItemMod>, IGameData

装备/模组类物品数据。可修改单位在指定槽位上的属性。

构造函数 ​

GameDataItemMod 双端 ​

csharp
public GameDataItemMod(GameLink<GameDataItem, GameDataItemMod> link)

GameDataItemMod 双端 ​

csharp
public GameDataItemMod(IGameLink<GameDataItemMod> link)

属性 ​

Modifications 双端 ​

csharp
public QuickDictionary<ItemSlotType, ItemUnitModificationData> Modifications { get; set; }

各槽位上的属性修改配置。键为槽位类型,值为该槽位的属性加成/修改数据。

Requirements 双端 ​

csharp
public UnitPropertyRequirements Requirements { get; set; }

装备此物品所需的单位属性条件(如力量、等级等)。

Responses 双端 ​

csharp
public List<IGameLink<GameDataResponse>?>? Responses { get; set; }
csharp
public new IGameLink<GameDataItemMod> Link { get; }

方法 ​

CreateItem 双端 ​

csharp
protected override Item CreateItem(Unit unit)

ReplicateItem 仅客户端 ​

csharp
protected override Item ReplicateItem(Unit unit, int? syncId)

GameDataItemPickable 双端 ​

命名空间 GameCore.ItemSystem.Data

csharp
public class GameDataItemPickable : GameDataItem, IGameData<GameDataItemPickable>, IGameData

可拾取物品数据。定义堆叠、丢弃、出售等行为。

构造函数 ​

GameDataItemPickable 双端 ​

csharp
public GameDataItemPickable(GameLink<GameDataItem, GameDataItemPickable> link)

GameDataItemPickable 双端 ​

csharp
public GameDataItemPickable(IGameLink<GameDataItemPickable> link)

属性 ​

StackStart 双端 ​

csharp
public uint StackStart { get; set; }

拾取时的初始堆叠数量。

StackMax 双端 ​

csharp
public uint? StackMax { get; set; }

最大堆叠数量。为空表示不限制。

CanDrop 双端 ​

csharp
public bool CanDrop { get; set; }

是否允许丢弃到地面。

CanSell 双端 ​

csharp
public bool CanSell { get; set; }

是否允许出售给商店。

RemoveOnDrop 双端 ​

csharp
public bool RemoveOnDrop { get; set; }

丢弃后是否从背包中移除(不生成地面物品)。

CanStack 双端 ​

csharp
public bool CanStack { get; set; }

是否可与其他同种物品堆叠。

CanAbsorb 双端 ​

csharp
public bool CanAbsorb { get; set; }

堆叠时是否自动吸收另一物品的堆叠数量。

KillOnDepleted 双端 ​

csharp
public bool KillOnDepleted { get; set; }

堆叠数量耗尽时是否销毁该物品实例。

csharp
public new IGameLink<GameDataItemPickable> Link { get; }

方法 ​

CreateItem 双端 ​

csharp
protected override Item CreateItem(Unit unit)

ReplicateItem 仅客户端 ​

csharp
protected override Item ReplicateItem(Unit unit, int? syncId)

GameDataItemPowerUp 双端 ​

命名空间 GameCore.ItemSystem.Data

csharp
public class GameDataItemPowerUp : GameDataItem, IGameData<GameDataItemPowerUp>, IGameData

增益类消耗品数据。使用后对目标施加效果,如药水、卷轴等。

构造函数 ​

GameDataItemPowerUp 双端 ​

csharp
public GameDataItemPowerUp(GameLink<GameDataItem, GameDataItemPowerUp> link)

GameDataItemPowerUp 双端 ​

csharp
public GameDataItemPowerUp(IGameLink<GameDataItemPowerUp> link)

属性 ​

Effect 双端 ​

csharp
public IGameLink<GameDataEffect>? Effect { get; set; }

使用后施加的效果。通常为目标单位施加增益或治疗。

KillOnPowerUp 双端 ​

csharp
public bool KillOnPowerUp { get; set; }

使用后是否消耗并移除该物品。

csharp
public new IGameLink<GameDataItemPowerUp> Link { get; }

方法 ​

CreateItem 双端 ​

csharp
protected override Item CreateItem(Unit unit)

GameDataItemQuality 双端 ​

命名空间 GameCore.ItemSystem.Data

csharp
public class GameDataItemQuality : GameDataCategory<GameDataItemQuality>, IGameDataCategory<GameDataItemQuality>, IGameData<GameDataItemQuality>, IGameData

定义物品品质的视觉表现和特效配置,包括颜色、图标装饰和地面特效等品质相关的显示属性。

备注

物品品质系统通过此配置类为不同品质等级的物品提供统一的视觉标识。品质配置影响物品在UI中的显示效果, 包括名称颜色、图标装饰以及物品掉落在地面时的视觉特效。高品质物品通常配置更加醒目的视觉效果以突出其稀有性。

构造函数 ​

GameDataItemQuality 双端 ​

csharp
public GameDataItemQuality(GameLink<GameDataItemQuality, GameDataItemQuality> link)

GameDataItemQuality 双端 ​

csharp
public GameDataItemQuality(IGameLink<GameDataItemQuality> link)

属性 ​

Color 双端 ​

csharp
public Color Color { get; set; }

获取或设置此品质对应的显示颜色,用于物品名称和相关UI元素的着色。

备注

此颜色将应用于物品名称文本、品质标识等UI元素,为玩家提供直观的品质识别。 通常低品质使用灰白色,高品质使用金色、紫色等醒目颜色。

BackgroundImage 双端 ​

csharp
public Icon BackgroundImage { get; set; }

获取或设置此品质的背景装饰图标,用于物品图标的背景层显示。

备注

背景图标通常显示在物品图标的后方,为不同品质提供视觉区分。 可以是简单的色彩背景、纹理图案或装饰性边框等。

BorderImage 双端 ​

csharp
public Icon BorderImage { get; set; }

获取或设置此品质的边框装饰图标,用于物品图标的边框层显示。

备注

边框图标显示在物品图标的最前层,通常用于突出显示高品质物品。 可以是发光效果、华丽边框或特殊形状的装饰框等。

ActorArray 双端 ​

csharp
public List<IGameLink<GameDataActor>>? ActorArray { get; set; }

获取或设置物品掉落在地面时的附属视觉特效Actor列表,用于提供品质相关的地面显示效果。

备注

这些Actor通常包含粒子系统、光效、动画等视觉组件,在物品作为地面对象存在时自动激活。 不同品质的物品可以配置不同强度和样式的特效: 普通品质:无特效或简单光点 稀有品质:彩色光环或闪烁效果 史诗品质:华丽光柱或旋转特效 传说品质:复杂粒子系统和动态光效 这些特效有助于玩家在游戏世界中快速识别和定位高价值物品。

ProtoDynamicModificationKey 双端 ​

命名空间 GameCore.ItemSystem.Protocol

csharp
public struct ProtoDynamicModificationKey : IProtocolServerTransient<ProtoDynamicModificationKey>, IBytesReplicableUnmanaged<ProtoDynamicModificationKey>, IBytesReplicable<ProtoDynamicModificationKey>, IProtocolServerTransient, IGameClass, IEquatable<ProtoDynamicModificationKey>

DynamicModificationKey的协议表示,为可序列化的值类型

  • SlotType — 槽位类型
  • ProtoProperty — 属性链接
  • SubType — 属性子类型

构造函数 ​

ProtoDynamicModificationKey 双端 ​

csharp
public ProtoDynamicModificationKey(ItemSlotType SlotType, ProtoIGameLink<GameDataUnitProperty> ProtoProperty, ProtoIExtendableEnum<PropertySubType> SubType)

DynamicModificationKey的协议表示,为可序列化的值类型

  • SlotType — 槽位类型
  • ProtoProperty — 属性链接
  • SubType — 属性子类型

属性 ​

SlotType 双端 ​

csharp
public ItemSlotType SlotType { get; set; }

槽位类型

ProtoProperty 双端 ​

csharp
public ProtoIGameLink<GameDataUnitProperty> ProtoProperty { get; set; }

属性链接

SubType 双端 ​

csharp
public ProtoIExtendableEnum<PropertySubType> SubType { get; set; }

属性子类型

DynamicModificationKey 双端 ​

csharp
public readonly DynamicModificationKey? DynamicModificationKey { get; }

HashKey 双端 ​

csharp
public readonly int HashKey { get; }

方法 ​

implicit operator 双端 ​

csharp
public static DynamicModificationKey? implicit operator(ProtoDynamicModificationKey key)

implicit operator 双端 ​

csharp
public static ProtoDynamicModificationKey implicit operator(DynamicModificationKey key)

Handle 仅客户端 ​

csharp
public void Handle()

ToString 双端 ​

csharp
public override readonly string ToString()

operator != 双端 ​

csharp
public static bool operator !=(ProtoDynamicModificationKey left, ProtoDynamicModificationKey right)

operator == 双端 ​

csharp
public static bool operator ==(ProtoDynamicModificationKey left, ProtoDynamicModificationKey right)

GetHashCode 双端 ​

csharp
public override readonly int GetHashCode()

Equals 双端 ​

csharp
public override readonly bool Equals(object obj)

Equals 双端 ​

csharp
public readonly bool Equals(ProtoDynamicModificationKey other)

Deconstruct 双端 ​

csharp
public readonly void Deconstruct(out ItemSlotType SlotType, out ProtoIGameLink<GameDataUnitProperty> ProtoProperty, out ProtoIExtendableEnum<PropertySubType> SubType)

ItemAssignEventArgs 双端 ​

命名空间 GameCore.ItemSystem.Struct

csharp
public record ItemAssignEventArgs

构造函数 ​

ItemAssignEventArgs 双端 ​

csharp
public ItemAssignEventArgs(ItemPickable Item, InventorySlot Slot, ReasonItemAssign Reason)

ItemAssignEventArgs 双端 ​

csharp
protected ItemAssignEventArgs(ItemAssignEventArgs original)

属性 ​

EqualityContract 双端 ​

csharp
protected virtual Type EqualityContract { get; }

Item 双端 ​

csharp
public ItemPickable Item { get; init; }

Slot 双端 ​

csharp
public InventorySlot Slot { get; init; }

Reason 双端 ​

csharp
public ReasonItemAssign Reason { get; init; }

方法 ​

ToString 双端 ​

csharp
public override string ToString()

PrintMembers 双端 ​

csharp
protected virtual bool PrintMembers(StringBuilder builder)

GetHashCode 双端 ​

csharp
public override int GetHashCode()

Equals 双端 ​

csharp
public virtual bool Equals(ItemAssignEventArgs? other)

Deconstruct 双端 ​

csharp
public void Deconstruct(out ItemPickable Item, out InventorySlot Slot, out ReasonItemAssign Reason)

ItemDropEventArgs 双端 ​

命名空间 GameCore.ItemSystem.Struct

csharp
public record ItemDropEventArgs

构造函数 ​

ItemDropEventArgs 双端 ​

csharp
public ItemDropEventArgs(ItemPickable Item, InventorySlot Slot, ReasonItemDrop Reason)

ItemDropEventArgs 双端 ​

csharp
protected ItemDropEventArgs(ItemDropEventArgs original)

属性 ​

EqualityContract 双端 ​

csharp
protected virtual Type EqualityContract { get; }

Item 双端 ​

csharp
public ItemPickable Item { get; init; }

Slot 双端 ​

csharp
public InventorySlot Slot { get; init; }

Reason 双端 ​

csharp
public ReasonItemDrop Reason { get; init; }

方法 ​

ToString 双端 ​

csharp
public override string ToString()

PrintMembers 双端 ​

csharp
protected virtual bool PrintMembers(StringBuilder builder)

GetHashCode 双端 ​

csharp
public override int GetHashCode()

Equals 双端 ​

csharp
public virtual bool Equals(ItemDropEventArgs? other)

Deconstruct 双端 ​

csharp
public void Deconstruct(out ItemPickable Item, out InventorySlot Slot, out ReasonItemDrop Reason)