private void TryActiveModule(LOSResult result, UnitLock primaryLock) { if (result.hit && !result.blockingFlags.HasFlag(BlockingFlags.Plant)) { return; } _module.Lock = primaryLock; _module.State.SwitchTo(ModuleStateType.Oneshot); }
public void VisitUnitLock(UnitLock unitLock) { var victim = unitLock.Target; victim.InZone.ThrowIfFalse(ErrorCodes.TargetNotFound); victim.States.Dead.ThrowIfTrue(ErrorCodes.TargetIsDead); var err = victim.IsAttackable; if (err != ErrorCodes.NoError) { throw new PerpetuumException(err); } victim.IsInvulnerable.ThrowIfTrue(ErrorCodes.TargetIsInvulnerable); if (victim is Rift && (_weapon.ParentRobot.Zone is StrongHoldZone)) { throw new PerpetuumException(ErrorCodes.TargetIsNonAttackable); } _weapon.ConsumeAmmo(); var result = _weapon.GetLineOfSight(victim); if (result.hit) { DoDamageToPosition(result.position); _weapon.OnError(ErrorCodes.LOSFailed); return; } var distance = _weapon.ParentRobot.GetDistance(victim); var bulletTime = _weapon.GetAmmo().BulletTime; var flyTime = (int)((distance / bulletTime) * 1000); var beamTime = (int)Math.Max(flyTime, _weapon.CycleTime.TotalMilliseconds); var miss = _weapon.CheckAccuracy(victim); if (miss) { _weapon.CreateBeam(victim, BeamState.Miss, beamTime, bulletTime); _weapon.OnError(ErrorCodes.AccuracyCheckFailed); return; } var delay = _weapon.CreateBeam(victim, BeamState.Hit, beamTime, bulletTime); flyTime += delay; var builder = _weapon.GetDamageBuilder(); Task.Delay(flyTime).ContinueWith(t => victim.TakeDamage(builder.Build())); }
public override void VisitUnitLock(UnitLock unitLock) { if (!unitLock.Target.InZone) { Error = ErrorCodes.LockTargetNotFound; } else if (unitLock.Target.States.Dead) { Error = ErrorCodes.TargetIsDead; } else if (!unitLock.Target.IsLockable) { Error = ErrorCodes.TargetIsNotLockable; } else if (!unitLock.Owner.IsInLockingRange(unitLock.Target)) { Error = ErrorCodes.TargetOutOfRange; } }
public virtual void VisitUnitLock(UnitLock unitLock) { VisitLock(unitLock); }
public override void VisitUnitLock(UnitLock unitLock) { _lockType = LockType.Unit; _target.AppendLong(unitLock.Target.Eid); base.VisitUnitLock(unitLock); }