public static void DestroyAgent(LSAgent agent, bool immediate = false) { DeactivationBuffer.Add(new DeactivationData(agent, immediate)); }
public void RemoveFromSelection(LSAgent agent) { SelectedAgents.Remove(agent); SelectionChanged = true; }
protected virtual bool AgentValid(LSAgent agent) { return(true); }
public DeactivationData(LSAgent agent, bool immediate) { Agent = agent; Immediate = immediate; }
public LSProjectile PrepareProjectile(string projectileCode, Vector3d projOffset, LSAgent target) { LastFire = this; LSProjectile currentProjectile = ProjectileManager.Create( projectileCode, this.Agent, projOffset, this.TargetAllegiance, (other) => { Health healther = other.GetAbility <Health>(); return(healther.IsNotNull() && healther.HealthAmount > 0); }, CachedOnHit); switch (currentProjectile.TargetingBehavior) { case TargetingType.Homing: currentProjectile.InitializeHoming(target); break; case TargetingType.Timed: currentProjectile.InitializeTimed(Agent.Body.Forward); break; case TargetingType.Positional: currentProjectile.InitializePositional(target.Body.Position.ToVector3d(target.Body.HeightPos)); break; case TargetingType.Directional: //TODO throw new System.Exception("Not implemented yet."); //break; } OnPrepareProjectile(currentProjectile); return(currentProjectile); }
protected virtual void OnEngage(LSAgent target) { }
public AllegianceType GetAllegiance(LSAgent other) { return(Controller.GetAllegiance(other.Controller)); }
public LSProjectile FullFireProjectile(string projectileCode, Vector3d projOffset, LSAgent target) { LSProjectile proj = (PrepareProjectile(projectileCode, projOffset, target)); FireProjectile(proj); return(proj); }
public static AllegianceType GetAllegiance(LSAgent agent) { return(PlayerManager.GetAllegiance(agent.Controller)); }
public void Setup(LSAgent agent) { Agent = agent; Body = agent.Body; }
public AttackerInfo(LSAgent attacker, AgentController controller) { Attacker = attacker; Controller = controller; }
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 { } } } }
public static void Update() { MousePosition = Input.mousePosition; MouseWorldPosition = RTSInterfacing.GetWorldPos(MousePosition); GetMousedAgent(); if (Boxing) { if (CanBox) { BoxingTime += Time.deltaTime; if (MousePosition != BoxEnd) { Vector2 RaycastTopLeft; Vector2 RaycastTopRight; Vector2 RaycastBotLeft; Vector2 RaycastBotRight; BoxEnd = MousePosition; if (BoxStart.x < BoxEnd.x) { RaycastTopLeft.x = BoxStart.x; RaycastBotLeft.x = BoxStart.x; RaycastTopRight.x = BoxEnd.x; RaycastBotRight.x = BoxEnd.x; } else { RaycastTopLeft.x = BoxEnd.x; RaycastBotLeft.x = BoxEnd.x; RaycastTopRight.x = BoxStart.x; RaycastBotRight.x = BoxStart.x; } if (BoxStart.y < BoxEnd.y) { RaycastBotLeft.y = BoxStart.y; RaycastBotRight.y = BoxStart.y; RaycastTopLeft.y = BoxEnd.y; RaycastTopRight.y = BoxEnd.y; } else { RaycastBotLeft.y = BoxEnd.y; RaycastBotRight.y = BoxEnd.y; RaycastTopLeft.y = BoxStart.y; RaycastTopRight.y = BoxStart.y; } Box_TopLeft = RTSInterfacing.GetWorldPos(RaycastTopLeft); Box_TopRight = RTSInterfacing.GetWorldPos(RaycastTopRight); Box_BottomLeft = RTSInterfacing.GetWorldPos(RaycastBotLeft); Box_BottomRight = RTSInterfacing.GetWorldPos(RaycastBotRight); } ClearBox(); //int lecount = 0; if ((BoxEnd - BoxStart).sqrMagnitude >= MinBoxSqrDist) { bufferBoxedAgents.Clear(); for (int i = 0; i < PlayerManager.AgentControllerCount; i++) { var agentController = PlayerManager.GetAgentController(i); for (int j = 0; j < AgentController.MaxAgents; j++) { if (agentController.LocalAgentActive[j]) { curAgent = agentController.LocalAgents[j]; if (curAgent.CanSelect) { if (curAgent.RefEquals(MousedAgent)) { bufferBoxedAgents.Add(curAgent); } else { agentPos = curAgent.Position2; Edge = Box_TopRight - Box_TopLeft; Point = agentPos - Box_TopLeft; if (DotEdge() < 0) { Edge = Box_BottomRight - Box_TopRight; Point = agentPos - Box_TopRight; if (DotEdge() < 0) { Edge = Box_BottomLeft - Box_BottomRight; Point = agentPos - Box_BottomRight; if (DotEdge() < 0) { Edge = Box_TopLeft - Box_BottomLeft; Point = agentPos - Box_BottomLeft; if (DotEdge() < 0) { bufferBoxedAgents.Add(curAgent); continue; } } } } } } } } } bufferBoxable.FastClear(); //bool noneBoxable = true; if (bufferBoxedAgents.Count > 0) { int peakBoxPriority = bufferBoxedAgents.PeekMax().BoxPriority; while (bufferBoxedAgents.Count > 0) { LSAgent agent = bufferBoxedAgents.PopMax(); if (agent.BoxPriority < peakBoxPriority) { break; } BoxAgent(agent); } } } else { BoxAgent(MousedAgent); } } if (Input.GetMouseButtonUp(0)) { if (CanClearSelection && !Input.GetKey(KeyCode.LeftShift)) { ClearSelection(); } if (IsGathering == false) { SelectBoxedAgents(); } Boxing = false; } } else { if (IsGathering == false && Input.GetMouseButton(0)) { _checkBoxDistance = true; StartBoxing(MousePosition); } } }
protected virtual void OnApplyEffect(LSAgent agent, bool isCurrent) { }
public static void ScanAll(Vector2d position, long radius, Func <LSAgent, bool> agentConditional, Func <byte, bool> bucketConditional, FastList <LSAgent> output) { //If radius is too big and we scan too many tiles, performance will be bad const long circleCastRadius = FixedMath.One * 16; output.FastClear(); if (radius >= circleCastRadius) { bufferBodies.FastClear(); PhysicsTool.CircleCast(position, radius, bufferBodies); for (int i = 0; i < bufferBodies.Count; i++) { var body = bufferBodies [i]; var agent = body.Agent; //we have to check agent's controller since we did not filter it through buckets if (agent.IsNotNull() && bucketConditional(agent.Controller.ControllerID)) { if (agentConditional(agent)) { output.Add(agent); } } } return; } int xMin = ((position.x - radius - GridManager.OffsetX) / (long)GridManager.ScanResolution).ToInt(); int xMax = ((position.x + radius - GridManager.OffsetX) / (long)GridManager.ScanResolution).CeilToInt(); int yMin = ((position.y - radius - GridManager.OffsetY) / (long)GridManager.ScanResolution).ToInt(); int yMax = ((position.y + radius - GridManager.OffsetY) / (long)GridManager.ScanResolution).CeilToInt(); long fastRadius = radius * radius; for (int x = xMin; x <= xMax; x++) { for (int y = yMin; y <= yMax; y++) { ScanNode tempNode = GridManager.GetScanNode( x, y); if (tempNode.IsNotNull()) { if (tempNode.AgentCount > 0) { bufferBuckets.FastClear(); tempNode.GetBucketsWithAllegiance(bucketConditional, bufferBuckets); for (int i = 0; i < bufferBuckets.Count; i++) { FastBucket <LSInfluencer> tempBucket = bufferBuckets[i]; BitArray arrayAllocation = tempBucket.arrayAllocation; for (int j = 0; j < tempBucket.PeakCount; j++) { if (arrayAllocation.Get(j)) { LSAgent tempAgent = tempBucket[j].Agent; long distance = (tempAgent.Body.Position - position).FastMagnitude(); if (distance < fastRadius) { if (agentConditional(tempAgent)) { output.Add(tempAgent); } } else { } } } } } } } } }