Skip to content

GameCore.VitalSystem ​

Healing 双端 ​

命名空间 GameCore.VitalSystem

csharp
public class Healing

治疗实例,承载一次治疗的当前值、原始值、暴击标记等信息。 在治疗流程中可被公式修改。与 Damage 对称。

构造函数 ​

Healing 仅客户端 ​

csharp
public Healing(double origin, IGameLink<GameDataEffectUnitModifyVital> effectLink, IGameLink<GameDataVital> vitalLink)

Healing 仅服务端 ​

csharp
public Healing(double origin, EffectUnitModifyVital effect, Vital vital)

属性 ​

Current 双端 ​

csharp
public double Current { get; set; }

Origin 双端 ​

csharp
public double Origin { get; }

IsCritical 双端 ​

csharp
public bool IsCritical { get; set; }
csharp
public IGameLink<GameDataEffectUnitModifyVital> EffectLink { get; init; }

VitalData 双端 ​

csharp
public GameDataVital? VitalData { get; init; }

Caster 双端 ​

csharp
public Entity? Caster { get; init; }

CasterPlayer 双端 ​

csharp
public Player CasterPlayer { get; init; }

Target 双端 ​

csharp
public Entity? Target { get; init; }

TargetScenePoint 仅客户端 ​

csharp
public ScenePoint TargetScenePoint { get; init; }

Vital 仅服务端 ​

csharp
public Vital Vital { get; }

Effect 仅服务端 ​

csharp
public EffectUnitModifyVital Effect { get; }

方法 ​

ToString 双端 ​

csharp
public override string? ToString()

Vital 双端 ​

命名空间 GameCore.VitalSystem

csharp
public class Vital : TagComponent, IThinker, ITickFinalizer

单位的动态属性(如生命值、法力值、能量等),拥有当前值、最大值和回复速率。 值自动钳制在有效范围内,回复通过 IThinker 每帧自动应用。 作为 TagComponent 实现,每个单位的每种属性类型只有一个实例。

构造函数 ​

Vital 双端 ​

csharp
public Vital(Entity host, IGameLink<GameDataVital> vitalData)
  • host — The entity that owns this vital property.
  • vitalData — The game data link that defines this vital's configuration.

属性 ​

Cache 双端 ​

csharp
public GameDataVital Cache { get; }

Gets the game data configuration for this vital property.

备注

The vital data contains the vital type (Current) and the maximum value property reference (Max). The maximum value may be influenced by various factors such as level, equipment, buffs, and other modifiers. The actual maximum value is calculated dynamically through the unit property system.

PropertyMax 双端 ​

csharp
public IGameLink<GameDataUnitProperty> PropertyMax { get; }

Gets the game data link that defines how the maximum value of this vital is calculated.

备注

This is a convenience property that accesses the Max property from Cache.

Current 双端 ​

csharp
public double Current { get; }

Gets the current value of this vital property.

备注

This value represents the actual usable amount of the vital resource. It will always be between 0 and the maximum value, unless modifications are pending finalization.

Max 双端 ​

csharp
public double Max { get; }

Gets the maximum value of this vital property.

备注

The maximum value is calculated dynamically based on the entity's properties, level, equipment, and other modifiers. This value may change as the entity's stats change.

Regen 双端 ​

csharp
public GameRate Regen { get; }

Gets or sets the regeneration rate of this vital property.

备注

Positive values indicate regeneration (healing over time), while negative values indicate degeneration (damage over time). The actual regeneration is applied each game tick.

方法 ​

Think 双端 ​

csharp
public void Think(int delta)

Processes the regeneration logic for this vital on each game tick.

  • delta — The time delta since the last tick (currently unused).
备注

This method is called automatically by the game's thinking system. It applies regeneration and schedules finalization to ensure values stay within valid ranges. The method only processes regeneration on the server side.

TickFinalizer 双端 ​

csharp
public void TickFinalizer()

Finalizes vital values by clamping them within valid ranges and updating thinking status.

备注

This method ensures that the current value stays between 0 and the maximum value. It also determines whether this vital needs to continue thinking based on its regeneration rate and current value. This method is called automatically at the end of each tick.

DisposeManaged 双端 ​

csharp
protected override void DisposeManaged()

Releases managed resources used by this vital.

备注

This method is called when the vital is being disposed. It cleans up references to the unit property system and calls the base disposal method.

ToString 双端 ​

csharp
public override string? ToString()

Returns a string representation of this vital showing its current state.

返回: A formatted string containing the vital's tag, current/max values, regeneration rate (if non-zero), and sync ID.

Modify 仅服务端 ​

csharp
public void Modify(double amount, Property prop = Property.Current, bool doFinalize = true)

Modifies a vital property by adding the specified amount to its current value.

  • amount — The amount to add to the property (can be negative for reduction).
  • prop — The specific vital property to modify.
  • doFinalize — If true, clamp immediately; if false, defer to end of tick.

SetMax 仅服务端 ​

csharp
public void SetMax(double amount, PropertySubType subType, bool doFinalize = true)

Sets the maximum value of this vital property.

  • amount — The maximum value to set.
  • subType — The sub-type of the property to set.
  • doFinalize — If true, clamp immediately; if false, defer to end of tick.

Set 仅服务端 ​

csharp
public void Set(double amount, Property prop = Property.Current, bool doFinalize = true)

Sets a vital property to the specified absolute value.

  • amount — The absolute value to set the property to.
  • prop — The specific vital property to modify.
  • doFinalize — If true, clamp immediately; if false, defer to end of tick.

GameDataVital 双端 ​

命名空间 GameCore.VitalSystem.Data

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

表示活力值系统的数据配置,定义单位的活力值属性。活力是生命值、法力值、怒气值等拥有当前值/最大值的属性的统称。

备注

此类用于配置单位的活力值相关属性,包括当前活力值类型和最大活力值的引用。 它作为活力值系统的数据基础,允许灵活地定义不同单位的活力值特征。

构造函数 ​

GameDataVital 双端 ​

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

GameDataVital 双端 ​

csharp
public GameDataVital(IGameLink<GameDataVital> link)

属性 ​

Current 双端 ​

csharp
public required PropertyVital Current { get; set; }

获取或设置当前活力值属性的类型

备注

定义此活力值数据所对应的具体属性类型,例如生命值、魔法值等。 这个属性决定了活力值组件将管理哪种类型的数值。

Max 双端 ​

csharp
public required IGameLink<GameDataUnitProperty> Max { get; set; }

获取或设置最大活力值属性的数据链接

备注

引用定义最大活力值的单位属性数据。这个链接指向具体的单位属性配置, 允许系统动态获取和计算单位的最大活力值上限。

ClampCurrent 双端 ​

csharp
public bool ClampCurrent { get; set; }

是否在结算时将当前值限制在 0 到最大值之间。

备注

默认开启以保持生命值、法力值等常规 Vital 的既有行为。关闭后,当前值允许低于 0 或高于最大值。

HealingFloatingText 双端 ​

csharp
public IGameLink<GameDataFloatingText>? HealingFloatingText { get; set; }

The floating text to display when this damage is notified to the player when the player deals this damage type. If not set, the user can still capture the damage notification event and display the floating text manually.

HealingFloatingTextCritical 双端 ​

csharp
public IGameLink<GameDataFloatingText>? HealingFloatingTextCritical { get; set; }

The floating text to display when this damage is notified to the player when the player deals critical damage of this type. If not set, the game system will use the default critical damage floating text style.

HealingCustomFormular 仅服务端 ​

csharp
public Func<Healing, double>? HealingCustomFormular { get; set; }

自定义治疗计算公式

备注

一旦设置,此函数将在计算治疗效果时被调用,以确定实际的治疗数值。

HealingCustomFormularIsCritical 仅服务端 ​

csharp
public Func<Healing, bool>? HealingCustomFormularIsCritical { get; set; }

自定义治疗暴击判定公式

备注

一旦设置,此函数将在计算治疗效果时被调用,以确定治疗是否为暴击。 已经被设置为暴击的治疗效果将不会再次调用此函数。

HealingNotificationPredicate 仅服务端 ​

csharp
public Func<Player, Healing, bool>? HealingNotificationPredicate { get; set; }

是否要向特定玩家客户端发送此活力值类型的治疗事件通知。

备注

委托参数:Player 为目标玩家,判断其客户端是否应收到通知;Healing 为治疗实例,包含治疗量、施法者、目标等完整信息。

ProtoHealingNotification 双端 ​

命名空间 GameCore.VitalSystem.Protocol

csharp
public struct ProtoHealingNotification : IProtocolServerTransient<ProtoHealingNotification>, IBytesReplicableUnmanaged<ProtoHealingNotification>, IBytesReplicable<ProtoHealingNotification>, IProtocolServerTransient, IGameClass

属性 ​

ProtoCaster 双端 ​

csharp
public ProtoEntity ProtoCaster { get; set; }

ProtoCasterPlayer 双端 ​

csharp
public ProtoPlayer ProtoCasterPlayer { get; set; }

ProtoTarget 双端 ​

csharp
public ProtoEntity ProtoTarget { get; set; }

ProtoTargetScenePoint 双端 ​

csharp
public ProtoScenePoint ProtoTargetScenePoint { get; set; }

ProtoEffect 双端 ​

csharp
public ProtoIGameLink<GameDataEffectUnitModifyVital> ProtoEffect { get; set; }

ProtoVital 双端 ​

csharp
public ProtoIGameLink<GameDataVital> ProtoVital { get; set; }

PropertyVital 双端 ​

csharp
public readonly PropertyVital PropertyVital { get; }

HealAmount 双端 ​

csharp
public double HealAmount { get; set; }

Origin 双端 ​

csharp
public double Origin { get; set; }

IsCritical 双端 ​

csharp
public bool IsCritical { get; set; }

方法 ​

Handle 仅客户端 ​

csharp
public readonly void Handle()