public static IEnumerable <LSAgent> ScanAll(int gridX, int gridY, int deltaCount, LSAgent sourceAgent, AllegianceType targetAllegiance) { long sourceX = sourceAgent.Body._position.x; long sourceY = sourceAgent.Body._position.y; for (int i = 0; i < deltaCount; i++) { ScanNode tempNode = GridManager.GetScanNode( gridX + DeltaCache.CacheX [i], gridY + DeltaCache.CacheY [i]); if (tempNode.IsNotNull()) { foreach (FastBucket <LSInfluencer> tempBucket in tempNode.BucketsWithAllegiance(sourceAgent, targetAllegiance)) { BitArray arrayAllocation = tempBucket.arrayAllocation; for (int j = 0; j < tempBucket.PeakCount; j++) { if (arrayAllocation.Get(j)) { LSAgent tempAgent = tempBucket [j].Agent; if (true)//conditional(tempAgent)) { yield return(tempAgent); } } } } } } }
public void ScanAll(int deltaCount, FastList<LSAgent> outputAgents, bool CheckAllegiance = false, AllegianceType allegianceType = AllegianceType.Neutral) { for (i = 0; i < deltaCount; i++) { tempNode = GridManager.GetNode ( LocatedNode.gridX + DeltaCache.CacheX[i], LocatedNode.gridY + DeltaCache.CacheY[i]); if (tempNode != null && tempNode.LocatedAgents != null) { tempBucket = tempNode.LocatedAgents; for (j = 0; j < tempBucket.PeakCount; j++) { if (LSUtility.GetBitTrue (tempBucket.arrayAllocation, j)) { tempAgent = tempBucket.innerArray [j].Agent; if (System.Object.ReferenceEquals (tempAgent, Agent) == false) { if (CheckAllegiance) { if (Agent.MyAgentController.DiplomacyFlags [tempAgent.MyAgentController.ControllerID] != allegianceType) continue; } outputAgents.Add (tempAgent); } } } } } }
public void SetAllegiance(Team other, AllegianceType allegiance) { while (other.ID >= Diplomacy.Count) { Diplomacy.Add(AllegianceType.Neutral); } Diplomacy[other.ID] = allegiance; }
public void SetAllegiance(AgentController otherController, AllegianceType allegianceType) { while (DiplomacyFlags.Count <= otherController.ControllerID) { DiplomacyFlags.Add(AllegianceType.Neutral); } DiplomacyFlags[otherController.ControllerID] = allegianceType; }
public LSAgent Scan(int deltaCount, AllegianceType targetAllegiance = AllAllegiance, PlatformType targetPlatform = AllPlatforms) { InfluenceManager.Source = Agent; InfluenceManager.TargetAllegiance = targetAllegiance; InfluenceManager.TargetPlatform = targetPlatform; return(InfluenceManager.Scan(LocatedNode.ScanX, LocatedNode.ScanY, deltaCount, this.Agent, targetAllegiance)); }
public LSAgent Scan(int deltaCount, AllegianceType targetAllegiance = AllegianceType.Any, PlatformType targetPlatform = PlatformType.Any) { InfluenceManager.Source = Agent; InfluenceManager.TargetAllegiance = targetAllegiance; InfluenceManager.TargetPlatform = targetPlatform; return(InfluenceManager.Scan(LocatedNode.ScanX, LocatedNode.ScanY, deltaCount, InfluenceManager.ScanConditionalSourceWithHealthAction, Agent.Body.Position.x, Agent.Body.Position.y)); }
public LSAgent Scan(int deltaCount, AllegianceType targetAllegiance = AllegianceType.Any, PlatformType targetPlatform = PlatformType.Any) { InfluenceManager.Source = Agent; InfluenceManager.TargetAllegiance = targetAllegiance; InfluenceManager.TargetPlatform = targetPlatform; return InfluenceManager.Scan (LocatedNode.ScanX, LocatedNode.ScanY, deltaCount, InfluenceManager.ScanConditionalSourceWithHealthAction, Agent.Body.Position.x, Agent.Body.Position.y); }
private AgentController(AllegianceType defaultAllegiance) { if (InstanceManagers.Count > byte.MaxValue) { throw new System.Exception("Cannot have more than 256 AgentControllers"); } OpenLocalIDs.FastClear(); PeakLocalID = 0; ControllerID = (byte)InstanceManagers.Count; DefaultAllegiance = defaultAllegiance; for (int i = 0; i < InstanceManagers.Count; i++) { this.SetAllegiance(InstanceManagers [i], AllegianceType.Neutral); } InstanceManagers.Add(this); UpdateDiplomacy(this); this.SetAllegiance(this, AllegianceType.Friendly); }
public static LSAgent Scan(int gridX, int gridY, int deltaCount, LSAgent sourceAgent, AllegianceType targetAllegiance) { long sourceX = sourceAgent.Body._position.x; long sourceY = sourceAgent.Body._position.y; LSAgent closestAgent = null; long closestDistance = 0; int foundBuffer = FoundScanBuffer; foreach (LSAgent agent in ScanAll(gridX, gridY, deltaCount, sourceAgent, targetAllegiance)) { if (FoundScanBuffer == 0) { break; } if (closestAgent != null) { long tempDistance = agent.Body._position.FastDistance(sourceX, sourceY); if (tempDistance < closestDistance) { closestAgent = agent; closestDistance = tempDistance; foundBuffer = FoundScanBuffer; } else { foundBuffer--; } } else { closestAgent = agent; closestDistance = agent.Body._position.FastDistance(sourceX, sourceY); } } return(closestAgent); }
public static LSProjectile Create(string projCode, LSAgent source, Vector3d offset, AllegianceType targetAllegiance, Func <LSAgent, bool> agentConditional, Action <LSAgent> hitEffect) { Vector3d pos = offset; pos.SetVector2d(pos.ToVector2d().Rotated(source.Body._rotation.x, source.Body._rotation.y)); pos.Add(ref source.Body._position); return(Create(projCode, pos, agentConditional, (bite) => ((source.Controller.GetAllegiance(bite) & targetAllegiance) != 0), hitEffect)); }
public static AgentController Create(AllegianceType defaultAllegiance = AllegianceType.Neutral) { return(new AgentController(defaultAllegiance)); }
public static AgentController Create(AllegianceType defaultAllegiance = AllegianceType.Neutral, string controllerName = "") { return(new AgentController(defaultAllegiance, controllerName)); }
public void SetAllegiance(AgentController otherController, AllegianceType allegianceType) { DiplomacyFlags[otherController.ControllerID] = allegianceType; }
public void SetAllegiance(Team other, AllegianceType allegiance) { Diplomacy[other.ID] = allegiance; }
public static LSProjectile Create(string projCode, RTSAgent source, Vector3d offset, AllegianceType targetAllegiance, Func <RTSAgent, bool> agentConditional, Action <RTSAgent> hitEffect) { Vector2d relativePos = offset.ToVector2d(); Vector2d worldPos = relativePos.Rotated(source.Body.Rotation) + source.Body.Position; Vector3d pos = new Vector3d(worldPos.x, worldPos.y, offset.z + source.Body.HeightPos); AgentController sourceController = source.Controller; LSProjectile proj = Create( projCode, pos, agentConditional, (bite) => { return((sourceController.GetAllegiance(bite) & targetAllegiance) != 0); } , hitEffect); return(proj); }
public IEnumerable <FastBucket <LSInfluencer> > BucketsWithAllegiance(LSAgent source, AllegianceType allegiance) { foreach (KeyValuePair <byte, FastBucket <LSInfluencer> > pair in LocatedAgents) { if ((source.Controller.GetAllegiance(pair.Key) & allegiance) != 0) { yield return(pair.Value); } } }
public static LSProjectile Create(string projCode, LSAgent source, Vector3d offset, AllegianceType targetAllegiance, Func <LSAgent, bool> agentConditional, Action <LSAgent> hitEffect) { Vector2d relativePos = offset.ToVector2d(); Vector2d worldPos = relativePos.Rotated(source.Body.Rotation); Vector3d pos = new Vector3d(worldPos.x, worldPos.y, offset.z + source.Body.HeightPos); pos.Add(ref source.Body._position); return(Create(projCode, pos, agentConditional, (bite) => ((source.Controller.GetAllegiance(bite) & targetAllegiance) != 0), hitEffect)); }
private static IEnumerable <LSAgent> Scan(Vector2d center, long radius, LSAgent sourceAgent, AllegianceType targetAllegiance) { int gridX; int gridY; GridManager.GetScanCoordinates(center.x, center.y, out gridX, out gridY); foreach (LSAgent agent in InfluenceManager.ScanAll(gridX, gridY, InfluenceManager.GenerateDeltaCount(radius), sourceAgent, targetAllegiance)) { yield return(agent); } }
public TargetProperties setAllegianceType(AllegianceType allegianceType) { this.allegianceType = allegianceType; return(this); }
public void setAllegianceType(AllegianceType allegianceType) { this.allegianceType = allegianceType; }