public bool TerrainCheck(Entity.TerrainType targetTerrain) { if (type == WeaponDiversityType.Torpedo) { return(targetTerrain == Entity.TerrainType.Ground); } return(this.terrain == Entity.TerrainType.All || targetTerrain == this.terrain); }
public bool CheckCategoryCompatibility(Entity.TerrainType terrain, Entity.EntityCategory category) { if (type == WeaponDiversityType.Torpedo) { return(terrain == Entity.TerrainType.Ground); } else { return(TerrainCheck(terrain) && CategoryCheck(category)); } }
public static T getNearestEntity <T>(Entity craft, bool enemy = true) where T : Entity { int faction = craft.faction; Entity.TerrainType terrainType = craft.Terrain; float minD = float.MaxValue; T nearest = null; for (int i = 0; i < AIData.entities.Count; i++) { if (AIData.entities[i] == craft) { continue; } if (AIData.entities[i].GetIsDead()) { continue; } if (terrainType != Entity.TerrainType.All && AIData.entities[i].Terrain != terrainType) { continue; } if (AIData.entities[i].IsInvisible) { continue; } if (AIData.entities[i] is T) { if ((FactionManager.IsAllied(AIData.entities[i].faction, faction) ^ !enemy) && faction != -1) { continue; } float d = (craft.transform.position - AIData.entities[i].transform.position).sqrMagnitude; if (d < minD) { minD = d; nearest = AIData.entities[i] as T; } } } return(nearest); }
public void SetTerrain(Entity.TerrainType terrain) { this.terrain = terrain; }