Example #1
0
        /// <summary>
        /// Run the console UI.
        /// Starts with a splash screen, then instance selection if no default,
        /// then list of mods.
        /// </summary>
        public ConsoleCKAN(GameInstanceManager mgr, bool debug)
        {
            // GameInstanceManager only uses its IUser object to construct game instance objects,
            // which only use it to inform the user about the creation of the CKAN/ folder.
            // These aren't really intended to be displayed, so the manager
            // can keep a NullUser reference forever.
            GameInstanceManager manager = mgr ?? new GameInstanceManager(new NullUser());

            // The splash screen returns true when it's safe to run the rest of the app.
            // This can be blocked by a lock file, for example.
            if (new SplashScreen(manager).Run())
            {
                if (manager.CurrentInstance == null)
                {
                    if (manager.Instances.Count == 0)
                    {
                        // No instances, add one
                        new GameInstanceAddScreen(manager).Run();
                        // Set instance to current if they added one
                        manager.GetPreferredInstance();
                    }
                    else
                    {
                        // Multiple instances, no default, pick one
                        new GameInstanceListScreen(manager).Run();
                    }
                }
                if (manager.CurrentInstance != null)
                {
                    new ModListScreen(manager, debug).Run();
                }

                new ExitScreen().Run();
            }
        }
Example #2
0
        static void Main(string[] args)
        {
            Console.CursorVisible = false;
            var lockObject = new object();


            RenderOutput writeToConsole = s =>
            {
                lock (lockObject)
                {
                    Console.Clear();
                    Console.WriteLine(s);
                }
            };

            var manager = new GameInstanceManager(
                writeToConsole,
                new ConsoleKeyboardInput(lockObject),
                () => TicTacToeGameFactory.CreateWithRandomPlayers(lockObject)
                );

            while (!manager.Exited)
            {
                Thread.Sleep(1000);
            }
        }
Example #3
0
        public void ConstructModList_NumberOfRows_IsEqualToNumberOfMods()
        {
            using (var tidy = new DisposableKSP())
            {
                var config = new FakeConfiguration(tidy.KSP, tidy.KSP.Name);

                GameInstanceManager manager = new GameInstanceManager(
                    new NullUser(),
                    config
                    )
                {
                    CurrentInstance = tidy.KSP
                };
                var registry = Registry.Empty();
                registry.AddAvailable(TestData.FireSpitterModule());
                registry.AddAvailable(TestData.kOS_014_module());
                var main_mod_list = new ModList(null);
                var mod_list      = main_mod_list.ConstructModList(
                    new List <GUIMod>
                {
                    new GUIMod(TestData.FireSpitterModule(), registry, manager.CurrentInstance.VersionCriteria()),
                    new GUIMod(TestData.kOS_014_module(), registry, manager.CurrentInstance.VersionCriteria())
                },
                    manager.CurrentInstance.Name
                    );
                Assert.That(mod_list, Has.Count.EqualTo(2));

                manager.Dispose();
                config.Dispose();
            }
        }
Example #4
0
        public void SetUp()
        {
            _testModule = TestData.DogeCoinFlag_101_module();

            _instance        = new DisposableKSP();
            _nullUser        = new NullUser();
            _config          = new FakeConfiguration(_instance.KSP, _instance.KSP.Name);
            _manager         = new GameInstanceManager(_nullUser, _config);
            _registryManager = CKAN.RegistryManager.Instance(_instance.KSP);
            _registry        = _registryManager.registry;
            _installer       = CKAN.ModuleInstaller.GetInstance(_instance.KSP, _manager.Cache, _nullUser);

            _gameDir     = _instance.KSP.GameDir();
            _gameDataDir = _instance.KSP.game.PrimaryModDirectory(_instance.KSP);
            _registry.AddAvailable(_testModule);
            var testModFile = TestData.DogeCoinFlagZip();

            _manager.Cache.Store(_testModule, testModFile);
            HashSet <string> possibleConfigOnlyDirs = null;

            _installer.InstallList(
                new List <string>()
            {
                _testModule.identifier
            },
                new RelationshipResolverOptions(),
                _registryManager,
                ref possibleConfigOnlyDirs
                );
        }
Example #5
0
        public void UninstallModNotFound()
        {
            using (var tidy = new DisposableKSP())
            {
                var config = new FakeConfiguration(tidy.KSP, tidy.KSP.Name);

                GameInstanceManager manager = new GameInstanceManager(
                    new NullUser(),
                    config
                    )
                {
                    CurrentInstance = tidy.KSP
                };

                Assert.Throws <ModNotInstalledKraken>(delegate
                {
                    HashSet <string> possibleConfigOnlyDirs = null;
                    // This should throw, as our tidy KSP has no mods installed.
                    new CKAN.ModuleInstaller(manager.CurrentInstance, manager.Cache, nullUser).UninstallList(new List <string> {
                        "Foo"
                    }, ref possibleConfigOnlyDirs, CKAN.RegistryManager.Instance(manager.CurrentInstance));
                });

                manager.CurrentInstance = null; // I weep even more.
                manager.Dispose();
                config.Dispose();
            }
        }
Example #6
0
        private static NetFileCache FindCache(GameInstanceManager kspManager, IConfiguration cfg, string cacheDir)
        {
            if (cacheDir != null)
            {
                log.InfoFormat("Using user-supplied cache at {0}", cacheDir);
                return(new NetFileCache(cacheDir));
            }

            try
            {
                log.InfoFormat("Using main CKAN meta-cache at {0}", cfg.DownloadCacheDir);
                // Create a new file cache in the same location so NetKAN can download pure URLs not sourced from CkanModules
                return(new NetFileCache(kspManager, cfg.DownloadCacheDir));
            }
            catch
            {
                // Meh, can't find KSP. 'Scool, bro.
            }

            var tempdir = Path.GetTempPath();

            log.InfoFormat("Using tempdir for cache: {0}", tempdir);

            return(new NetFileCache(tempdir));
        }
Example #7
0
        public void IsVisible_WithAllAndNoNameFilter_ReturnsTrueForCompatible()
        {
            using (var tidy = new DisposableKSP())
            {
                var config = new FakeConfiguration(tidy.KSP, tidy.KSP.Name);

                GameInstanceManager manager = new GameInstanceManager(
                    new NullUser(),
                    config
                    )
                {
                    CurrentInstance = tidy.KSP
                };

                var ckan_mod = TestData.FireSpitterModule();
                var registry = Registry.Empty();
                registry.AddAvailable(ckan_mod);
                var item = new ModList(delegate { });
                Assert.That(item.IsVisible(
                                new GUIMod(ckan_mod, registry, manager.CurrentInstance.VersionCriteria()),
                                manager.CurrentInstance.Name
                                ));

                manager.Dispose();
                config.Dispose();
            }
        }
    //Use only xSize and plusDistance

    override public void Perform(GameInstanceManager gameInstanceManager)
    {
        GameObject playerObject = gameInstanceManager.player;
        GameObject bossObject   = gameInstanceManager.boss;

        Vector3 playerPosition = playerObject.transform.position;
        Vector3 bossPosition   = bossObject.transform.position;

        playerPosition.y = 0;
        bossPosition.y   = 0;
        Vector3 positionBetween    = (bossPosition + playerPosition) / 2;
        float   distance           = Vector3.Distance(playerPosition, bossPosition);
        Vector3 vectorTowardPlayer = (new Vector3(playerPosition.x - bossPosition.x, 0, playerPosition.z - bossPosition.z)).normalized;

        GameObject newAoeObject = Instantiate(MyUtility.GetAoePrefabObject(AoeType.Square), positionBetween, Quaternion.identity, gameInstanceManager.transform);

        newAoeObject.transform.LookAt(playerPosition);
        newAoeObject.transform.rotation *= Quaternion.Euler(new Vector3(0, rotation, 0));

        AoeAttack aoeAttackScript = newAoeObject.transform.GetChild(0).GetComponent <AoeAttack>();

        aoeAttackScript.SettingsAoe(aoeTimer, lingerTime, damage);

        if (distance + plusDistance < minLength)
        {
            newAoeObject.transform.position   = bossPosition + vectorTowardPlayer * minLength / 2;
            newAoeObject.transform.localScale = new Vector3(xSize, 1, minLength);
        }
        else
        {
            newAoeObject.transform.position  += vectorTowardPlayer * plusDistance / 2; // = bossposition + vectorTowardplayer *( distance + plusdistance)/2
            newAoeObject.transform.localScale = new Vector3(xSize, 1, distance + plusDistance);
        }
    }
Example #9
0
 /// <summary>
 /// Initialize the Screen
 /// </summary>
 /// <param name="mgr">Game instance manager containing the instances</param>
 public GameInstanceAddScreen(GameInstanceManager mgr) : base(mgr)
 {
     AddObject(new ConsoleLabel(
                   labelWidth, pathRow + 1, -1,
                   () => $"Example: {examplePath}",
                   null, th => th.DimLabelFg
                   ));
 }
Example #10
0
 private static int ConsoleUi(GameInstanceManager manager, ConsoleUIOptions opts, string[] args)
 {
     // Debug/verbose output just messes up the screen
     LogManager.GetRepository().Threshold = Level.Warn;
     return(CKAN.ConsoleUI.ConsoleUI.Main_(args, manager,
                                           opts.Theme ?? Environment.GetEnvironmentVariable("CKAN_CONSOLEUI_THEME") ?? "default",
                                           opts.Debug));
 }
Example #11
0
        public void UninstallEmptyDirs()
        {
            string emptyFolderName = "DogeCoinFlag";

            // Create a new disposable KSP instance to run the test on.
            using (var ksp = new DisposableKSP())
            {
                var config = new FakeConfiguration(ksp.KSP, ksp.KSP.Name);

                GameInstanceManager manager = new GameInstanceManager(
                    new NullUser(),
                    config
                ) {
                    CurrentInstance = ksp.KSP
                };

                string directoryPath = Path.Combine(ksp.KSP.game.PrimaryModDirectory(ksp.KSP), emptyFolderName);

                // Install the base test mod.

                var registry = CKAN.RegistryManager.Instance(ksp.KSP).registry;
                manager.Cache.Store(TestData.DogeCoinFlag_101_module(), TestData.DogeCoinFlagZip());
                registry.AddAvailable(TestData.DogeCoinFlag_101_module());

                List<string> modules = new List<string> { TestData.DogeCoinFlag_101_module().identifier };

                HashSet<string> possibleConfigOnlyDirs = null;
                CKAN.ModuleInstaller.GetInstance(manager.CurrentInstance, manager.Cache, nullUser).InstallList(modules, new RelationshipResolverOptions(), CKAN.RegistryManager.Instance(manager.CurrentInstance), ref possibleConfigOnlyDirs);

                modules.Clear();

                // Install the plugin test mod.
                manager.Cache.Store(TestData.DogeCoinPlugin_module(), TestData.DogeCoinPluginZip());
                registry.AddAvailable(TestData.DogeCoinPlugin_module());

                modules.Add(TestData.DogeCoinPlugin_module().identifier);

                CKAN.ModuleInstaller.GetInstance(manager.CurrentInstance, manager.Cache, nullUser).InstallList(modules, new RelationshipResolverOptions(), CKAN.RegistryManager.Instance(manager.CurrentInstance), ref possibleConfigOnlyDirs);

                modules.Clear();

                // Check that the directory is installed.
                Assert.IsTrue(Directory.Exists(directoryPath));

                // Uninstall both mods.

                modules.Add(TestData.DogeCoinFlag_101_module().identifier);
                modules.Add(TestData.DogeCoinPlugin_module().identifier);

                CKAN.ModuleInstaller.GetInstance(manager.CurrentInstance, manager.Cache, nullUser).UninstallList(modules, ref possibleConfigOnlyDirs, CKAN.RegistryManager.Instance(manager.CurrentInstance));

                // Check that the directory has been deleted.
                Assert.IsFalse(Directory.Exists(directoryPath));

                manager.Dispose();
                config.Dispose();
            }
        }
Example #12
0
        private static int Gui(GameInstanceManager manager, GuiOptions options, string[] args)
        {
            // TODO: Sometimes when the GUI exits, we get a System.ArgumentException,
            // but trying to catch it here doesn't seem to help. Dunno why.

            GUI.Main_(args, manager, options.ShowConsole);

            return(Exit.OK);
        }
Example #13
0
 /// <summary>
 /// Upgrade some modules by their identifier and (optional) version
 /// </summary>
 /// <param name="manager">Game instance manager to use</param>
 /// <param name="user">IUser object for output</param>
 /// <param name="ksp">Game instance to use</param>
 /// <param name="identsAndVersions">List of identifier[=version] to upgrade</param>
 public static void UpgradeModules(GameInstanceManager manager, IUser user, CKAN.GameInstance ksp, List <string> identsAndVersions)
 {
     UpgradeModules(manager, user, ksp,
                    (ModuleInstaller installer, NetAsyncModulesDownloader downloader, RegistryManager regMgr, ref HashSet <string> possibleConfigOnlyDirs) =>
                    installer.Upgrade(identsAndVersions, downloader,
                                      ref possibleConfigOnlyDirs, regMgr, true),
                    m => identsAndVersions.Add(m.identifier)
                    );
 }
Example #14
0
 /// <summary>
 /// Upgrade some modules by their CkanModules
 /// </summary>
 /// <param name="manager">Game instance manager to use</param>
 /// <param name="user">IUser object for output</param>
 /// <param name="ksp">Game instance to use</param>
 /// <param name="modules">List of modules to upgrade</param>
 public static void UpgradeModules(GameInstanceManager manager, IUser user, CKAN.GameInstance ksp, bool ConfirmPrompt, List <CkanModule> modules)
 {
     UpgradeModules(manager, user, ksp,
                    (ModuleInstaller installer, NetAsyncModulesDownloader downloader, RegistryManager regMgr, ref HashSet <string> possibleConfigOnlyDirs) =>
                    installer.Upgrade(modules, downloader,
                                      ref possibleConfigOnlyDirs, regMgr, true, true, ConfirmPrompt),
                    m => modules.Add(m)
                    );
 }
Example #15
0
        /// <summary>
        /// Execute a cache subcommand
        /// </summary>
        /// <param name="mgr">GameInstanceManager object containing our instances and cache</param>
        /// <param name="opts">Command line options object</param>
        /// <param name="unparsed">Raw command line options</param>
        /// <returns>
        /// Exit code for shell environment
        /// </returns>
        public int RunSubCommand(GameInstanceManager mgr, CommonOptions opts, SubCommandOptions unparsed)
        {
            string[] args = unparsed.options.ToArray();

            int exitCode = Exit.OK;

            // Parse and process our sub-verbs
            Parser.Default.ParseArgumentsStrict(args, new CacheSubOptions(), (string option, object suboptions) =>
            {
                // ParseArgumentsStrict calls us unconditionally, even with bad arguments
                if (!string.IsNullOrEmpty(option) && suboptions != null)
                {
                    CommonOptions options = (CommonOptions)suboptions;
                    options.Merge(opts);
                    user     = new ConsoleUser(options.Headless);
                    manager  = mgr ?? new GameInstanceManager(user);
                    exitCode = options.Handle(manager, user);
                    if (exitCode != Exit.OK)
                    {
                        return;
                    }

                    switch (option)
                    {
                    case "list":
                        exitCode = ListCacheDirectory((CommonOptions)suboptions);
                        break;

                    case "set":
                        exitCode = SetCacheDirectory((SetOptions)suboptions);
                        break;

                    case "clear":
                        exitCode = ClearCacheDirectory((CommonOptions)suboptions);
                        break;

                    case "reset":
                        exitCode = ResetCacheDirectory((CommonOptions)suboptions);
                        break;

                    case "showlimit":
                        exitCode = ShowCacheSizeLimit((CommonOptions)suboptions);
                        break;

                    case "setlimit":
                        exitCode = SetCacheSizeLimit((SetLimitOptions)suboptions);
                        break;

                    default:
                        user.RaiseMessage("Unknown command: cache {0}", option);
                        exitCode = Exit.BADOPT;
                        break;
                    }
                }
            }, () => { exitCode = MainClass.AfterHelp(); });
            return(exitCode);
        }
        private void CreateGameManager()
        {
            RenderOutput writeOutputToField = output => this.renderedOutput = output;

            _keyboard = new FakeKeyboardInput();
            Func <FakeGameInstance> gameInstanceFactory = () => _fakeGameInstance = new FakeGameInstance();

            _manager = new GameInstanceManager(writeOutputToField, _keyboard, gameInstanceFactory);
        }
Example #17
0
 /// <summary>
 /// Return a mod's current status
 /// This can't be static because the user's installation plans are part of the object.
 /// This function is extremely performance-sensitive because it's the default sort for
 /// the main mod list, so anything in here should be O(1) and fast.
 /// </summary>
 /// <param name="manager">Game instance manager containing the instances</param>
 /// <param name="registry">Registry of instance being displayed</param>
 /// <param name="identifier">The mod</param>
 /// <returns>
 /// Status of mod
 /// </returns>
 public InstallStatus GetModStatus(GameInstanceManager manager, IRegistryQuerier registry, string identifier)
 {
     if (registry.IsInstalled(identifier, false))
     {
         if (Remove.Contains(identifier))
         {
             return(InstallStatus.Removing);
         }
         else if (registry.HasUpdate(identifier, manager.CurrentInstance.VersionCriteria()))
         {
             if (Upgrade.Contains(identifier))
             {
                 return(InstallStatus.Upgrading);
             }
             else
             {
                 return(InstallStatus.Upgradeable);
             }
         }
         else if (registry.IsAutodetected(identifier))
         {
             return(InstallStatus.AutoDetected);
         }
         else if (Replace.Contains(identifier))
         {
             return(InstallStatus.Replacing);
         }
         else if (registry.GetReplacement(identifier, manager.CurrentInstance.VersionCriteria()) != null)
         {
             return(InstallStatus.Replaceable);
         }
         else if (!IsAnyAvailable(registry, identifier))
         {
             return(InstallStatus.Unavailable);
         }
         else if (registry.InstalledModule(identifier)?.AutoInstalled ?? false)
         {
             return(InstallStatus.AutoInstalled);
         }
         else
         {
             return(InstallStatus.Installed);
         }
     }
     else
     {
         foreach (CkanModule m in Install)
         {
             if (m.identifier == identifier)
             {
                 return(InstallStatus.Installing);
             }
         }
         return(InstallStatus.NotInstalled);
     }
 }
Example #18
0
 public static CKAN.GameInstance GetGameInstance(GameInstanceManager manager)
 {
     CKAN.GameInstance inst = manager.CurrentInstance
                              ?? manager.GetPreferredInstance();
     if (inst == null)
     {
         throw new NoGameInstanceKraken();
     }
     return(inst);
 }
Example #19
0
 /// <summary>
 /// Initialize the Screen
 /// </summary>
 /// <param name="mgr">Game instance manager containing instances</param>
 /// <param name="cp">Plan of mods to install or remove</param>
 /// <param name="dbg">True if debug options should be available, false otherwise</param>
 public InstallScreen(GameInstanceManager mgr, ChangePlan cp, bool dbg)
     : base(
         "Installing, Updating, and Removing Mods",
         "Calculating..."
         )
 {
     debug   = dbg;
     manager = mgr;
     plan    = cp;
 }
Example #20
0
 public IEnumerator PerformSubAttacks(GameInstanceManager gameInstanceManager, BossAttackController bossAttackController)
 {
     foreach (IAction action in actionsList)
     {
         action.Perform(gameInstanceManager);
         yield return(new WaitForSeconds(action.GetTotalDelay()));
     }
     //Debug.Log("finish an attack : "+ gameObject.name);
     bossAttackController.nextAttackReady = true;
     yield return(null);
 }
Example #21
0
        /// <summary>
        /// Shared entry point for the application, used by real command line
        /// and by other parts of CKAN that want to launch the console UI.
        /// </summary>
        /// <param name="args">Command line arguments</param>
        /// <param name="manager">Game instance manager object potentially initialized by command line flags</param>
        /// <param name="debug">True if debug options should be available, false otherwise</param>
        /// <returns>
        /// Process exit status
        /// </returns>
        public static int Main_(string[] args, GameInstanceManager manager, bool debug = false)
        {
            Logging.Initialize();

            new ConsoleCKAN(manager, debug);

            // Tell RegistryManager not to throw Dispose-related exceptions at exit
            RegistryManager.DisposeAll();

            return(0);
        }
Example #22
0
 public void GetPreferredInstance_WithEmptyAutoStartAndMultipleInstances_ReturnsNull()
 {
     using (var tidy2 = new DisposableKSP())
     {
         cfg.Instances.Add(new Tuple <string, string, string>("tidy2", tidy2.KSP.GameDir(), "KSP"));
         // Make a new manager with the updated config
         var multiMgr = new GameInstanceManager(new NullUser(), cfg);
         multiMgr.ClearAutoStart();
         Assert.That(multiMgr.GetPreferredInstance(), Is.Null);
         multiMgr.Dispose();
     }
 }
Example #23
0
        public void CanInstallMod()
        {
            string mod_file_name = "DogeCoinFlag/Flags/dogecoin.png";

            // Create a new disposable KSP instance to run the test on.
            using (DisposableKSP ksp = new DisposableKSP())
            {
                var config = new FakeConfiguration(ksp.KSP, ksp.KSP.Name);

                GameInstanceManager manager = new GameInstanceManager(
                    new NullUser(),
                    config
                    )
                {
                    CurrentInstance = ksp.KSP
                };

                // Make sure the mod is not installed.
                string mod_file_path = Path.Combine(ksp.KSP.game.PrimaryModDirectory(ksp.KSP), mod_file_name);

                Assert.IsFalse(File.Exists(mod_file_path));

                // Copy the zip file to the cache directory.
                Assert.IsFalse(manager.Cache.IsCachedZip(TestData.DogeCoinFlag_101_module()));

                string cache_path = manager.Cache.Store(TestData.DogeCoinFlag_101_module(), TestData.DogeCoinFlagZip());

                Assert.IsTrue(manager.Cache.IsCachedZip(TestData.DogeCoinFlag_101_module()));
                Assert.IsTrue(File.Exists(cache_path));

                // Mark it as available in the registry.
                var registry = CKAN.RegistryManager.Instance(ksp.KSP).registry;
                Assert.AreEqual(0, registry.CompatibleModules(ksp.KSP.VersionCriteria()).Count());

                registry.AddAvailable(TestData.DogeCoinFlag_101_module());

                Assert.AreEqual(1, registry.CompatibleModules(ksp.KSP.VersionCriteria()).Count());

                // Attempt to install it.
                List <string> modules = new List <string> {
                    TestData.DogeCoinFlag_101_module().identifier
                };

                HashSet <string> possibleConfigOnlyDirs = null;
                new CKAN.ModuleInstaller(ksp.KSP, manager.Cache, nullUser).InstallList(modules, new RelationshipResolverOptions(), CKAN.RegistryManager.Instance(manager.CurrentInstance), ref possibleConfigOnlyDirs);

                // Check that the module is installed.
                Assert.IsTrue(File.Exists(mod_file_path));

                manager.Dispose();
                config.Dispose();
            }
        }
Example #24
0
    override public void Perform(GameInstanceManager gameInstanceManager)
    {
        Quaternion targetRotation = Quaternion.Euler(new Vector3(0, rotation, 0));
        Vector3    targetPosition = gameInstanceManager.player.transform.position;

        targetPosition.y = 0;

        GameObject newAoeObject    = Instantiate(MyUtility.GetAoePrefabObject(aoeType), targetPosition, targetRotation, gameInstanceManager.transform);
        AoeAttack  aoeAttackScript = newAoeObject.transform.GetChild(0).GetComponent <AoeAttack>();

        aoeAttackScript.SettingsAoe(aoeTimer, lingerTime, damage);
        SettingAoeSizeByType(newAoeObject, aoeType);
    }
Example #25
0
 public MatchMakingServer(MatchMakerSettings settings)
 {
     SerializerSingleton.Serializer.AddSerializer <ClientHeartBeatPacket>(new ClientHeartBeatSerializer());
     SerializerSingleton.Serializer.AddSerializer <ClientHandshakePacket>(new ClientHandshakeSerializer());
     SerializerSingleton.Serializer.AddSerializer <ClientInstanceReadyPacket>(new ClientInstanceReadySerializer());
     SerializerSingleton.Serializer.AddSerializer <ServerExitPacket>(new ServerExitSerializer());
     Settings = settings;
     Logger.DefaultLogger(Settings.ToString());
     PortManager       = new PortManager(Settings);
     InstanceManager   = new GameInstanceManager(Settings);
     ConnectionManager = new ConnectionManager(Settings);
     WaitingQueue      = new List <WaitingQueueItem>();
     RemoveList        = new List <WaitingQueueItem>();
 }
Example #26
0
    public override void Perform(GameInstanceManager gameInstance)
    {
        BossMovementController bossMovementScript = gameInstance.boss.GetComponent <BossMovementController>();
        Vector3 targetPos = gameInstance.transform.position;

        if (coordinateName != CoordinateName.none)
        {
            targetPos += Coordinate.getCoordinate(coordinateName).transform.position;
        }
        else
        {
            targetPos += new Vector3(xPos, 2, zPos);
        }
        bossMovementScript.MoveToPosition(targetPos, timeToMove, delaybefore);
    }
Example #27
0
        public void Up()
        {
            _instance        = new DisposableKSP();
            _registryManager = RegistryManager.Instance(_instance.KSP);
            _registry        = Registry.Empty();
            _config          = new FakeConfiguration(_instance.KSP, _instance.KSP.Name);
            _manager         = new GameInstanceManager(
                new NullUser(),
                _config
                );

            // this module contains a ksp_version of "any" which repros our issue
            _anyVersionModule = TestData.DogeCoinFlag_101_module();

            // install it and set it as pre-installed
            _manager.Cache.Store(TestData.DogeCoinFlag_101_module(), TestData.DogeCoinFlagZip());
            _registry.RegisterModule(_anyVersionModule, new string[] { }, _instance.KSP, false);
            _registry.AddAvailable(_anyVersionModule);

            HashSet <string> possibleConfigOnlyDirs = null;

            ModuleInstaller.GetInstance(_instance.KSP, _manager.Cache, _manager.User).InstallList(
                new List <CkanModule> {
                { _anyVersionModule }
            },
                new RelationshipResolverOptions(),
                _registryManager,
                ref possibleConfigOnlyDirs,
                new NetAsyncModulesDownloader(_manager.User, _manager.Cache)
                );

            // this module is not for "any" version, to provide another to sort against
            _registry.AddAvailable(TestData.kOS_014_module());

            // test object
            _modList = new ModList(null);
            _listGui = new DataGridView();

            // todo: refactor the column header code to allow mocking of the GUI without creating columns
            _listGui.Columns.Add(new DataGridViewCheckBoxColumn());
            _listGui.Columns.Add(new DataGridViewCheckBoxColumn());
            _listGui.Columns.Add(new DataGridViewCheckBoxColumn());
            _listGui.Columns.Add(new DataGridViewCheckBoxColumn());
            for (int i = 0; i < 10; i++)
            {
                _listGui.Columns.Add(i.ToString(), "Column" + i);
            }
        }
Example #28
0
    override public void Perform(GameInstanceManager gameInstance)
    {
        BossMovementController bossMovementScript = gameInstance.boss.GetComponent <BossMovementController>();
        Vector3 targetPos;

        Vector3 bossPosition   = gameInstance.boss.transform.position;
        Vector3 playerPosition = gameInstance.player.transform.position;

        playerPosition.y = 0;
        bossPosition.y   = 0;
        float   distance           = Vector3.Distance(playerPosition, bossPosition);
        Vector3 vectorTowardPlayer = (new Vector3(playerPosition.x - bossPosition.x, 0, playerPosition.z - bossPosition.z)).normalized;

        targetPos = gameInstance.boss.transform.position + vectorTowardPlayer * (distance + distanceOffset);
        bossMovementScript.MoveToPosition(targetPos, timeToMove, delaybefore);
    }
Example #29
0
        public void ModuleManagerInstancesAreDecoupled()
        {
            string mod_file_name = "DogeCoinFlag/Flags/dogecoin.png";

            // Create a new disposable KSP instance to run the test on.
            Assert.DoesNotThrow(delegate
            {
                for (int i = 0; i < 5; i++)
                {
                    using (DisposableKSP ksp = new DisposableKSP())
                    {
                        var config = new FakeConfiguration(ksp.KSP, ksp.KSP.Name);

                        GameInstanceManager manager = new GameInstanceManager(
                            new NullUser(),
                            config
                            )
                        {
                            CurrentInstance = ksp.KSP
                        };

                        // Copy the zip file to the cache directory.
                        manager.Cache.Store(TestData.DogeCoinFlag_101_module(), TestData.DogeCoinFlagZip());

                        // Mark it as available in the registry.
                        var registry = CKAN.RegistryManager.Instance(ksp.KSP).registry;
                        registry.AddAvailable(TestData.DogeCoinFlag_101_module());

                        // Attempt to install it.
                        List <string> modules = new List <string> {
                            TestData.DogeCoinFlag_101_module().identifier
                        };

                        HashSet <string> possibleConfigOnlyDirs = null;
                        new CKAN.ModuleInstaller(ksp.KSP, manager.Cache, nullUser).InstallList(modules, new RelationshipResolverOptions(), CKAN.RegistryManager.Instance(manager.CurrentInstance), ref possibleConfigOnlyDirs);

                        // Check that the module is installed.
                        string mod_file_path = Path.Combine(ksp.KSP.game.PrimaryModDirectory(ksp.KSP), mod_file_name);

                        Assert.IsTrue(File.Exists(mod_file_path));

                        manager.Dispose();
                        config.Dispose();
                    }
                }
            });
        }
Example #30
0
        public int RunCommand(GameInstanceManager manager, object raw_options)
        {
            CommonOptions opts = raw_options as CommonOptions;

            // Print an intro if not in headless mode
            if (!(opts?.Headless ?? false))
            {
                Console.WriteLine("Welcome to CKAN!");
                Console.WriteLine("");
                Console.WriteLine("To get help, type help and press enter.");
                Console.WriteLine("");
            }
            bool done = false;

            while (!done)
            {
                // Prompt if not in headless mode
                if (!(opts?.Headless ?? false))
                {
                    Console.Write(
                        manager.CurrentInstance != null
                            ? $"CKAN {Meta.GetVersion()}: {manager.CurrentInstance.game.ShortName} {manager.CurrentInstance.Version()} ({manager.CurrentInstance.Name})> "
                            : $"CKAN {Meta.GetVersion()}> "
                        );
                }
                // Get input
                string command = Console.ReadLine();
                if (command == null || command == exitCommand)
                {
                    done = true;
                }
                else if (command != "")
                {
                    // Parse input as if it was a normal command line,
                    // but with a persistent GameInstanceManager object.
                    int cmdExitCode = MainClass.Execute(manager, opts, command.Split(' '));
                    if ((opts?.Headless ?? false) && cmdExitCode != Exit.OK)
                    {
                        // Pass failure codes to calling process in headless mode
                        // (in interactive mode the user can see the error and try again)
                        return(cmdExitCode);
                    }
                }
            }
            return(Exit.OK);
        }