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 && CanCollisionStop) { if (otherMover.MyMovementGroupID == MyMovementGroupID) { if (otherMover.IsMoving == false && otherMover.Arrived && otherMover.stopTime > MinimumOtherStopTime) { Arrive(); } else if (hasPath && otherMover.hasPath && otherMover.pathIndex > 0 && otherMover.lastTargetPos.SqrDistance(targetPos.x, targetPos.y) < FixedMath.One) { if (movementDirection.Dot(targetDirection.x, targetDirection.y) < 0) { pathIndex++; } } } } } }
protected virtual void OnHit(LSAgent agent) { Health healther = agent.GetAbility <Health>(); healther.TakeDamage(Damage, this.Agent); CallExtraOnHit(agent); }
protected virtual void OnHit(LSAgent agent) { Health healther = agent.GetAbility <Health>(); AttackerInfo info = new AttackerInfo(Agent, this.Agent.Controller); healther.TakeDamage(Damage, info); CallExtraOnHit(agent); }
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 AgentCommander CreateCommander(string commanderAgentCode) { if (Commander != null) { Debug.LogError("A commander called '" + Commander.Agent.CachedGameObject + "' already exists for '" + this.ToString() + "'."); } LSAgent commanderAgent = CreateBareAgent(commanderAgentCode); _commander = commanderAgent.GetAbility <AgentCommander> (); if (_commander == null) { Debug.LogError("Agent '" + commanderAgentCode + "' does not have AgentCommander component and cannot be a commander."); } return(Commander); }
public void Engage(LSAgent other) { if (other != Agent) { cachedTargetHealth = other.GetAbility <Health>(); if (cachedTargetHealth.IsNotNull()) { Target = other; HasTarget = true; targetVersion = Target.SpawnVersion; IsCasting = true; fastRangeToTarget = Range + (Target.Body.IsNotNull() ? Target.Body.Radius : 0); fastRangeToTarget *= fastRangeToTarget; } } }
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 && (GetFullCanAutoStop())) { if (otherMover.MyMovementGroupID == MyMovementGroupID || otherMover.targetPos == this.targetPos) { if (otherMover.IsMoving == false && otherMover.Arrived && otherMover.StoppedTime > MinimumOtherStopTime) { if (otherMover.CanCollisionStop == false) { PauseAutoStop(); } else { Arrive(); } } else if (hasPath && otherMover.hasPath && otherMover.pathIndex > 0 && otherMover.lastTargetPos.SqrDistance(targetPos.x, targetPos.y) < FixedMath.One ) { if (this.distance < this.closingDistance) { this.pathIndex++; } } } else { } } } }
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()) { cachedMove.StartMove(Target.Body.Position); } } } }
public override void Initialize(LSAgent agent) { MyMovementGroupID = -1; Body = agent.Body; Body.Mover = this; Body.OnContact += HandleCollision; Turner = agent.GetAbility<Turn> (); timescaledSpeed = ((Speed * LockstepManager.Timestep) >> FixedMath.SHIFT_AMOUNT); closingDistance = agent.Body.Radius; RepathCount = LSUtility.GetRandom (RepathRate); ViableDestination = false; }
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 { } } } }
protected virtual void OnHit(LSAgent agent) { Health healther = agent.GetAbility <Health>(); healther.TakeDamage(_damage); }