protected override void Execute(CallArgs args)
        {
            ServerGameMode sgm = args.Get <ServerGameMode>(0);

            serverConfig.GameModeEnum = sgm;
            SendMessage(args.Sender, $"Server gamemode changed to \"{sgm}\" by {args.SenderName}");
        }
示例#2
0
        protected override void Execute(CallArgs args)
        {
            ServerGameMode sgm = args.Get <ServerGameMode>(0);

            serverConfig.GameModeEnum = sgm;
            playerManager.SendPacketToAllPlayers(new GameModeChanged(sgm));

            SendMessageToAllPlayers($"Server gamemode changed to \"{sgm}\" by {args.SenderName}");
        }
示例#3
0
        public World CreateWorld(PersistedWorldData pWorldData, ServerGameMode gameMode)
        {
            string seed = pWorldData.WorldData.Seed;

            if (string.IsNullOrWhiteSpace(seed))
            {
                seed = StringHelper.GenerateRandomString(10);
            }

            Log.Info($"Loading world with seed {seed}");

            World world = new()
            {
                TimeKeeper = new TimeKeeper {
                    ServerStartTime = pWorldData.WorldData.ServerStartTime
                },

                SimulationOwnershipData = new SimulationOwnershipData(),
                PlayerManager           = new PlayerManager(pWorldData.PlayerData.GetPlayers(), config),

                BaseManager = new BaseManager(pWorldData.BaseData.PartiallyConstructedPieces, pWorldData.BaseData.CompletedBasePieceHistory),

                InventoryManager = new InventoryManager(pWorldData.WorldData.InventoryData.InventoryItems, pWorldData.WorldData.InventoryData.StorageSlotItems, pWorldData.WorldData.InventoryData.Modules),

                EscapePodManager = new EscapePodManager(pWorldData.WorldData.EscapePodData.EscapePods, randomStart, seed),

                GameData = pWorldData.WorldData.GameData,
                GameMode = gameMode,
                Seed     = seed
            };

            world.EventTriggerer = new EventTriggerer(world.PlayerManager, pWorldData.WorldData.GameData.StoryTiming.ElapsedTime, pWorldData.WorldData.GameData.StoryTiming.AuroraExplosionTime);
            world.VehicleManager = new VehicleManager(pWorldData.WorldData.VehicleData.Vehicles, world.InventoryManager);

            world.BatchEntitySpawner = new BatchEntitySpawner(
                NitroxServiceLocator.LocateService <EntitySpawnPointFactory>(),
                NitroxServiceLocator.LocateService <UweWorldEntityFactory>(),
                NitroxServiceLocator.LocateService <UwePrefabFactory>(),
                pWorldData.WorldData.ParsedBatchCells,
                protoBufSerializer,
                NitroxServiceLocator.LocateService <Dictionary <NitroxTechType, IEntityBootstrapper> >(),
                NitroxServiceLocator.LocateService <Dictionary <string, PrefabPlaceholdersGroupAsset> >(),
                world.Seed
                );

            world.EntityManager = new EntityManager(pWorldData.EntityData.Entities, world.BatchEntitySpawner);

            HashSet <NitroxTechType> serverSpawnedSimulationWhiteList = NitroxServiceLocator.LocateService <HashSet <NitroxTechType> >();

            world.EntitySimulation = new EntitySimulation(world.EntityManager, world.SimulationOwnershipData, world.PlayerManager, serverSpawnedSimulationWhiteList);

            return(world);
        }
    }
示例#4
0
        private World CreateWorld(DateTime serverStartTime,
                                  List <Entity> entities,
                                  List <BasePiece> partiallyConstructedPieces,
                                  List <BasePiece> completedBasePieceHistory,
                                  List <VehicleModel> vehicles,
                                  List <Player> players,
                                  List <ItemData> inventoryItems,
                                  List <ItemData> storageSlotItems,
                                  GameData gameData,
                                  List <NitroxInt3> parsedBatchCells,
                                  List <EscapePodModel> escapePods,
                                  StoryTimingData storyTimingData,
                                  ServerGameMode gameMode)
        {
            World world = new World
            {
                TimeKeeper = new TimeKeeper {
                    ServerStartTime = serverStartTime
                },
                SimulationOwnershipData = new SimulationOwnershipData(),
                PlayerManager           = new PlayerManager(players, config),
                BaseManager             = new BaseManager(partiallyConstructedPieces, completedBasePieceHistory),
                InventoryManager        = new InventoryManager(inventoryItems, storageSlotItems),
                EscapePodManager        = new EscapePodManager(escapePods),
                GameData = gameData,
                GameMode = gameMode
            };

            world.EventTriggerer = new EventTriggerer(world.PlayerManager, storyTimingData.ElapsedTime, storyTimingData.AuroraExplosionTime);
            world.VehicleManager = new VehicleManager(vehicles, world.InventoryManager);

            world.BatchEntitySpawner = new BatchEntitySpawner(
                NitroxServiceLocator.LocateService <EntitySpawnPointFactory>(),
                NitroxServiceLocator.LocateService <UweWorldEntityFactory>(),
                NitroxServiceLocator.LocateService <UwePrefabFactory>(),
                parsedBatchCells,
                protoBufSerializer,
                NitroxServiceLocator.LocateService <Dictionary <NitroxTechType, IEntityBootstrapper> >(),
                NitroxServiceLocator.LocateService <Dictionary <string, PrefabPlaceholdersGroupAsset> >()
                );

            world.EntityManager = new EntityManager(entities, world.BatchEntitySpawner);

            HashSet <NitroxTechType> serverSpawnedSimulationWhiteList = NitroxServiceLocator.LocateService <HashSet <NitroxTechType> >();

            world.EntitySimulation = new EntitySimulation(world.EntityManager, world.SimulationOwnershipData, world.PlayerManager, serverSpawnedSimulationWhiteList);

            return(world);
        }
示例#5
0
 public InitialPlayerSync(NitroxId playerGameObjectId,
                          bool firstTimeConnecting,
                          IEnumerable <EscapePodModel> escapePodsData,
                          NitroxId assignedEscapePodId,
                          IEnumerable <EquippedItemData> equipment,
                          IEnumerable <EquippedItemData> modules,
                          IEnumerable <BasePiece> basePieces,
                          IEnumerable <VehicleModel> vehicles,
                          IEnumerable <ItemData> inventoryItems,
                          IEnumerable <ItemData> storageSlotItems,
                          IEnumerable <NitroxTechType> usedItems,
                          IEnumerable <string> quickSlotsBinding,
                          InitialPDAData pdaData,
                          InitialStoryGoalData storyGoalData,
                          HashSet <string> completedGoals,
                          NitroxVector3 playerSpawnData,
                          Optional <NitroxId> playerSubRootId,
                          PlayerStatsData playerStatsData,
                          IEnumerable <InitialRemotePlayerData> remotePlayerData,
                          IEnumerable <Entity> globalRootEntities,
                          IEnumerable <NitroxId> initialSimulationOwnerships,
                          ServerGameMode gameMode,
                          Perms perms)
 {
     EscapePodsData              = escapePodsData.ToList();
     AssignedEscapePodId         = assignedEscapePodId;
     PlayerGameObjectId          = playerGameObjectId;
     FirstTimeConnecting         = firstTimeConnecting;
     EquippedItems               = equipment.ToList();
     Modules                     = modules.ToList();
     BasePieces                  = basePieces.ToList();
     Vehicles                    = vehicles.ToList();
     InventoryItems              = inventoryItems.ToList();
     StorageSlotItems            = storageSlotItems.ToList();
     UsedItems                   = usedItems.ToList();
     QuickSlotsBinding           = quickSlotsBinding.ToList();
     PDAData                     = pdaData;
     StoryGoalData               = storyGoalData;
     CompletedGoals              = completedGoals;
     PlayerSpawnData             = playerSpawnData;
     PlayerSubRootId             = playerSubRootId;
     PlayerStatsData             = playerStatsData;
     RemotePlayerData            = remotePlayerData.ToList();
     GlobalRootEntities          = globalRootEntities.ToList();
     InitialSimulationOwnerships = initialSimulationOwnerships.ToList();
     GameMode                    = gameMode;
     Permissions                 = perms;
 }
示例#6
0
        protected override void Execute(CallArgs args)
        {
            ServerGameMode sgm = args.Get <ServerGameMode>(0);

            serverConfig.Update(c =>
            {
                if (c.GameMode != sgm)
                {
                    c.GameMode = sgm;

                    playerManager.SendPacketToAllPlayers(new GameModeChanged(sgm));
                    SendMessageToAllPlayers($"Server gamemode changed to \"{sgm}\" by {args.SenderName}");
                }
                else
                {
                    SendMessage(args.Sender, "Server is already using this gamemode");
                }
            });
        }
示例#7
0
        public ServerConfig(int port, int saveinterval, int maxconnection, bool disableconsole, bool disableautosave, string savename, string serverpassword, string adminpassword, ServerGameMode gamemode, ServerSerializerMode serverserializermode)
        {
            portSetting            = new ServerConfigItem <int>("Port", port);
            saveIntervalSetting    = new ServerConfigItem <int>("SaveInterval", saveinterval);
            maxConnectionsSetting  = new ServerConfigItem <int>("MaxConnections", maxconnection);
            disableConsoleSetting  = new ServerConfigItem <bool>("DisableConsole", disableconsole);
            disableAutoSaveSetting = new ServerConfigItem <bool>("DisableAutoSave", disableautosave);
            saveNameSetting        = new ServerConfigItem <string>("SaveName", savename);
            serverPasswordSetting  = new ServerConfigItem <string>("ServerPassword", serverpassword);
            adminPasswordSetting   = new ServerConfigItem <string>("AdminPassword", adminpassword);
            gameModeSetting        = new ServerConfigItem <ServerGameMode>("GameMode", gamemode);
            serverSerializerMode   = new ServerConfigItem <string>("ServerSerializerMode", serverserializermode.ToString());

            //We don't want to custom those values for now
            oxygenSetting    = new ServerConfigItem <float>("StartOxygen", 45);
            maxOxygenSetting = new ServerConfigItem <float>("StartMaxOxygen", 45);
            healthSetting    = new ServerConfigItem <float>("StartHealth", 80);
            foodSetting      = new ServerConfigItem <float>("StartFood", 50.5f);
            waterSetting     = new ServerConfigItem <float>("StartWater", 90.5f);
            infectionSetting = new ServerConfigItem <float>("StartInfection", 0);
        }
 private void SetPlayerGameMode(ServerGameMode gameMode)
 {
     Log.Info($"Received initial sync packet with gamemode {gameMode}");
     GameModeUtils.SetGameMode((GameModeOption)(int)gameMode, GameModeOption.None);
 }
示例#9
0
 public GameModeChanged(ServerGameMode gameMode)
 {
     GameMode = gameMode;
 }