// Constructors. public DirectAttackAbility( NamedId abilityId, NamedId conditionId, Damage singleAttackDamage, float attackDuration, float attackMoment, float attackRange) : base(abilityId) { // Meta. this.conditionId = conditionId; //Attack properties. this.singleAttackDamage = singleAttackDamage; this.attackDuration = Floats.SetPositive(attackDuration); this.attackMoment = Floats.LimitPositive(attackMoment, this.attackDuration); this.attackRange = Floats.SetPositive(attackRange); }
// Updating. private protected override void OnAct(out bool finished) { ValidateContext(); finished = false; // Update time. timeUntilExtinction = Floats.SetPositive(timeUntilExtinction - Context.GameTimeDelta); // Go extinct. if (timeUntilExtinction == 0f) { Context.UnitSystem.PlanAction(new UnitRemovalAction(Owner)); } }
// Constructors. public DirectAttackCondition( UnitPresentation target, Damage singleAttackDamage, float attackDuration, float attackMoment, float attackRange, NamedId id) { // Meta. this.id = id; // Attack properties. this.target = target ?? throw new ArgumentNullException(nameof(target)); this.singleAttackDamage = singleAttackDamage; this.attackDuration = Floats.SetPositive(attackDuration); this.attackMoment = Floats.LimitPositive(attackMoment, this.attackDuration); this.attackRange = Floats.SetPositive(attackRange); // Progress. accumulatedTime = 0f; attacked = false; atStart = true; }
// Constructor. public DirectMotionAbility(NamedId abilityId, NamedId conditionId, float speed) : base(abilityId) { this.conditionId = conditionId; this.speed = Floats.SetPositive(speed); }
// Constructor. public CollapseCondition(NamedId id, float timeUntilExtinction = 1f) { this.id = id; this.timeUntilExtinction = Floats.SetPositive(timeUntilExtinction); }