public void UpdateWorld(ServerWorld world, string id) { string url = WORLDS_ENDPOINT + id; string json = JsonConvert.SerializeObject(world); StartCoroutine(Put(url, json)); }
public void Initialize(ServerWorld world, ServerStateSettings settings) { _world = world; _settings = (LoadServerRoomSettings)settings; _settings.Hide(); _transitionState = ServerStateId.NO_TRANSITION; }
public Server() { instance = this; serverWorld = new ServerWorld(); networkServer = new NetworkServer(serverWorld); }
public void CreateWorld(ServerWorld world, System.Action <string> callBack) { string json = JsonConvert.SerializeObject(world, serializationSettings); Debug.Log(json); StartCoroutine(Post(WORLDS_ENDPOINT, json, callBack)); }
public void CreateButtonClicked() { ServerWorld serverWorld = worldManager.CreateWorld(newWorldInput.text); AddItem(serverWorld); newWorldInput.text = ""; }
public ServerWorldHost() { var services = new ServiceCollection(); services.AddLogging(builder => { builder.AddConsole(); builder.SetMinimumLevel(LogLevel.Trace); }); var commandType = typeof(GameCommand); IEnumerable <Type> eventTypes = new List <Type> { typeof(GameActionEvent), }; IEnumerable <KeyValuePair <Type, Type> > entityTypes = new Dictionary <Type, Type> { [typeof(ServerControlledEntity)] = typeof(MyState), [typeof(ServerDummyEntity)] = typeof(DummyEntityState), [typeof(ServerMimicEntity)] = typeof(MyState), }; var pools = new ServerPools(commandType, eventTypes, entityTypes); var manager = new ServerWorld(new ServerGameProtocol(pools), pools); //var manager = new ServerWorld(new MessagePackServerPacketProtocol(), pools); services.AddSingleton(manager); ServiceProvider = services.BuildServiceProvider(); InitializeCommon(); Initialize(); }
public void Start() { //database Database.Connect(); //hackshiedl Hackshield.Load(); //get path to config files string configPath = Path.Combine(Environment.CurrentDirectory, Settings.Default.ConfigPath); //load config files ConfigManager.LoadConfigFiles(configPath); //read config files ConfigManager.ReadConfig(); //load item codes Configs.Items.ItemCodes.CodeManager.Load(); //load chat manager Chat.ChatManager.Load(); //prepare a new world ServerWorld.Load(2); //start server ProcessConnectionsThread = new Thread( new ThreadStart(Server.ProcessConnections) ); ProcessConnectionsThread.Start(); Thinker.Start(); ServerConsole.WriteLine("Server started on port {0}", MessageLevel.Message, Settings.Default.Port); }
public void SaveGameState(ServerWorld world) { string serializedObject = JsonConvert.SerializeObject(world, serializationSettings); Debug.Log(serializedObject); APIService.Instance.UpdateWorld(world, world.id); }
public ServerChunkProvider(ServerWorld world) { _mainThread = Thread.CurrentThread; _world = world; _manager = new ChunkManager(_world, new ChunkGenerator()); InvalidateCaches(); }
public void Initialize(ServerWorld world, ServerStateSettings settings) { _world = world; _network = _world.GetServerNode(); _settings = (LaunchServerSettings)settings; _settings.Hide(); _transitionState = ServerStateId.NO_TRANSITION; }
public void GetSharedWorld(string shareCode, System.Action <ServerWorld> callBack) { string url = SHARED_WORLDS_ENDPOINT + shareCode; StartCoroutine(Get(url, (jsonData) => { Debug.Log(jsonData); ServerWorld worlds = JsonConvert.DeserializeObject <ServerWorld>(jsonData); callBack(worlds); })); }
private void AddItem(ServerWorld world) { GameObject newItem = Instantiate(worldItemPrefab); // set parent newItem.transform.SetParent(contentPanel, false); // initialise WorldItem worldItem = newItem.GetComponent <WorldItem>(); worldItem.Initialise(world, loader); }
public void Dispose() { ServerWorld?.Dispose(); ClientWorld?.Dispose(); DefaultWorld?.Dispose(); ServerWorld = null; ClientWorld = null; DefaultWorld = null; ClientServerBootstrap.SystemStates = _oldState; }
private static void ServerCharacterJoinedOrLeftFactionHandler( ICharacter character, ILogicObject faction, bool isJoined) { if (isJoined) { ServerRefreshFactionClaimAccess(faction); return; } // left the faction - remove the faction claims from the character's private scope var ownedAreas = SharedGetPlayerOwnedAreas(character); using var tempList = Api.Shared.WrapInTempList( (ICollection <ILogicObject>)ownedAreas); foreach (var area in tempList.AsList()) { var owners = area.GetPrivateState <LandClaimAreaPrivateState>().ServerGetLandOwners(); if (owners is null) { continue; } var isOwner = false; foreach (var owner in owners) { if (character.Name != owner) { continue; } isOwner = true; break; } if (isOwner) { continue; } ownedAreas.Remove(area); if (character.ServerIsOnline) { ServerWorld.ExitPrivateScope(character, area); } } }
public void Tick(float dt) { ElapsedTime += dt; DefaultWorld.SetTime(new TimeData(ElapsedTime, dt)); ServerWorld?.SetTime(new TimeData(ElapsedTime, dt)); ClientWorld?.SetTime(new TimeData(ElapsedTime, dt)); ServerWorld?.GetExistingSystem <ServerInitializationSystemGroup>().Update(); ClientWorld.GetExistingSystem <ClientInitializationSystemGroup>().Update(); DefaultWorld.GetExistingSystem <ChainServerSimulationSystem>().Update(); DefaultWorld.GetExistingSystem <ChainClientSimulationSystem>().Update(); ClientWorld.GetExistingSystem <ClientPresentationSystemGroup>().Update(); }
private void NewClientServer() { ushort port = (ushort)(21650 + testCount); Debug.Log(port); serverOptions = new ServerOptions { Address = "0.0.0.0", Port = port, WorldName = $"Test_Connection_Server{testCount}", GhostCollectionPrefab = prefab }; clientOptions = new ClientOptions { Address = "127.0.0.1", Port = port, TimeOut = 5, WorldName = $"Test_Connection_Client{testCount}", GhostCollectionPrefab = prefab }; serverWorld = new ServerWorld(serverOptions); clientWorld = new ClientWorld(clientOptions); serverWorld.ListenSuccess += () => { Debug.Log($"{serverOptions.WorldName}: Listening"); serverListening = true; }; clientWorld.Connecting += () => { Debug.Log($"{clientOptions.WorldName}: Connecting"); clientConnecting = true; }; clientWorld.Connected += x => { Debug.Log($"{clientOptions.WorldName}: Connected"); clientConnected = true; }; clientWorld.ConnectionFailed += x => { Debug.Log($"{clientOptions.WorldName}: Connect Failed: " + x); clientConnectFailed = true; }; testCount++; }
public static void SpawnPlayer(Client Client, PacketIn packet) { if (Client.Authenticated) { ServerWorld.AddEntity(Client.Character); Client.Send(new Packets.SendSkills(Client.Character.Player)); if (Client.Character.Inventory.Items.Count > 0) { Client.Send(new Packets.SendInventory(Client.Character.Inventory)); } else { Client.Send(new Packets.LoginAccepted()); } Client.Send(new Packets.SpawnPlayer(Client.Character, true)); } }
public NetworkServer(ServerWorld serverWorld) { var netListener = new EventBasedNetListener(); netListener.ConnectionRequestEvent += ConnectionRequestEvent; netListener.PeerConnectedEvent += PeerConnectedEvent; netListener.NetworkReceiveEvent += OnNetworkReceive; netManager = new NetManager(netListener); netManager.Start(GameConfig.serverPort); this.serverWorld = serverWorld; // simulate extra latency netManager.SimulateLatency = true; netManager.SimulationMinLatency = 100; netManager.SimulationMaxLatency = 150; }
public void Initialise(ServerWorld serverWorld, GameObject loader) { // set world item properties this.loader = loader; this.world = serverWorld; worldNameText.text = serverWorld.world.Name; carbonCreditsText.text = serverWorld.world.ResourceData.Money.ToString(); populationText.text = serverWorld.world.ResourceData.Population.ToString(); if (serverWorld.shareCode != null) { sharePanel.SetActive(true); sharePanel.GetComponentInChildren <Text>().text = serverWorld.shareCode; } else { sharePanel.SetActive(false); } }
public bool Connect(float dt, int maxSteps = 4) { var ep = NetworkEndPoint.LoopbackIpv4; ep.Port = 7979; ServerWorld.GetExistingSystem <NetworkStreamReceiveSystem>().Listen(ep); ClientWorld.GetExistingSystem <NetworkStreamReceiveSystem>().Connect(ep); while (TryGetSingletonEntity <NetworkIdComponent>(ClientWorld) == Entity.Null) { if (maxSteps <= 0) { return(false); } --maxSteps; Tick(dt); } return(true); }
public void Initialize(ServerWorld world, ServerStateSettings settings) { _world = world; _network = _world.GetServerNode(); _settings = (HostingSettings)settings; _settings.Hide(); _transitionState = ServerStateId.NO_TRANSITION; int maxChars = _network.GetMaxMessageLength() / sizeof(char); _charBuffer = new char[maxChars]; _sb = new StringBuilder(maxChars); if (_settings.randomSeed != 0) { _random = new Random(_settings.randomSeed); } else { _random = new Random(); } }
private void CreateWorld() { _serverWorld = new ServerWorld(); CreateSpawnPosition(); }
/// <summary> /// Unspawn a player /// </summary> public void UnspawnPlayer() { Database.Update(Database.KalDB, Character.Player); ServerWorld.RemoveEntity(Character); Character = null; }
public Task <Chunk> DoLoadingWork(ServerWorld serverWorld, ChunkGenerator generator, Func <Chunk, Task <Chunk> > func, Chunk chunk) { return(_loadingWorker(this, serverWorld, generator, func, chunk)); }
public Task <Chunk> DoGenerationWork(ServerWorld serverWorld, ChunkGenerator generator, Func <Chunk, Task <Chunk> > func, Chunk[] chunks) { return(_generationWorker(this, serverWorld, generator, func, chunks, chunks[chunks.Length / 2])); }
public void DeleteWorld(ServerWorld serverWorld) { APIService.Instance.DeleteWorld(serverWorld.id); }