29 lines
1.2 KiB
C#
29 lines
1.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using RobotAndDonkey.Game.Data;
|
|
using RobotAndDonkey.Game.Execution;
|
|
using RobotAndDonkey.Game.Execution.Results;
|
|
using RobotAndDonkey.Game.GameState;
|
|
using RobotAndDonkey.Game.Intents;
|
|
|
|
namespace RobotAndDonkey.Game.Modifiers;
|
|
|
|
public record PestModifier(EModifierDuration Duration) : Modifier(EModifierKind.Robot, EModifierId.Pest, Duration)
|
|
{
|
|
protected override PestModifier CreateInstance() => new(Duration);
|
|
|
|
public override void Before(Guid requestId, ReadOnlySpan<Intent> intents, CoreLoop coreLoop, Entity owner, List<Intent> newIntents, List<Result> results)
|
|
{
|
|
foreach (var intent in intents)
|
|
{
|
|
if (intent is ModifyCurrency { Delta.Delivery: > 0 } modifyCurrency)
|
|
{
|
|
var original = modifyCurrency.Delta;
|
|
var reduced = (int)MathF.Floor(original.Delivery * Balancing.Instance.PestDeliveryMultiplier);
|
|
modifyCurrency.Delta = original with { Delivery = reduced };
|
|
}
|
|
}
|
|
}
|
|
|
|
public override string ToolTip => $"Deliveries are reduced to {Balancing.Instance.PestDeliveryMultiplier * 100:N0}% (temporary).";
|
|
} |