// get the atom with the highest Sim() value to me in a structure public static clsGroundAtom findMostSimilarInStructure(clsGroundAtom me, clsPolygon structure) { // find most similar only in this agent's public space List <clsGroundAtom> comparisonAtoms = me.m_GameObject.getQuadTreeByStructure(structure).SearchEntities(me.curr_X, me.curr_Y, me.proxemics.publicSpace, isPrecise: true); return(findMostSimilarFromGroup(me, comparisonAtoms)); }
// get a polygon by guid public static clsPolygon getPolygonByGuid(String guid) { string sql = "select * from Polygons where polygon_guid='" + guid + "'"; clsPolygon polygon = GetPolygonBySql(sql); return(polygon); }
// get all polygon escape points for a specific polygon public static List <clsPolygonOpeningEscapePoint> getPolygonEscapePoints(clsPolygon polygon) { String sql = "select * from polygon_openings_escape_points where polygon_guid='" + polygon.PolygonGuid + "'"; List <clsPolygonOpeningEscapePoint> escapePoints = getPolygonEscapePointsBySql(sql); return(escapePoints); }
// get all polygon openings from database for a specific polygon public static List <clsPolygonOpening> getPolygonOpeningsByPolygon(clsPolygon polygon) { string sql = "select * from polygon_openings where polygon_guid='" + polygon.PolygonGuid + "'"; List <clsPolygonOpening> openings = GetPolygonOpeningsBySql(sql); return(openings); }
public static clsPolygon GetPolygonByName(string Name) { string sql = "select * from Polygons where polygon_name='" + Name + "'"; clsPolygon polygon = GetPolygonBySql(sql); return(polygon); }
public GO_AWAY_FROM_BUILDING_STATE(clsActivityMovement ActivityMovement, TerrainService.Vector targetPosition, clsPolygon Structure, int exitEdgeNumber) : base(ActivityMovement) { refActivityMovement = ActivityMovement; this.targetPosition = targetPosition; this.Structure = Structure; this.exitEdgeNumber = exitEdgeNumber; }
private static clsPolygon GetPolygonBySql(string sql) { try { clsPolygon polygon = new clsPolygon(); using (NpgsqlConnection connection = new NpgsqlConnection(strPostGISConnection)) using (NpgsqlDataAdapter da = new NpgsqlDataAdapter(sql, connection)) { DataSet dsPol = new DataSet(); DataTable dtPol = new DataTable(); dsPol.Reset(); da.Fill(dsPol); dtPol = dsPol.Tables[0]; if (dtPol == null || dtPol.Rows == null || dtPol.Rows.Count == 0) { return null; } foreach (DataRow rowPol in dtPol.Rows) { polygon.PolygonName = rowPol["polygon_name"].ToString(); polygon.PolygonGuid = rowPol["polygon_guid"].ToString(); } } polygon.Points = getPolygonPoints(polygon.PolygonGuid); //YD: // get the polygon's openings polygon.PolygonOpenings = getPolygonOpeningsByPolygon(polygon); // get the escape points for each opening List<clsPolygonOpeningEscapePoint> escapePoints = getPolygonEscapePoints(polygon); polygon.EscapePoints = new Dictionary<int, clsPolygonOpeningEscapePoint>(); foreach (clsPolygonOpeningEscapePoint escapePoint in escapePoints) { polygon.EscapePoints.Add(escapePoint.polygonEdgeNum, escapePoint); } // --- return polygon; } catch (Exception ex) { } return null; }
private static clsPolygon GetPolygonBySql(string sql) { try { clsPolygon polygon = new clsPolygon(); using (NpgsqlConnection connection = new NpgsqlConnection(strPostGISConnection)) using (NpgsqlDataAdapter da = new NpgsqlDataAdapter(sql, connection)) { DataSet dsPol = new DataSet(); DataTable dtPol = new DataTable(); dsPol.Reset(); da.Fill(dsPol); dtPol = dsPol.Tables[0]; if (dtPol == null || dtPol.Rows == null || dtPol.Rows.Count == 0) { return(null); } foreach (DataRow rowPol in dtPol.Rows) { polygon.PolygonName = rowPol["polygon_name"].ToString(); polygon.PolygonGuid = rowPol["polygon_guid"].ToString(); } } polygon.Points = getPolygonPoints(polygon.PolygonGuid); //YD: // get the polygon's openings polygon.PolygonOpenings = getPolygonOpeningsByPolygon(polygon); // get the escape points for each opening List <clsPolygonOpeningEscapePoint> escapePoints = getPolygonEscapePoints(polygon); polygon.EscapePoints = new Dictionary <int, clsPolygonOpeningEscapePoint>(); foreach (clsPolygonOpeningEscapePoint escapePoint in escapePoints) { polygon.EscapePoints.Add(escapePoint.polygonEdgeNum, escapePoint); } // --- return(polygon); } catch (Exception ex) { } return(null); }
private int getClosestExitPoint(clsGroundAtom refGroundAtom, clsPolygon Structure) { DPoint[] coordinates = refGroundAtom.m_GameObject.getRegularMovementCoordinates(); DPoint minPoint = null; int minIndex = 0; for (int i = 0; i < coordinates.Count(); i++) { DPoint coordinate = coordinates[i]; if (minPoint == null || TerrainService.MathEngine.CalcDistance(refGroundAtom.curr_X, refGroundAtom.curr_Y, coordinate.x, coordinate.y) < TerrainService.MathEngine.CalcDistance(refGroundAtom.curr_X, refGroundAtom.curr_Y, minPoint.x, minPoint.y)) { minPoint = coordinate; minIndex = i; } } return(minIndex); }
// get all polygon openings from database for a specific polygon public static List<clsPolygonOpening> getPolygonOpeningsByPolygon(clsPolygon polygon) { string sql = "select * from polygon_openings where polygon_guid='" + polygon.PolygonGuid + "'"; List<clsPolygonOpening> openings = GetPolygonOpeningsBySql(sql); return openings; }
public SOCIAL_COMPARISON_IN_STRUCTURE_STATE(clsPolygon _Structure, clsGroundAtom mostSimilar) : base(_Structure) { this.mostSimilar = mostSimilar; }
public EXIT_STRUCTURE_STATE(clsPolygon _Structure) : base(_Structure) { }
public STAY_IN_STRUCTURE_STATE(clsPolygon _Structure) : base(_Structure) { }
public REGULAR_MOVEMENT_IN_STRUCTURE_STATE(clsPolygon _Structure, PolygonWaypoint nextWaypoint) : base(_Structure) { this.nextWaypoint = nextWaypoint; }
public MOVEMENT_IN_STRUCTURE_STATE(clsPolygon _Structure) { Structure = _Structure; }
public AtomAndStructureEventArgs(clsGroundAtom groundAtom, clsPolygon Structure) { this.groundAtom = groundAtom; this.Structure = Structure; }
private int getClosestExitPoint(clsGroundAtom refGroundAtom, clsPolygon Structure) { DPoint[] coordinates = refGroundAtom.m_GameObject.getRegularMovementCoordinates(); DPoint minPoint = null; int minIndex = 0; for (int i = 0; i < coordinates.Count(); i++) { DPoint coordinate = coordinates[i]; if (minPoint == null || TerrainService.MathEngine.CalcDistance(refGroundAtom.curr_X, refGroundAtom.curr_Y, coordinate.x, coordinate.y) < TerrainService.MathEngine.CalcDistance(refGroundAtom.curr_X, refGroundAtom.curr_Y, minPoint.x, minPoint.y)) { minPoint = coordinate; minIndex = i; } } return minIndex; }
// get the atom with the highest Sim() value to me in a structure public static clsGroundAtom findMostSimilarInStructure(clsGroundAtom me, clsPolygon structure) { List<clsGroundAtom> comparisonAtoms = me.m_GameObject.getQuadTreeByStructure(structure).SearchEntities(me.curr_X, me.curr_Y, COMPARISON_RADIUS, isPrecise: true); return findMostSimilarFromGroup(me, comparisonAtoms); }
// get all polygon escape points for a specific polygon public static List<clsPolygonOpeningEscapePoint> getPolygonEscapePoints(clsPolygon polygon) { String sql = "select * from polygon_openings_escape_points where polygon_guid='" + polygon.PolygonGuid + "'"; List<clsPolygonOpeningEscapePoint> escapePoints = getPolygonEscapePointsBySql(sql); return escapePoints; }