コード例 #1
0
ファイル: Main.cs プロジェクト: CHazz/DUXDMP
        public void Start()
        {
            TimingManager.FixedUpdateAdd(TimingManager.TimingStage.BetterLateThanNever, TimingManagerFixedUpdate);
            dmpDir      = Path.Combine(Path.Combine(Path.Combine(KSPUtil.ApplicationRootPath, "GameData"), "DarkMultiPlayer"), "Plugins");
            dmpDataDir  = Path.Combine(dmpDir, "Data");
            gameDataDir = Path.Combine(KSPUtil.ApplicationRootPath, "GameData");
            kspRootPath = KSPUtil.ApplicationRootPath;

            //Fix DarkLog time/thread marker in the log during init.
            DarkLog.SetMainThread();
            lastClockTicks           = DateTime.UtcNow.Ticks;
            lastRealTimeSinceStartup = 0f;

            dmpClient         = this;
            dmpSettings       = new Settings();
            toolbarSupport    = new ToolbarSupport(dmpSettings);
            universeSyncCache = new UniverseSyncCache(dmpSettings);
            modWindow         = new ModWindow();
            modWorker         = new ModWorker(modWindow);
            modWindow.SetDependenices(modWorker);
            universeConverter       = new UniverseConverter(dmpSettings);
            universeConverterWindow = new UniverseConverterWindow(universeConverter);
            optionsWindow           = new OptionsWindow(dmpSettings, universeSyncCache, modWorker, universeConverterWindow, toolbarSupport);
            connectionWindow        = new ConnectionWindow(dmpSettings, optionsWindow);
            disclaimerWindow        = new DisclaimerWindow(dmpSettings);
            dmpModInterface         = new DMPModInterface();
            SafetyBubble.RegisterDefaultLocations();

            if (!CompatibilityChecker.IsCompatible() || !InstallChecker.IsCorrectlyInstalled())
            {
                modDisabled = true;
            }

            if (dmpSettings.disclaimerAccepted != 1)
            {
                modDisabled = true;
                disclaimerWindow.SpawnDialog();
            }

            Profiler.DMPReferenceTime.Start();
            DontDestroyOnLoad(this);

            // Prevents symlink warning for development.
            SetupDirectoriesIfNeeded();

            // UniverseSyncCache needs to run expiry here
            universeSyncCache.ExpireCache();

            GameEvents.onHideUI.Add(() =>
            {
                showGUI = false;
            });
            GameEvents.onShowUI.Add(() =>
            {
                showGUI = true;
            });

            HandleCommandLineArgs();
            DarkLog.Debug("DarkMultiPlayer " + Common.PROGRAM_VERSION + ", protocol " + Common.PROTOCOL_VERSION + " Initialized!");
        }
コード例 #2
0
        public Client()
        {
#if DEBUG
            dmpDir = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
#else
            dmpDir = Path.Combine(Path.Combine(Path.Combine(KSPUtil.ApplicationRootPath, "GameData"), "DarkMultiPlayer"), "Plugins");
#endif
            dmpDataDir  = Path.Combine(dmpDir, "Data");
            gameDataDir = Path.GetFullPath(Path.Combine(dmpDir, "../../"));
            kspRootPath = Path.GetFullPath(Path.Combine(gameDataDir, "../"));

            //Fix DarkLog time/thread marker in the log during init.
            DarkLog.SetMainThread();
            lastClockTicks           = DateTime.UtcNow.Ticks;
            lastRealTimeSinceStartup = 0f;

            dmpClient         = this;
            dmpSettings       = new Settings();
            toolbarSupport    = new ToolbarSupport(dmpSettings);
            universeSyncCache = new UniverseSyncCache(dmpSettings);
            modWindow         = new ModWindow();
            modWorker         = new ModWorker(modWindow);
            modWindow.SetDependenices(modWorker);
            universeConverter       = new UniverseConverter(dmpSettings);
            universeConverterWindow = new UniverseConverterWindow(universeConverter);
            optionsWindow           = new OptionsWindow(dmpSettings, universeSyncCache, modWorker, universeConverterWindow, toolbarSupport);
            connectionWindow        = new ConnectionWindow(dmpSettings, optionsWindow);
            disclaimerWindow        = new DisclaimerWindow(dmpSettings);
            dmpModInterface         = new DMPModInterface();
        }
コード例 #3
0
 public ConnectionWindow(Settings dmpSettings, OptionsWindow optionsWindow, ServersWindow serversWindow, ServerListDisclaimerWindow serverListDisclaimerWindow)
 {
     this.dmpSettings   = dmpSettings;
     this.optionsWindow = optionsWindow;
     this.serversWindow = serversWindow;
     this.serverListDisclaimerWindow = serverListDisclaimerWindow;
 }
コード例 #4
0
 public DebugWindow(DMPGame dmpGame, Settings dmpSettings, TimeSyncer timeSyncer, NetworkWorker networkWorker, VesselWorker vesselWorker, DynamicTickWorker dynamicTickWorker, WarpWorker warpWorker, VesselRecorder vesselRecorder, PosistionStatistics posistionStatistics, OptionsWindow optionsWindow)
 {
     this.dmpGame             = dmpGame;
     this.dmpSettings         = dmpSettings;
     this.timeSyncer          = timeSyncer;
     this.networkWorker       = networkWorker;
     this.vesselWorker        = vesselWorker;
     this.dynamicTickWorker   = dynamicTickWorker;
     this.warpWorker          = warpWorker;
     this.vesselRecorder      = vesselRecorder;
     this.posistionStatistics = posistionStatistics;
     this.optionsWindow       = optionsWindow;
     dmpGame.updateEvent.Add(Update);
     dmpGame.drawEvent.Add(Draw);
 }
コード例 #5
0
 public PlayerStatusWindow(DMPGame dmpGame, Settings dmpSettings, WarpWorker warpWorker, ChatWorker chatWorker, CraftLibraryWorker craftLibraryWorker, DebugWindow debugWindow, ScreenshotWorker screenshotWorker, TimeSyncer timeSyncer, PlayerStatusWorker playerStatusWorker, OptionsWindow optionsWindow, PlayerColorWorker playerColorWorker)
 {
     this.dmpGame            = dmpGame;
     this.dmpSettings        = dmpSettings;
     this.warpWorker         = warpWorker;
     this.chatWorker         = chatWorker;
     this.craftLibraryWorker = craftLibraryWorker;
     this.debugWindow        = debugWindow;
     this.screenshotWorker   = screenshotWorker;
     this.timeSyncer         = timeSyncer;
     this.playerStatusWorker = playerStatusWorker;
     this.optionsWindow      = optionsWindow;
     this.playerColorWorker  = playerColorWorker;
     dmpGame.updateEvent.Add(Update);
     dmpGame.drawEvent.Add(Draw);
 }
コード例 #6
0
 public PlayerStatusWindow(DMPGame dmpGame, Settings dmpSettings, WarpWorker warpWorker, ChatWorker chatWorker, CraftLibraryWorker craftLibraryWorker, ScreenshotWorker screenshotWorker, TimeSyncer timeSyncer, PlayerStatusWorker playerStatusWorker, OptionsWindow optionsWindow, PlayerColorWorker playerColorWorker, GroupsWindow groupsWindow, PermissionsWindow permissionsWindow)
 {
     this.dmpGame            = dmpGame;
     this.dmpSettings        = dmpSettings;
     this.warpWorker         = warpWorker;
     this.chatWorker         = chatWorker;
     this.craftLibraryWorker = craftLibraryWorker;
     this.screenshotWorker   = screenshotWorker;
     this.timeSyncer         = timeSyncer;
     this.playerStatusWorker = playerStatusWorker;
     this.optionsWindow      = optionsWindow;
     this.playerColorWorker  = playerColorWorker;
     this.groupsWindow       = groupsWindow;
     this.permissionsWindow  = permissionsWindow;
     updateAction            = new NamedAction(Update);
     drawAction = new NamedAction(Draw);
     this.dmpGame.updateEvent.Add(updateAction);
     this.dmpGame.drawEvent.Add(drawAction);
 }
コード例 #7
0
ファイル: Main.cs プロジェクト: zstone23/DarkMultiPlayer
        public Client()
        {
            //Fix DarkLog time/thread marker in the log during init.
            DarkLog.SetMainThread();
            lastClockTicks           = DateTime.UtcNow.Ticks;
            lastRealTimeSinceStartup = Time.realtimeSinceStartup;

            dmpClient         = this;
            dmpSettings       = new Settings();
            toolbarSupport    = new ToolbarSupport(dmpSettings);
            universeSyncCache = new UniverseSyncCache(dmpSettings);
            modWindow         = new ModWindow();
            modWorker         = new ModWorker(modWindow);
            modWindow.SetDependenices(modWorker);
            universeConverter       = new UniverseConverter(dmpSettings);
            universeConverterWindow = new UniverseConverterWindow(universeConverter);
            optionsWindow           = new OptionsWindow(dmpSettings, universeSyncCache, modWorker, universeConverterWindow, toolbarSupport);
            connectionWindow        = new ConnectionWindow(dmpSettings, optionsWindow);
            disclaimerWindow        = new DisclaimerWindow(dmpSettings);
            dmpModInterface         = new DMPModInterface();
        }
コード例 #8
0
ファイル: DMPGame.cs プロジェクト: SuumCW/DarkMultiPlayer
 public DMPGame(Settings dmpSettings, UniverseSyncCache universeSyncCache, ModWorker modWorker, ConnectionWindow connectionWindow, DMPModInterface dmpModInterface, ToolbarSupport toolbarSupport, OptionsWindow optionsWindow)
 {
     this.dmpSettings          = dmpSettings;
     this.universeSyncCache    = universeSyncCache;
     this.modWorker            = modWorker;
     this.connectionWindow     = connectionWindow;
     this.dmpModInterface      = dmpModInterface;
     this.configNodeSerializer = new ConfigNodeSerializer();
     this.posistionStatistics  = new PosistionStatistics();
     this.networkWorker        = new NetworkWorker(this, dmpSettings, connectionWindow, modWorker, configNodeSerializer);
     this.adminSystem          = new AdminSystem(dmpSettings);
     this.flagSyncer           = new FlagSyncer(this, dmpSettings, networkWorker);
     this.lockSystem           = new LockSystem(dmpSettings, networkWorker);
     this.partKiller           = new PartKiller(lockSystem);
     this.dynamicTickWorker    = new DynamicTickWorker(this, networkWorker);
     this.kerbalReassigner     = new KerbalReassigner();
     this.vesselPackedUpdater  = new VesselPackedUpdater(lockSystem, posistionStatistics);
     this.vesselWorker         = new VesselWorker(this, dmpSettings, modWorker, lockSystem, networkWorker, configNodeSerializer, dynamicTickWorker, kerbalReassigner, partKiller, posistionStatistics, vesselPackedUpdater);
     this.scenarioWorker       = new ScenarioWorker(this, vesselWorker, configNodeSerializer, networkWorker);
     this.playerStatusWorker   = new PlayerStatusWorker(this, dmpSettings, vesselWorker, lockSystem, networkWorker);
     this.timeSyncer           = new TimeSyncer(this, networkWorker, vesselWorker);
     this.warpWorker           = new WarpWorker(this, dmpSettings, timeSyncer, networkWorker, playerStatusWorker);
     this.chatWorker           = new ChatWorker(this, dmpSettings, networkWorker, adminSystem, playerStatusWorker);
     this.screenshotWorker     = new ScreenshotWorker(this, dmpSettings, chatWorker, networkWorker, playerStatusWorker);
     this.vesselRecorder       = new VesselRecorder(this, warpWorker, vesselWorker);
     this.debugWindow          = new DebugWindow(this, dmpSettings, timeSyncer, networkWorker, vesselWorker, dynamicTickWorker, warpWorker, vesselRecorder, posistionStatistics);
     this.craftLibraryWorker   = new CraftLibraryWorker(this, dmpSettings, networkWorker);
     this.hackyInAtmoLoader    = new HackyInAtmoLoader(this, lockSystem, vesselWorker);
     this.asteroidWorker       = new AsteroidWorker(this, lockSystem, networkWorker, vesselWorker);
     this.playerColorWorker    = new PlayerColorWorker(dmpSettings, lockSystem, networkWorker);
     this.playerStatusWindow   = new PlayerStatusWindow(this, dmpSettings, warpWorker, chatWorker, craftLibraryWorker, debugWindow, screenshotWorker, timeSyncer, playerStatusWorker, optionsWindow, playerColorWorker);
     this.playerColorWorker.SetDependencies(playerStatusWindow);
     this.vesselWorker.SetDependencies(hackyInAtmoLoader, timeSyncer, asteroidWorker, chatWorker, playerStatusWorker);
     this.networkWorker.SetDependencies(timeSyncer, warpWorker, chatWorker, playerColorWorker, flagSyncer, partKiller, kerbalReassigner, asteroidWorker, vesselWorker, hackyInAtmoLoader, playerStatusWorker, scenarioWorker, dynamicTickWorker, craftLibraryWorker, screenshotWorker, toolbarSupport, adminSystem, lockSystem, dmpModInterface, universeSyncCache, vesselRecorder);
     optionsWindow.SetDependencies(this, networkWorker, playerColorWorker);
     this.dmpModInterface.DMPRun(networkWorker);
     this.stopEvent.Add(this.chatWorker.Stop);
     this.stopEvent.Add(this.craftLibraryWorker.Stop);
     this.stopEvent.Add(this.debugWindow.Stop);
     this.stopEvent.Add(this.dynamicTickWorker.Stop);
     this.stopEvent.Add(this.flagSyncer.Stop);
     this.stopEvent.Add(this.hackyInAtmoLoader.Stop);
     this.stopEvent.Add(this.kerbalReassigner.Stop);
     this.stopEvent.Add(this.playerColorWorker.Stop);
     this.stopEvent.Add(this.playerStatusWindow.Stop);
     this.stopEvent.Add(this.playerStatusWorker.Stop);
     this.stopEvent.Add(this.partKiller.Stop);
     this.stopEvent.Add(this.scenarioWorker.Stop);
     this.stopEvent.Add(this.screenshotWorker.Stop);
     this.stopEvent.Add(this.timeSyncer.Stop);
     this.stopEvent.Add(toolbarSupport.Stop);
     this.stopEvent.Add(optionsWindow.Stop);
     this.stopEvent.Add(this.vesselWorker.Stop);
     this.stopEvent.Add(this.warpWorker.Stop);
     this.stopEvent.Add(this.asteroidWorker.Stop);
     this.stopEvent.Add(this.vesselRecorder.Stop);
 }
コード例 #9
0
        public void Start()
        {
            //Set buffered UDPMesh
            UDPMeshLib.UdpMeshCommon.USE_BUFFERS = true;
            //Set pool sizes for ByteRecycler
            ByteRecycler.AddPoolSize(SMALL_MESSAGE_SIZE);
            ByteRecycler.AddPoolSize(MEDIUM_MESSAGE_SIZE);
            ByteRecycler.AddPoolSize(LARGE_MESSAGE_SIZE);
            MessageWriter.RegisterType <ByteArray>(WriteByteArrayToStream);
            MessageReader.RegisterType <ByteArray>(ReadByteArrayFromStream);

            //Prevent loads if multiple copies of DMP are installed. KSP will instantate us twice.
            if (dmpClient != null)
            {
                warnDuplicateInstall = true;
                return;
            }

            if (!CompatibilityChecker.IsCompatible() || !InstallChecker.IsCorrectlyInstalled())
            {
                modDisabled = true;
                enabled     = false;
                return;
            }

            TimingManager.FixedUpdateAdd(TimingManager.TimingStage.BetterLateThanNever, TimingManagerFixedUpdate);
            dmpDir      = Path.Combine(Path.Combine(Path.Combine(KSPUtil.ApplicationRootPath, "GameData"), "DarkMultiPlayer"), "Plugins");
            dmpDataDir  = Path.Combine(dmpDir, "Data");
            gameDataDir = Path.Combine(KSPUtil.ApplicationRootPath, "GameData");
            kspRootPath = KSPUtil.ApplicationRootPath;

            //Fix DarkLog time/thread marker in the log during init.
            DarkLog.SetMainThread();
            lastClockTicks           = DateTime.UtcNow.Ticks;
            lastRealTimeSinceStartup = 0f;

            dmpClient = this;
            profiler  = new Profiler();
            kspTime   = profiler.GetCurrentTime;
            kspMemory = profiler.GetCurrentMemory;

            dmpSettings       = new Settings();
            toolbarSupport    = new ToolbarSupport(dmpSettings);
            universeSyncCache = new UniverseSyncCache(dmpSettings);
            modWindow         = new ModWindow();
            modWorker         = new ModWorker(modWindow);
            modWindow.SetDependenices(modWorker);
            universeConverter          = new UniverseConverter(dmpSettings);
            universeConverterWindow    = new UniverseConverterWindow(universeConverter);
            serverListDisclaimerWindow = new ServerListDisclaimerWindow(dmpSettings);
            optionsWindow        = new OptionsWindow(dmpSettings, universeSyncCache, modWorker, universeConverterWindow, toolbarSupport, serverListDisclaimerWindow);
            serverListConnection = new ServerListConnection(dmpSettings);
            serversWindow        = new ServersWindow(dmpSettings, optionsWindow, serverListConnection);
            serverListConnection.SetDependancy(serversWindow);
            connectionWindow = new ConnectionWindow(dmpSettings, optionsWindow, serversWindow, serverListDisclaimerWindow);
            disclaimerWindow = new DisclaimerWindow(dmpSettings);
            dmpModInterface  = new DMPModInterface();
            //SafetyBubble.RegisterDefaultLocations();


            if (dmpSettings.disclaimerAccepted != 1)
            {
                modDisabled = true;
                disclaimerWindow.SpawnDialog();
            }

            Application.wantsToQuit += WantsToQuit;
            DontDestroyOnLoad(this);

            // Prevents symlink warning for development.
            SetupDirectoriesIfNeeded();

            // UniverseSyncCache needs to run expiry here
            universeSyncCache.ExpireCache();

            GameEvents.onHideUI.Add(() =>
            {
                showGUI = false;
            });
            GameEvents.onShowUI.Add(() =>
            {
                showGUI = true;
            });

            HandleCommandLineArgs();
            DarkLog.Debug("DarkMultiPlayer " + Common.PROGRAM_VERSION + ", protocol " + Common.PROTOCOL_VERSION + " Initialized!");
        }
コード例 #10
0
 public ServersWindow(Settings dmpSettings, OptionsWindow optionsWindow, ServerListConnection serverListConnection)
 {
     this.dmpSettings          = dmpSettings;
     this.optionsWindow        = optionsWindow;
     this.serverListConnection = serverListConnection;
 }
コード例 #11
0
 public ConnectionWindow(Settings dmpSettings, OptionsWindow optionsWindow)
 {
     this.dmpSettings   = dmpSettings;
     this.optionsWindow = optionsWindow;
 }