Add a sleep delay to Nocturine (NewStatusEffect version) (#40231)
* Initial commit * Minor fix * Why is this uncommented here? Hmmm * No wait this can't be here, oops * Do better time * Also guidebook * Review changes * Add rejuvination, fix mispredicts
This commit is contained in:
@@ -19,6 +19,12 @@ public sealed partial class ModifyStatusEffect : EntityEffect
|
||||
[DataField]
|
||||
public float Time = 2.0f;
|
||||
|
||||
/// <summary>
|
||||
/// Delay before the effect starts. If another effect is added with a shorter delay, it takes precedence.
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public float Delay = 0f;
|
||||
|
||||
/// <remarks>
|
||||
/// true - refresh status effect time (update to greater value), false - accumulate status effect time.
|
||||
/// </remarks>
|
||||
@@ -45,22 +51,30 @@ public sealed partial class ModifyStatusEffect : EntityEffect
|
||||
{
|
||||
case StatusEffectMetabolismType.Add:
|
||||
if (Refresh)
|
||||
statusSys.TryUpdateStatusEffectDuration(args.TargetEntity, EffectProto, duration);
|
||||
statusSys.TryUpdateStatusEffectDuration(args.TargetEntity, EffectProto, duration, Delay > 0 ? TimeSpan.FromSeconds(Delay) : null);
|
||||
else
|
||||
statusSys.TryAddStatusEffectDuration(args.TargetEntity, EffectProto, duration);
|
||||
statusSys.TryAddStatusEffectDuration(args.TargetEntity, EffectProto, duration, Delay > 0 ? TimeSpan.FromSeconds(Delay) : null);
|
||||
break;
|
||||
case StatusEffectMetabolismType.Remove:
|
||||
statusSys.TryAddTime(args.TargetEntity, EffectProto, -duration);
|
||||
break;
|
||||
case StatusEffectMetabolismType.Set:
|
||||
statusSys.TrySetStatusEffectDuration(args.TargetEntity, EffectProto, duration);
|
||||
statusSys.TrySetStatusEffectDuration(args.TargetEntity, EffectProto, duration, TimeSpan.FromSeconds(Delay));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override string? ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys)
|
||||
=> Loc.GetString(
|
||||
protected override string? ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys) =>
|
||||
Delay > 0
|
||||
? Loc.GetString(
|
||||
"reagent-effect-guidebook-status-effect-delay",
|
||||
("chance", Probability),
|
||||
("type", Type),
|
||||
("time", Time),
|
||||
("key", prototype.Index(EffectProto).Name),
|
||||
("delay", Delay))
|
||||
: Loc.GetString(
|
||||
"reagent-effect-guidebook-status-effect",
|
||||
("chance", Probability),
|
||||
("type", Type),
|
||||
|
||||
Reference in New Issue
Block a user