public Rule(Func <AreaTypes, bool> applicable, Func <AreaTypes[], bool> condition, AreaTypes yesResultOutput, AreaTypes noResultOutput) { Applicable = applicable; Condition = condition; YesResultOutput = yesResultOutput; NoResultOutput = noResultOutput; }
public void StartSimulatingArea(AreaTypes areaType, int areaID) { if (_gameStates.ContainsKey(areaID)) { throw new Exception("AreaID is already being simulated!"); } PlayableGameState newState; switch (areaType) { case AreaTypes.System: { newState = SimulatorStateBuilder.BuildSpaceStateManager(areaID, _redisServer, _networkingService); break; } case AreaTypes.Planet: { newState = SimulatorStateBuilder.BuildPlanetStateManager(areaID, _redisServer, _networkingService, _physicsConfig); break; } default: throw new InvalidOperationException(areaType + " not implemeted in the simulator."); } FinalizeNewState(newState, areaID); }
public RestrictedArea(string name, AreaTypes type, int floor, int ceiling) { Name = name; Type = type; AltitudeFloor = floor; AltitudeCeiling = ceiling; }
public string GetPath(AreaTypes stopType, string interval) { if (!string.IsNullOrEmpty(_path)) { return(_path); } if (this.Type == stopType) { return(Name); } if (this.Id == 2) { _path = Name; } if (Parent != null) { if (Parent.Type == stopType) { _path = Parent.Name + interval + Name; } else { _path = Parent.GetPath(stopType, interval) + interval + Name; } } else { _path = Name; } return(_path); }
public void MoveShipLocal(IShip ship, int destinationAreaId) { if (!_areaLocator.IsLocalArea(destinationAreaId)) { return; } IArea currentArea = null; if (ship.CurrentAreaId != null) { currentArea = _areaLocator.GetArea((int)ship.CurrentAreaId); } var newArea = _areaLocator.GetArea(destinationAreaId); AreaTypes currentAreaType = currentArea?.AreaType ?? AreaTypes.Any; OnAreaExit(ship, currentArea, newArea.AreaType); newArea.MoveShipHere(ship); ship.SetArea(newArea); newArea.SetEntryPosition(ship, currentArea); OnAreaChange(ship, newArea, currentAreaType); }
public void MovePlayerLocal(Player p, int destinationAreaId, bool isWarping) { if (!_areaLocator.IsLocalArea(destinationAreaId)) { return; } IArea currentArea = null; currentArea = _areaLocator.GetArea((int)p.CurrentAreaID); var newArea = _areaLocator.GetArea(destinationAreaId); AreaTypes currentAreaType = currentArea?.AreaType ?? AreaTypes.Any; if (currentAreaType == AreaTypes.System) { newArea.MovePlayerHere(p, isWarping); } else { newArea.MovePlayerHere(p, false); } p.SetArea(newArea); if (p.PlayerType == PlayerTypes.Human && p.IsOnline) { newArea.SendEntryData((HumanPlayer)p, isWarping, p.GetActiveShip()); } }
public ResourceNodeData GetResourceNodeCollection(AreaTypes collectionAreaType) { ResourceNodeData rnd = null; rnd = resNodeData.Find(x => x.thisAreaType == collectionAreaType); return(rnd); }
public EnvironmentPiece GetPieceForAreaType(AreaTypes findType) { EnvironmentPieceCollection collection = allEnviroPieceCollections.Find(x => x.thisAreaType == findType); int randomIndex = Random.Range(0, collection.allEnvironmentPieces.Count); return(collection.allEnvironmentPieces[randomIndex]); }
public BuiltPathPiece GetValidBPPForAreaType(AreaTypes aType) { //Find the related group PathPoolGroup ppGroup = allPathedAreas.Find(x => x.thisPathedArea.thisAreaType == aType); //Get a random available piece from that group BuiltPathPiece availablePiece = GetProceduralBPPForGroup(ppGroup); //Return the piece return(availablePiece); }
public AreaTemplateAttribute(string objId, string name, string icon, AreaTypes needsAreaType, AreaTypes providesAreayType, AreaTypes isAreaType, bool isDeletable = true) { ObjId = new Guid(objId); Name = $"AREA_TEMPLATE.{name.ToUpperInvariant()}.NAME"; Description = $"AREA_TEMPLATE.{name.ToUpperInvariant()}.DESCRIPTION"; Icon = icon; NeedsAreaType = needsAreaType; ProvidesAreayType = providesAreayType; IsAreaType = isAreaType; IsDeletable = isDeletable; }
public void MoveToNewArea(AreaTypes aType) { currentPathPoolGroup = allPathedAreas.Find(x => x.thisPathedArea.thisAreaType == aType); if (currentPathPoolGroup == null) { Debug.LogError("Invalid area type set as starting area."); } else { currentPathPoolGroup.Fixed_SetupLocalReferences(); } }
/// <summary> /// Fetch area with known type from database. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="areaId"></param> /// <param name="areaType"></param> /// <returns></returns> public async Task <T> GetAreaFromDatabase <T>(int areaId, AreaTypes areaType) where T : AreaModel { try { return(await _databaseManager.GetAreaAsync(areaId, areaType) as T); } catch (WrongAreaTypeException e) { _logger.Log("User requested area of different type. Potential race condition or hacking?", LogLevel.Warning); } return(null); }
public static Guid GetFromEnum(AreaTypes areaType) { var type = areaType.GetType(); var memInfo = type.GetMember(areaType.ToString()); var attributes = memInfo[0].GetCustomAttributes(typeof(AreaTypeAttribute), false); if (attributes.Length == 1 && attributes[0] is AreaTypeAttribute attribute) { return(attribute.ObjId); } throw new ArgumentException($"{nameof(areaType)} is no {nameof(AreaTypeAttribute)}"); }
private static TopoInfo GetTopoInfo(string name, AreaTypes type, params PointInfo[] pis) { BoundInfo boundInfo = NewBoundInfo(); boundInfo.Points.AddRange(pis); TopoInfo topoInfo = new TopoInfo(); topoInfo.BoundInfo = boundInfo; topoInfo.Name = name; topoInfo.Type = type; return(topoInfo); }
/// <summary> /// Reads an area from the DB /// If the areatype is PSystem, loads all associated nested objects with each system (e.g. planets, ships, players...). Probably subject to change. /// </summary> /// <returns></returns> public async Task <AreaModel> GetAreaAsync(int ID, AreaTypes expectedType = AreaTypes.Any) { var a = await(_areaC.Find(s => s.Id == ID).FirstOrDefaultAsync()); //Unknown descriminator exception? Register the class in _initData() if (expectedType != AreaTypes.Any && expectedType != a.AreaType) { throw new WrongAreaTypeException( "Error: AreaModel loaded from database does not match requested AreaModel.Type. Expected type: " + expectedType + "; loaded type: " + a.AreaType); } return(a); }
public void SetStartingArea(AreaTypes areaType) { currentPathPoolGroup = allPathedAreas.Find(x => x.thisPathedArea.thisAreaType == areaType); if (currentPathPoolGroup == null) { Debug.LogError("Invalid area type set as starting area."); } else { pathBuilder.BuildFixedArea(currentPathPoolGroup); pathBuilder.BuildExtensionsToFixedArea(); currentPathPoolGroup.Fixed_SetupLocalReferences(); currentBuiltPathPiece = currentPathPoolGroup.thisPathedArea.startBPP; } }
public string ConvertAreaToInterfaceState(AreaTypes area) { switch (area) { case AreaTypes.Colony: return(AreaTypes.Colony.ToString()); case AreaTypes.Planet: return(AreaTypes.Planet.ToString()); case AreaTypes.Port: return(AreaTypes.Port.ToString()); default: return("Space"); } }
/// <summary> /// Call this to begin changing area when handing off a local client. /// </summary> /// <param name="newArea"></param> /// <param name="ship"></param> /// <param name="isWarping"></param> async Task HandoffInitiateAreaChange(int destinationAreaID, AreaTypes newAreaType, IShip ship, Player warpingPlayer) { var shipSaveTask = _databaseManager.SaveAsync(warpingPlayer); var playerSaveTask = _databaseManager.SaveAsync(ship); var shipSaveHandoffTask = _databaseManager.HandoffSaveAsync(ship);//If these collections aren't empty on server startup, a server crashed mid handoff and there could be ships/players which aren't stored in any area and might not be loaded. var playerSaveHandoffTask = _databaseManager.HandoffSaveAsync(warpingPlayer); //Ensure that db versions of ship and player are most recent, since they'll be loaded by slave List <Task> tasklist = new List <Task> { shipSaveTask, shipSaveHandoffTask, playerSaveTask, playerSaveHandoffTask, }; await Task.WhenAll(tasklist); if (!(shipSaveTask.Result.IsAcknowledged && shipSaveHandoffTask.Result.IsAcknowledged && playerSaveTask.Result.IsAcknowledged && playerSaveHandoffTask.Result.IsAcknowledged)) { throw new InvalidOperationException("Error: db write failed during handoff, handoff aborted."); } //Send handoff to be handled by server NetworkMessageContainer redismsg = new NetworkMessageContainer(new MessageClientHandoff((int)warpingPlayer.AccountID, (int)warpingPlayer.ActiveShipId, destinationAreaID, ((LidgrenOutgoingMessageService)warpingPlayer.MessageService).Connection.RemoteEndPoint.Address.GetAddressBytes()), MessageTypes.Redis_ClientHandoff); _redisServer.PublishObject(MessageTypes.Redis_ClientHandoff, redismsg); IArea currentArea = null; if (ship.CurrentAreaId != null) { currentArea = _areaLocator.GetArea((int)ship.CurrentAreaId); } OnAreaExit(ship, currentArea, newAreaType); currentArea.RemovePlayer(ship.GetPlayer()); //There doesn't seem to be a convenient way to avoid putting this here currentArea.RemoveShip(ship); //Sends removeship Command to clients in area ConsoleManager.WriteLine("Initiated Handoff"); ship.GetPlayer().IsHandedOff = true; _registrationManager.DeRegisterObject(warpingPlayer); _registrationManager.DeRegisterObject(ship); _accountManager.DeregisterAccount(warpingPlayer.GetAccount()); }
public AreaInput() { this.Name = "Area Input"; this.Width = 2; this.Height = 3; this.Origin = new Point16(1, 1); this.Settings.Add("AreaType", AreaTypes.First()); this.RightClickHelp = "Right Click to change area type"; this.PinLayout = new List <PinDesign> { new PinDesign("In", 0, new Point16(1, 0), "int", "Distance"), new PinDesign("In", 1, new Point16(0, 1), "point", "Point"), new PinDesign("Out", 0, new Point16(1, 2), "area", "Area"), }; }
/// <summary> /// To be called just after a IShip warps /// </summary> /// <param name="s"></param> /// <param name="currentArea">The area that the IShip warped into</param> /// <param name="oldArea">The area that the IShip left</param> void OnAreaChange(IShip s, IArea currentArea, AreaTypes oldArea) { if (currentArea == null) { return; } var player = s.GetPlayer(); if (player?.ActiveShipId == s.Id) { switch (currentArea.AreaType) { case AreaTypes.StarBase: case AreaTypes.Port: switch (oldArea) { case AreaTypes.StarBase: case AreaTypes.Port: // How the heck will you ever get here? I dunno bro, just go with it. _chatManager.BroadcastChatAlert(currentArea, player.Id, player.Username + " has gone through a wormhole."); break; case AreaTypes.System: _chatManager.BroadcastChatAlert(currentArea, player.Id, player.Username + " has entered the port."); break; } break; case AreaTypes.System: switch (oldArea) { case AreaTypes.StarBase: case AreaTypes.Port: _chatManager.BroadcastChatAlert(currentArea, player.Id, player.Username + " has undocked from the port."); break; case AreaTypes.System: _chatManager.BroadcastChatAlert(currentArea, player.Id, player.Username + " has warped into the system."); break; } break; } } }
/// <summary> /// To be called just before a IShip warps /// </summary> /// <param name="s"></param> /// <param name="currentArea">The area the IShip is about to leave</param> /// <param name="newArea">The area the IShip is about to warp to</param> void OnAreaExit(IShip s, IArea currentArea, AreaTypes newArea) { if (currentArea == null) { return; } var player = s.GetPlayer(); if (player.ActiveShipId == s.Id) { switch (currentArea.AreaType) { case AreaTypes.StarBase: case AreaTypes.Port: switch (newArea) { case AreaTypes.StarBase: case AreaTypes.Port: _chatManager.BroadcastChatAlert(currentArea, player.Id, player.Username + " has entered a wormhole."); break; case AreaTypes.System: _chatManager.BroadcastChatAlert(currentArea, player.Id, player.Username + " has undocked."); break; } break; case AreaTypes.System: switch (newArea) { case AreaTypes.StarBase: case AreaTypes.Port: _chatManager.BroadcastChatAlert(currentArea, player.Id, player.Username + " has docked at the port."); break; case AreaTypes.System: _chatManager.BroadcastChatAlert(currentArea, player.Id, player.Username + " has warped out of the system."); break; } break; } } }
private List <Area> AddSubNodes(Area parent, AreaTypes type, params string[] names) { List <Area> nodes = new List <Area>(); foreach (string name in names) { if (string.IsNullOrEmpty(name)) { continue; } var node = AddTopoNode(name, "", parent, type); if (node == null) { continue; } nodes.Add(node); } return(nodes); }
static AreaTypes[] GetNeighbours(Map map, int x, int y) { var neighbours = new AreaTypes[8]; if (x > 0 && y > 0) { neighbours[0] = map.Acres[x - 1, y - 1]; } if (y > 0) { neighbours[1] = map.Acres[x, y - 1]; } if (x < 49 && y > 0) { neighbours[2] = map.Acres[x + 1, y - 1]; } if (x > 0) { neighbours[3] = map.Acres[x - 1, y]; } if (x < 49) { neighbours[4] = map.Acres[x + 1, y]; } if (x > 0 && y < 49) { neighbours[5] = map.Acres[x - 1, y + 1]; } if (y < 49) { neighbours[6] = map.Acres[x, y + 1]; } if (x < 49 && y < 49) { neighbours[7] = map.Acres[x + 1, y + 1]; } return(neighbours); }
void GenerateWorld() { for (int totalAreas = 0; totalAreas < Mathf.Pow(AreaXbyX, 2); totalAreas++) { GameObject container = Instantiate(WorldContainer, Vector3.zero, Quaternion.identity); container.name = "WorldContainer" + totalAreas; int areaType = Random.Range(0, System.Enum.GetNames(typeof(AreaTypes)).Length); if (areaType == 0) { currentArea = AreaTypes.FIELD; } else if (areaType == 1) { currentArea = AreaTypes.FIELD; } else { currentArea = AreaTypes.FIELD; //currentArea = AreaTypes.CITY; } for (int i = 0; i < CellXbyX; i++) { for (int j = 0; j < CellXbyX; j++) { if (currentArea == AreaTypes.FIELD) { GameObject newTile; float randomChance = Random.Range(0f, BasicTileChance + DecorativeTileChance); //+ BuildingTileChance); if (randomChance <= BasicTileChance) { int tileIndex = Random.Range(0, FIELD_SmallBasicTiles.Length); newTile = Instantiate(FIELD_SmallBasicTiles[tileIndex], new Vector3(i, j, 0), Quaternion.identity); } else if (randomChance <= DecorativeTileChance + BasicTileChance) { int tileIndex = Random.Range(0, FIELD_SmallDecorativeTiles.Length); newTile = Instantiate(FIELD_SmallDecorativeTiles[tileIndex], new Vector3(i, j, 0), Quaternion.identity); } else { int tileIndex = Random.Range(0, FIELD_SmallBasicTiles.Length); newTile = Instantiate(FIELD_SmallBasicTiles[tileIndex], new Vector3(i, j, 0), Quaternion.identity); /*int tileIndex = Random.Range(0, FIELD_SmallBuildingTiles.Length); * if (i-(FIELD_BuildingXSize[tileIndex]/2) > 0 && j-(FIELD_BuildingYSize[tileIndex]/2) > 0 && i + (FIELD_BuildingXSize[tileIndex] / 2) < CellXbyX && j - (FIELD_BuildingYSize[tileIndex] / 2) < CellXbyX) * { * newTile = Instantiate(FIELD_SmallBuildingTiles[tileIndex], new Vector3(i, j, 0), Quaternion.identity); * } * else * { * tileIndex = Random.Range(0, FIELD_SmallBasicTiles.Length); * newTile = Instantiate(FIELD_SmallBasicTiles[tileIndex], new Vector3(i, j, 0), Quaternion.identity); * }*/ } newTile.transform.parent = container.transform; areaMap[i, j] = newTile; } else if (currentArea == AreaTypes.FARM) { GameObject newTile; float randomChance = Random.Range(0f, BasicTileChance + DecorativeTileChance); //+ BuildingTileChance); if (randomChance <= BasicTileChance) { int tileIndex = Random.Range(0, FARM_SmallBasicTiles.Length); newTile = Instantiate(FARM_SmallBasicTiles[tileIndex], new Vector3(i, j, 0), Quaternion.identity); } else if (randomChance <= DecorativeTileChance + BasicTileChance) { int tileIndex = Random.Range(0, FARM_SmallDecorativeTiles.Length); newTile = Instantiate(FARM_SmallDecorativeTiles[tileIndex], new Vector3(i, j, 0), Quaternion.identity); } else { int tileIndex = Random.Range(0, FARM_SmallBasicTiles.Length); newTile = Instantiate(FIELD_SmallBasicTiles[tileIndex], new Vector3(i, j, 0), Quaternion.identity); /*int tileIndex = Random.Range(0, FARM_SmallBuildingTiles.Length); * if (i - (FARM_BuildingXSize[tileIndex] / 2) > 0 && j - (FARM_BuildingYSize[tileIndex] / 2) > 0 && i + (FARM_BuildingXSize[tileIndex] / 2) < CellXbyX && j - (FARM_BuildingYSize[tileIndex] / 2) < CellXbyX) * { * newTile = Instantiate(FARM_SmallBuildingTiles[tileIndex], new Vector3(i, j, 0), Quaternion.identity); * } * else * { * tileIndex = Random.Range(0, FARM_SmallBasicTiles.Length); * newTile = Instantiate(FARM_SmallBasicTiles[tileIndex], new Vector3(i, j, 0), Quaternion.identity); * }*/ } newTile.transform.parent = container.transform; areaMap[i, j] = newTile; } else if (currentArea == AreaTypes.CITY) { GameObject newTile; float randomChance = Random.Range(0f, BasicTileChance + DecorativeTileChance); // + BuildingTileChance); if (randomChance <= BasicTileChance) { int tileIndex = Random.Range(0, CITY_SmallBasicTiles.Length); newTile = Instantiate(CITY_SmallBasicTiles[tileIndex], new Vector3(i, j, 0), Quaternion.identity); } else if (randomChance <= DecorativeTileChance + BasicTileChance) { int tileIndex = Random.Range(0, CITY_SmallDecorativeTiles.Length); newTile = Instantiate(CITY_SmallDecorativeTiles[tileIndex], new Vector3(i, j, 0), Quaternion.identity); } else { int tileIndex = Random.Range(0, CITY_SmallBasicTiles.Length); newTile = Instantiate(CITY_SmallBasicTiles[tileIndex], new Vector3(i, j, 0), Quaternion.identity); /*int tileIndex = Random.Range(0, CITY_SmallBuildingTiles.Length); * if (i - (CITY_BuildingXSize[tileIndex] / 2) > 0 && j - (CITY_BuildingYSize[tileIndex] / 2) > 0 && i + (CITY_BuildingXSize[tileIndex] / 2) < CellXbyX && j - (CITY_BuildingYSize[tileIndex] / 2) < CellXbyX) * { * newTile = Instantiate(CITY_SmallBuildingTiles[tileIndex], new Vector3(i, j, 0), Quaternion.identity); * } * else * { * tileIndex = Random.Range(0, CITY_SmallBasicTiles.Length); * newTile = Instantiate(CITY_SmallBasicTiles[tileIndex], new Vector3(i, j, 0), Quaternion.identity); * }*/ } newTile.transform.parent = container.transform; areaMap[i, j] = newTile; } //Debug.Log("Tile Complete: " + (j * i)); } } worldMap[totalAreas] = areaMap; //Debug.Log("Area Complete: " + (totalAreas + 1)); } GameObject[] containers = GameObject.FindGameObjectsWithTag("World"); int containerNum = 0; for (int x = 0; x < AreaXbyX; x++) { for (int y = 0; y < AreaXbyX; y++) { containers[containerNum].transform.position = new Vector2(x * CellXbyX, y * CellXbyX); containerNum++; } } foreach (GameObject[,] item in worldMap) { foreach (GameObject i in item) { Debug.Log(i.name); } } }
private Area AddTopoNode(string name, string kks, Area parent, AreaTypes type, TransformM transform = null, string otherName = "") { if (string.IsNullOrEmpty(kks)) { KKSCode kksCode = KKSCodes.DbSet.FirstOrDefault(i => i.Name.Contains(name) && i.MainType == "土建"); if (kksCode != null) { kks = kksCode.Code; } } if (!string.IsNullOrEmpty(kks)) { var topoNode = new Area() { Name = name, ParentId = parent.Id, Type = type, //Transfrom = transform, }; topoNode.SetTransform(transform); Areas.Add(topoNode); KKSCode kksCode = KKSCodes.DbSet.FirstOrDefault(i => i.Code == kks); NodeKKS kks1 = null; if (kksCode != null) { kks1 = new NodeKKS() { KKS = kks, NodeType = type, NodeId = topoNode.Id, KKSId = kksCode.Id }; NodeKKSs.Add(kks1); } else { kks1 = new NodeKKS() { KKS = kks, NodeType = type, NodeId = topoNode.Id }; NodeKKSs.Add(kks1); } topoNode.KKS = kks1.KKS; //topoNode.Nodekks = kks1; //topoNode.NodekksId = kks1.Id; Areas.Edit(topoNode); return(topoNode); } else { var topoNode = new Area() { Name = name, ParentId = parent.Id, Type = type, //Transfrom = transform }; topoNode.SetTransform(transform); bool result = Areas.Add(topoNode); return(topoNode); } }
private static AreaType GetAreaTypeFromTag(object element) { string areaTypeName = (string)((FrameworkElement)element).Tag; return(AreaTypes.GetByName(areaTypeName)); }
public FixedAreaEntrances GetFixedAreaEntranceForAreaType(AreaTypes aType) { return(entrances.Find(x => x.areaFrom == aType)); }
public bool IsApplicable(AreaTypes current) { return(Applicable(current)); }
public Models.Search.SearchAreaModel GenerateSearchArea(string name, AreaTypes areaType, ParseGeoPoint northeastGeopoint, ParseGeoPoint southwestGeopoint) { Guid id = Guid.NewGuid(); string id_str = id.ToString(); double neLng = northeastGeopoint.Longitude; double neLat = northeastGeopoint.Latitude; double swLng = southwestGeopoint.Longitude; double swLat = southwestGeopoint.Latitude; SearchAreaModel searchAreaModel = new SearchAreaModel(id_str, name, areaType, northeastGeopoint, neLng, neLat, swLng, swLat, false); return searchAreaModel; }
public PathedArea GetAreaOfType(AreaTypes aType) { return(allPathedAreas.Find(x => x.thisPathedArea.thisAreaType == aType).thisPathedArea); }
public TopoInfo(string name, AreaTypes type) { Name = name; Type = type; }