protected virtual void OnHit(LSAgent target, uint agentVersion, AgentController controller) { //If the shooter died, certain effects or records can't be completed bool isCurrent = Agent != null && agentVersion == Agent.SpawnVersion; Health healther = target.GetAbility <Health>(); AttackerInfo info = new AttackerInfo(isCurrent ? Agent : null, controller); healther.TakeDamage(Damage, info); CallExtraOnHit(target, isCurrent); }
public void Engage(LSAgent other) { if (other != Agent && other != null) { cachedTargetHealth = other.GetAbility <Health>(); if (cachedTargetHealth.IsNotNull()) { OnEngage(other); Target = other; targetVersion = Target.SpawnVersion; IsCasting = true; fastRangeToTarget = Range + (Target.Body.IsNotNull() ? Target.Body.Radius : 0) + Agent.Body.Radius; fastRangeToTarget *= fastRangeToTarget; if (!CheckRange()) { if (CanMove) { cachedMove.StartMove(Target.Body.Position); } } } } }
private void HandleCollision(LSBody other) { if (!CanMove) { return; } if ((tempAgent = other.Agent) == null) { return; } Move otherMover = tempAgent.GetAbility <Move>(); if (ReferenceEquals(otherMover, null) == false) { if (IsMoving) { //If the other mover is moving to a similar point if (otherMover.MyMovementGroupID == MyMovementGroupID || otherMover.targetPos.FastDistance(this.targetPos) <= (closingDistance * closingDistance)) { if (otherMover.IsMoving == false) { if (otherMover.Arrived && otherMover.StoppedTime > MinimumOtherStopTime) { Arrive(); } } else { if (hasPath && otherMover.hasPath && otherMover.pathIndex > 0 && otherMover.lastTargetPos.SqrDistance(targetPos.x, targetPos.y) < closingDistance.Mul(closingDistance)) { if (this.distance < this.closingDistance) { this.pathIndex++; } } } } if (GetLookingForStopPause()) { //As soon as the original collision stop unit is released, units will start breaking out of pauses if (otherMover.GetCanCollisionStop() == false) { StopPauseLayer = -1; PauseAutoStop(); } else if (otherMover.GetCanAutoStop() == false) { if (otherMover.StopPauseLayer < StopPauseLayer) { StopPauseLayer = otherMover.StopPauseLayer + 1; PauseAutoStop(); } } } else { } } } }