예제 #1
0
 protected override async Task<IEnumerable<string>> GetStartupParameters(IRealVirtualityLauncher launcher,
     ILaunchContentAction<IContent> action) {
     var defParams = await base.GetStartupParameters(launcher, action).ConfigureAwait(false);
     return /*Settings.ServerMode ||*/ !_settings.LaunchThroughBattlEye || !GetBattleEyeClientExectuable().Exists
         ? defParams
         : AddBattleEyeLaunchParameters(defParams);
 }
예제 #2
0
        protected override async Task <Process> LaunchImpl(IGameLauncherFactory factory,
                                                           ILaunchContentAction <IContent> action)
        {
            var launcher     = factory.Create <IRealVirtualityLauncher>(this);
            var launchAction = _shouldLaunchAsDedicatedServer.Value
                ? LaunchAction.LaunchAsDedicatedServer
                : action.Action;
            var ls = new LaunchState(GetLaunchExecutable(launchAction), GetExecutable(launchAction),
                                     await GetStartupParameters(launcher, action, launchAction).ConfigureAwait(false), launchAction);

            if (launchAction.IsAsServer())
            {
                Tools.FileUtil.Ops.CreateDirectoryAndSetACLWithFallbackAndRetry(KeysPath);
            }

            var launchables = action.GetLaunchables()
                              .OfType <IModContent>()
                              .Select(c => new RvMod(this, c));

            foreach (var mod in launchables)
            {
                await mod.PreLaunch(action.Action).ConfigureAwait(false);
            }
            return(await InitiateLaunch(launcher, ls).ConfigureAwait(false));
        }
예제 #3
0
        // TODO: Enter content into LAUNCHING state, then once completed, back to the content's state.
        public async Task <int> Launch(IGameLauncherFactory factory,
                                       ILaunchContentAction <Content> launchContentAction)
        {
            var pid = await LaunchInternal(factory, launchContentAction).ConfigureAwait(false);

            PrepareEvent(new LaunchActionCompleted(this, pid));
            return(pid);
        }
예제 #4
0
        protected override async Task <IReadOnlyCollection <string> > GetStartupParameters(
            IRealVirtualityLauncher launcher, ILaunchContentAction <IContent> action, LaunchAction launchAction)
        {
            var defParams = await base.GetStartupParameters(launcher, action, launchAction).ConfigureAwait(false);

            return(LaunchNormally(GetBattleEyeClientExectuable(), launchAction)
                ? defParams
                : AddBattleEyeLaunchParameters(defParams).ToArray());
        }
예제 #5
0
        protected override Task <Process> LaunchImpl(IGameLauncherFactory factory,
                                                     ILaunchContentAction <IContent> action)
        {
            var launcher = factory.Create(this);

            return(InitiateLaunch(launcher,
                                  new LaunchState(GetLaunchExecutable(action.Action), GetExecutable(action.Action),
                                                  GetStartupParameters(action).ToArray(), action.Action)));
        }
예제 #6
0
        private IEnumerable <string> GetAdvancedStartupParameters(ILaunchContentAction <IContent> action)
        {
            var launchables = action.GetLaunchables();
            var server      = GetServerOverride(action) ?? GetServer(launchables, action.Action);

            if (server != null)
            {
                // join friend would be :steamid_{id}
                yield return($"+platform:connect:address_{server.Address}"); // TODO: PW
            }
        }
예제 #7
0
        protected override Task EnableMods(ILaunchContentAction <IContent> launchContentAction)
        {
            var content  = launchContentAction.Content.SelectMany(x => x.Content.GetLaunchables(x.Constraint)).ToArray();
            var packages = content.OfType <IHavePackageName>()
                           .Select(x => x.PackageName)
                           .Distinct()
                           .ToArray();

            HandleModDirectory(packages);
            HandleNMSEDirectory();

            return(EnableModsInternal(content.OfType <IModContent>().Select(CreateMod), m => m.Install(false)));
        }
예제 #8
0
 protected CollectionServer GetServerOverride(ILaunchContentAction <IContent> action)
 {
     if (action.Action == LaunchAction.Default)
     {
         return action.ServerAddress == null ? null : new CollectionServer {
                    Address = action.ServerAddress
         }
     }
     ;
     return(action.Action == LaunchAction.Join
         ? new CollectionServer {
         Address = action.ServerAddress
     }
         : null);
 }
예제 #9
0
 protected override Task EnableMods(ILaunchContentAction<IContent> launchContentAction) {
     var pluginList = GetLocalAppDataFolder().GetChildFileWithName("plugins.txt");
     var loadOrder = GetLocalAppDataFolder().GetChildFileWithName("loadorder.txt");
     var contentList =
         new[] {"Skyrim.esm", "Update.esm"}.Concat(
                 launchContentAction.Content.Select(x => x.Content)
                     .OfType<IModContent>()
                     .Select(CreateMod)
                     .Select(x => x.GetEsmFileName())
                     .Where(x => x != null))
             .ToArray();
     // todo; backup and keep load order
     pluginList.WriteText(string.Join(Environment.NewLine, contentList));
     loadOrder.WriteText(string.Join(Environment.NewLine, contentList));
     return TaskExt.Default;
 }
예제 #10
0
        protected override Task EnableMods(ILaunchContentAction <IContent> launchContentAction)
        {
            var pluginList  = GetLocalAppDataFolder().GetChildFileWithName("plugins.txt");
            var loadOrder   = GetLocalAppDataFolder().GetChildFileWithName("loadorder.txt");
            var contentList =
                new[] { "Fallout4.esm", "Update.esm" }.Concat(
                launchContentAction.Content.Select(x => x.Content)
                .OfType <IModContent>()
                .Select(CreateMod)
                .Select(x => x.GetEsmFileName())
                .Where(x => x != null))
            .ToArray();

            // todo; backup and keep load order
            pluginList.WriteText(string.Join(Environment.NewLine, contentList));
            loadOrder.WriteText(string.Join(Environment.NewLine, contentList));
            return(TaskExt.Default);
        }
예제 #11
0
        StartupBuilderSpec GetStartupSpec(ILaunchContentAction <IContent> action, LaunchAction launchAction)
        {
            var content = GetLaunchables(action);

            return(new StartupBuilderSpec {
                GamePath = InstalledState.Directory,
                SteamWorkshopPath = SteamDirectories.IsValid ? SteamDirectories.Workshop.ContentPath : null,
                LaunchType = launchAction == LaunchAction.LaunchAsServer ? LaunchType.Multiplayer : action.LaunchType,
                ModPath = ContentPaths.Path,
                GameVersion = InstalledState.Version,
                InputMods = content.OfType <IModContent>().Select(x => new RvMod(this, x)).ToList(), //.Where(x => x.Controller.Exists),
                AdditionalLaunchMods = GetAdditionalLaunchMods(),
                //Mission = CalculatedSettings.Mission,
                Server = GetServerOverride(action) ?? GetServerFromContent(content, launchAction),
                // TODO: Or configurable by user?
                StartupParameters = Settings.StartupParameters.Get(),
                UseParFile = true
            });
        }
예제 #12
0
        async Task <int> LaunchInternal(IGameLauncherFactory factory, ILaunchContentAction <IContent> action)
        {
            ConfirmLaunch();

            await BeforeLaunch(action).ConfigureAwait(false);

            int id;

            using (var p = await LaunchImpl(factory, action).ConfigureAwait(false))
                id = p?.Id ?? -1;
            LastPlayed = Tools.Generic.GetCurrentUtcDateTime;
            PrepareEvent(new GameLaunched(this, id));

            if (Metadata.AfterLaunchDelay.HasValue)
            {
                await Task.Delay(Metadata.AfterLaunchDelay.Value, action.CancelToken).ConfigureAwait(false);
            }

            return(id);
        }
예제 #13
0
        protected override async Task EnableMods(ILaunchContentAction <IContent> launchContentAction)
        {
            var sf = GetDocumentsDirectory().GetChildFileWithName("settings.txt");

            new SettingsWriter(sf).Write(GetMods(launchContentAction));
        }
예제 #14
0
 private IEnumerable <StellarisMod> GetMods(ILaunchContentAction <IContent> launchContentAction)
 => launchContentAction.Content.Select(x => x.Content).OfType <IModContent>().Select(CreateMod);
예제 #15
0
 public void Use(ILaunchContentAction <IContent> action)
 {
     RecentInfo = new RecentInfo(action.LaunchType);
     PrepareEvent(new ContentUsed(this, action));
 }
예제 #16
0
        //private static readonly string[] defaultStartupParameters = {"-noworkshop"};

        protected override IEnumerable <string> GetStartupParameters(ILaunchContentAction <IContent> action)
        => GetAdvancedStartupParameters(action).Concat(base.GetStartupParameters(action));
예제 #17
0
 Tuple <string[], string[]> RvStartupParameters(IRealVirtualityLauncher launcher,
                                                ILaunchContentAction <IContent> action, LaunchAction launchAction)
 => GetStartupBuilder().GetStartupParameters(GetStartupSpec(action, launchAction));
예제 #18
0
 protected abstract Task EnableMods(ILaunchContentAction <IContent> launchContentAction);
예제 #19
0
 private IEnumerable<StellarisMod> GetMods(ILaunchContentAction<IContent> launchContentAction)
     => launchContentAction.Content.Select(x => x.Content).OfType<IModContent>().Select(CreateMod);
예제 #20
0
 protected abstract Task <Process> LaunchImpl(IGameLauncherFactory factory,
                                              ILaunchContentAction <IContent> action);
예제 #21
0
 protected virtual IReadOnlyCollection <ILaunchableContent> GetLaunchables(ILaunchContentAction <IContent> action)
 => action.GetLaunchables().ToArray();
예제 #22
0
 protected virtual IEnumerable <string> GetStartupParameters(ILaunchContentAction <IContent> action)
 => Settings.StartupParameters.Get();
예제 #23
0
 protected override Task EnableMods(ILaunchContentAction<IContent> launchContentAction) {
     throw new NotImplementedException();
 }
예제 #24
0
 protected override IReadOnlyCollection<ILaunchableContent> GetLaunchables(
         ILaunchContentAction<IContent> action)
     => HandleAia(base.GetLaunchables(action));
예제 #25
0
 protected virtual async Task BeforeLaunch(ILaunchContentAction <IContent> action)
 {
 }
예제 #26
0
        protected virtual async Task <IReadOnlyCollection <string> > GetStartupParameters(IRealVirtualityLauncher launcher,
                                                                                          ILaunchContentAction <IContent> action, LaunchAction launchAction)
        {
            var startupInfo       = RvStartupParameters(launcher, action, launchAction);
            var startupParameters = startupInfo.Item1.ToList();
            var parData           = startupInfo.Item2;

            if (!parData.Any())
            {
                return(startupParameters);
            }

            try {
                var parPath =
                    await
                    launcher.WriteParFile(new WriteParFileInfo(Id, string.Join("\n", parData)
                                                               //, new ShortGuid(Settings.CurrentProfile).ToString()
                                                               ))
                    .ConfigureAwait(false);

                startupParameters.Insert(0, "-par=" + parPath);
            } catch (Exception e) {
                throw new ParFileException(e.Message, e);
            }

            return(startupParameters);
        }
예제 #27
0
 protected override async Task EnableMods(ILaunchContentAction<IContent> launchContentAction) {
     var sf = GetDocumentsDirectory().GetChildFileWithName("settings.txt");
     new SettingsWriter(sf).Write(GetMods(launchContentAction));
 }
예제 #28
0
        // Temporary disabled because of server join testing
        // Don't launch with Steam because we don't want the Steam workshop mods supported
        //protected override bool ShouldLaunchWithSteam(LaunchState ls) => false;

        protected override Task EnableMods(ILaunchContentAction<IContent> launchContentAction) {
            // TODO: PublisherId

            var content = launchContentAction.Content.SelectMany(x => x.Content.GetLaunchables(x.Constraint)).ToArray();
            var packages = content.OfType<IHavePackageName>()
                .Select(x => x.PackageName)
                .Distinct()
                .ToArray();
            HandleModDirectory(packages);

            return EnableModsInternal(content.OfType<IModContent>().Select(CreateMod), m => m.Enable());
        }
예제 #29
0
        protected override async Task BeforeLaunch(ILaunchContentAction <IContent> action)
        {
            await EnableMods(action).ConfigureAwait(false);

            await base.BeforeLaunch(action).ConfigureAwait(false);
        }
예제 #30
0
        //private static readonly string[] defaultStartupParameters = {"-noworkshop"};

        protected override IEnumerable<string> GetStartupParameters(ILaunchContentAction<IContent> action)
            => GetAdvancedStartupParameters(action).Concat(base.GetStartupParameters(action));
예제 #31
0
 protected override Task EnableMods(ILaunchContentAction <IContent> launchContentAction)
 {
     throw new NotImplementedException();
 }
예제 #32
0
 private IEnumerable<string> GetAdvancedStartupParameters(ILaunchContentAction<IContent> action) {
     var launchables = action.GetLaunchables();
     var server = GetServerOverride(action) ?? GetServer(launchables, action.Action);
     if (server != null) {
         // join friend would be :steamid_{id}
         yield return $"+platform:connect:address_{server.Address}"; // TODO: PW
     }
 }
예제 #33
0
 public static IEnumerable <ILaunchableContent> GetLaunchables(this ILaunchContentAction <IContent> action)
 => action.Content.SelectMany(x => x.Content.GetLaunchables(x.Constraint)).Distinct();
예제 #34
0
 protected override IReadOnlyCollection <ILaunchableContent> GetLaunchables(
     ILaunchContentAction <IContent> action)
 => HandleAia(base.GetLaunchables(action));