예제 #1
0
    // Use this for initialization.
    public void OnEnable()
    {
        string dataPath = System.IO.Path.Combine(Application.streamingAssetsPath, "Data");

        modsManager = new ModsManager(dataPath);

        if (Instance != null)
        {
            Debug.ULogErrorChannel("WorldController", "There should never be two world controllers.");
        }

        Instance = this;

        if (loadWorldFromFile != null)
        {
            CreateWorldFromSaveFile();
            loadWorldFromFile = null;
        }
        else
        {
            CreateEmptyWorld();
        }

        soundController = new SoundController(World);

        gameTickDelay = 1f / GameTickPerSecond;
    }
예제 #2
0
        public void AddMod(string name, string sourceURL)
        {
            Mod    mod  = ModsManager.ModWithName(name);
            var    item = Mods.FirstOrDefault(i => i.Mod.Equals(mod));
            Source source;

            if (SourcesManager.TryBuildModSource(sourceURL, out source))
            {
                if (mod == null)
                {
                    mod = new Mod()
                    {
                        Name = name
                    };
                    item = new ModItemViewModel(mod, this);
                    AddModCommand.Execute(item);
                }
                SelectedMod  = item;
                mod.Language = source.Language;

                var srcItem = Mods.SelectMany(i => i.Sources).FirstOrDefault(s => s.Source.HasValidURL && s.Source.URL == sourceURL);
                if (srcItem == null)
                {
                    AddSourceCommand.Execute(new SourceItemViewModel(source, mod, this));
                }
                SelectedSource = srcItem;
            }
        }
예제 #3
0
    // Use this for initialization.
    public void OnEnable()
    {
        if (Instance != null)
        {
            UnityDebugger.Debugger.LogError("WorldController", "There should never be two world controllers.");
        }

        Instance = this;

        new FunctionsManager();
        new PrototypeManager();
        new CharacterNameManager();
        new SpriteManager();
        new AudioManager();

        // FIXME: Do something real here. This is just to show how to register a C# event prototype for the Scheduler.
        PrototypeManager.ScheduledEvent.Add(
            new ScheduledEvent(
                "ping_log",
                (evt) => UnityDebugger.Debugger.LogFormat("Scheduler", "Event {0} fired", evt.Name)));

        modsManager = new ModsManager();

        if (SceneController.loadWorldFromFileName != null)
        {
            CreateWorldFromSaveFile(SceneController.loadWorldFromFileName);
            SceneController.loadWorldFromFileName = null;
        }
        else
        {
            CreateEmptyWorld();
        }

        soundController = new SoundController(World);
    }
예제 #4
0
    private void InitializePanelContent(string panelName, string previousPanelName)
    {
        switch (panelName)
        {
        case "OptionsPanel":
            Options.InitializePanel();
            break;

        case "ModsPanel":
            ModsManager.InitializePanel();
            break;

        case "BrowseRoomsPanel":
            Network.BrowseMatches();
            break;

        case "SelectFactionPanel":
            SquadBuilder.ClearShipsOfPlayer(SquadBuilder.CurrentPlayer);
            break;

        case "SquadBuilderPanel":
            SquadBuilder.UpdateSquadName("SquadBuilderPanel");
            SquadBuilder.ShowShipsAndUpgrades();
            SquadBuilder.UpdateNextButton();
            break;

        case "SelectShipPanel":
            SquadBuilder.ShowShipsFilteredByFaction();
            break;

        case "SelectPilotPanel":
            SquadBuilder.ShowPilotsFilteredByShipAndFaction();
            break;

        case "ShipSlotsPanel":
            SquadBuilder.ShowPilotWithSlots();
            break;

        case "SelectUpgradePanel":
            SquadBuilder.ShowUpgradesList();
            break;

        case "SquadronOptionsPanel":
            SquadBuilder.UpdateSquadName("SquadronOptionsPanel");
            break;

        case "BrowseSavedSquadsPanel":
            SquadBuilder.BrowseSavedSquads();
            break;

        case "SaveSquadronPanel":
            SquadBuilder.PrepareSaveSquadronPanel();
            break;

        case "ShipSkinsPanel":
            SquadBuilder.ShowSkinButtons();
            break;
        }
    }
예제 #5
0
 public ModsManagerUnitTests()
 {
     _modsCacheMock       = CreateModsCacheMock();
     _contentVerifierMock = CreateContentVerifierMock();
     _downloaderMock      = CreateContentDownloaderMock();
     _modsManager         = new ModsManager(
         _downloaderMock.Object,
         _contentVerifierMock.Object,
         _modsCacheMock.Object,
         new NullLogger <ModsManager>());
 }
예제 #6
0
    public void Start()
    {
        Instance = this;

        new SpriteManager();
        new AudioManager();
        modsManager = new ModsManager();

        TimeManager.Instance.IsPaused = true;

        // Create a Background.
        GameObject backgroundGO = new GameObject("Background");

        backgroundGO.AddComponent <SpriteRenderer>().sprite = SpriteManager.GetRandomSprite("Background");

        GameObject canvas = GameObject.Find("Canvas");

        // Create a Title.
        GameObject title = (GameObject)Instantiate(Resources.Load("UI/TitleMainMenu"));

        title.transform.SetParent(canvas.transform, false);
        title.SetActive(true);

        // Display Main Menu.
        GameObject mainMenu = (GameObject)Instantiate(Resources.Load("UI/MainMenu"));

        mainMenu.transform.SetParent(canvas.transform, false);
        mainMenu.SetActive(true);

        // Create dialogBoxes.
        GameObject dialogBoxes = new GameObject("Dialog Boxes");

        dialogBoxes.transform.SetParent(canvas.transform, false);
        dialogBoxes.AddComponent <DialogBoxManager>();

        // Instantiate a FPSCounter.
        GameObject menuTop = (GameObject)Instantiate(Resources.Load("UI/MenuTop"));

        menuTop.name = "MenuTop";
        menuTop.transform.SetParent(canvas.transform, false);
        GameObject fpsCounter = menuTop.GetComponent <PerformanceHUDManager>().gameObject;

        fpsCounter.SetActive(true);

        // Dev Console
        GameObject devConsole = (GameObject)Instantiate(Resources.Load("UI/Console/DevConsole"));

        devConsole.name = "DevConsole";
        devConsole.transform.SetParent(canvas.transform, false);
        devConsole.transform.SetAsLastSibling();
        devConsole.SetActive(false);
        DeveloperConsole.DevConsole.Close();
    }
        // Helper method
        private async Task <(bool, string)> ShowSimilarMods(string mod)
        {
            var mods = ModsManager.Mods.Where(m => string.Equals(m, mod, StringComparison.CurrentCultureIgnoreCase));

            if (mods.Any())
            {
                return(true, string.Empty);
            }
            var cached = await ModsManager.TryCacheMod(mod);

            if (cached)
            {
                return(true, string.Empty);
            }

            const string msg    = "Mod with that name doesn\'t exist";
            var          modMsg = "\nNo similar mods found...";;

            // Find similar mods

            var similarMods =
                ModsManager.Mods
                .Where(m => m.Contains(mod, StringComparison.CurrentCultureIgnoreCase) &&
                       m.LevenshteinDistance(mod) <= m.Length - 2)                                             // prevents insane amount of mods found
                .ToArray();

            if (similarMods.Any())
            {
                if (similarMods.Length == 1)
                {
                    return(true, similarMods.First());
                }

                modMsg = "\nDid you possibly mean any of these?\n" + similarMods.PrettyPrint();
                // Make sure message doesn't exceed discord's max msg length
                if (modMsg.Length > 2000)
                {
                    modMsg = modMsg.Cap(2000 - msg.Length);
                    // Make sure message doesn't end with a half cut modname
                    var index        = modMsg.LastIndexOf(',');
                    var lastModClean = modMsg.Substring(index + 1).Replace("`", "").Trim();
                    if (ModsManager.Mods.All(m => m != lastModClean))
                    {
                        modMsg = modMsg.Substring(0, index);
                    }
                }
            }

            await ReplyAsync($"{msg}{modMsg}");

            return(false, string.Empty);
        }
예제 #8
0
    private void InitializeMenu()
    {
        CurrentMainMenu = this;

        SetCurrentPanel();

        DontDestroyOnLoad(GameObject.Find("GlobalUI").gameObject);

        ModsManager.Initialize();
        Options.ReadOptions();
        Options.UpdateVolume();
        StartCoroutine(CheckUpdates());
    }
예제 #9
0
    private void InitializeMenu()
    {
        CurrentMainMenu = this;
        SetCurrentPanel();

        DontDestroyOnLoad(GameObject.Find("GlobalUI").gameObject);

        SetBackground();
        ModsManager.Initialize();
        Options.ReadOptions();
        Options.UpdateVolume();
        UpdateVersionInfo();
        UpdatePlayerInfo();
        CheckUpdates();
    }
예제 #10
0
    public void Start()
    {
        Instance = this;

        new SpriteManager();
        new AudioManager();
        modsManager = new ModsManager();

        TimeManager.Instance.IsPaused = true;

        // Create a Background.
        GameObject backgroundGO = new GameObject("Background");

        backgroundGO.AddComponent <SpriteRenderer>().sprite = SpriteManager.GetRandomSprite("Background");

        GameObject canvas = GameObject.Find("Canvas");

        // Create a Title.
        GameObject title = (GameObject)Instantiate(Resources.Load("UI/TitleMainMenu"));

        title.transform.SetParent(canvas.transform, false);
        title.SetActive(true);

        // Display Main Menu.
        GameObject mainMenu = (GameObject)Instantiate(Resources.Load("UI/MainMenu"));

        mainMenu.transform.SetParent(canvas.transform, false);
        mainMenu.SetActive(true);

        // Create dialogBoxes.
        GameObject dialogBoxes = new GameObject("Dialog Boxes");

        dialogBoxes.transform.SetParent(canvas.transform, false);
        dialogBoxes.AddComponent <DialogBoxManager>();

        // Instantiate a FPSCounter.
        GameObject menuTop = (GameObject)Instantiate(Resources.Load("UI/MenuTop"));

        menuTop.name = "MenuTop";
        menuTop.transform.SetParent(canvas.transform, false);
        menuTop.SetActive(true);
        GameObject fpsCounter = FindObjectOfType <FPSCounter>().gameObject;

        fpsCounter.SetActive(true);

        // TODO : Activate this when DialogBoxSettings will be fixed. See issue #1526
        ////fpsCounter.SetActive(Settings.GetSetting("DialogBoxSettings_fpsToggle", true));
    }
예제 #11
0
    private void InitializeMenu()
    {
        CurrentMainMenu = this;
        SetCurrentPanel();

        DontDestroyOnLoad(GameObject.Find("GlobalUI").gameObject);

        ModsManager.Initialize();
        Options.ReadOptions();
        Options.UpdateVolume();
        ExtraOptionsManager.Initialize();
        SetBackground();
        UpdateVersionInfo();
        ClearBatchAiSquadsTestingMode();

        PrepareUpdateChecker();

        new ObstaclesManager();
    }
        public async Task <bool> UninstallModAsync()
        {
            var task = new Task <bool>(() =>
            {
                try
                {
                    FileWrite.SafeDeleteFile(FileWrite.GetFileOutputPath(Location, RealName, _legacy));
                    ModsManager.RunOnMainSyncContext(state => ModsManager.InstalledMods.Remove(this));
                    return(true);
                }
                catch (Exception ex)
                {
                    MessageDisplay.RaiseError(new ErrorEventArgs(ex));
                    return(false);
                }
            });

            task.Start();
            return(await task);
        }
예제 #13
0
        /// <summary>
        /// Scans Application.streamingAssetsPath/Localization folder in search for .lang files and load's them
        /// to the LocalizationTable.
        /// </summary>
        public void UpdateLocalizationTable()
        {
            // Load application localization files
            LoadLocalizationInDirectory(Application.streamingAssetsPath);

            // Load mods localization files
            foreach (DirectoryInfo mod in ModsManager.GetModsFiles())
            {
                LoadLocalizationInDirectory(mod.FullName);
            }

            // Attempt to get setting of currently selected language. (Will default to English).
            string lang = SettingsKeyHolder.SelectedLanguage;

            // Setup LocalizationTable with either loaded or defaulted language
            LocalizationTable.currentLanguage = lang;

            // Tell the LocalizationTable that it has been initialized.
            LocalizationTable.LoadingLanguagesFinished();
        }
예제 #14
0
    public void Awake()
    {
        if (Instance == null || Instance == this)
        {
            Instance = this;
        }
        else
        {
            UnityDebugger.Debugger.LogError("Two 'MainMenuController' exist, deleting the new version rather than the old.");
            Destroy(this.gameObject);
        }

        PrototypeManager.Initialize();
        FunctionsManager.Initialize();
        SpriteManager.Initialize();
        AudioManager.Initialize();

        // Load Mods and Settings on awake rather than on Starts
        ModsManager = new ModsManager();
        Settings.LoadSettings();
    }
예제 #15
0
    public void OnEnable()
    {
        if (Instance == null || Instance == this)
        {
            Instance = this;
        }
        else
        {
            UnityDebugger.Debugger.LogError("WorldController", "There should never be two world controllers.");
        }

        FunctionsManager.Initialize();
        PrototypeManager.Initialize();
        CharacterNameManager.Initialize();
        SpriteManager.Initialize();
        AudioManager.Initialize();

        // FIXME: Do something real here. This is just to show how to register a C# event prototype for the Scheduler.
        PrototypeManager.ScheduledEvent.Add(
            new ScheduledEvent(
                "ping_log",
                (evt) => UnityDebugger.Debugger.LogFormat("Scheduler", "Event {0} fired", evt.Name)));

        ModsManager = new ModsManager();

        // Reload incase any mods have changed settings
        Settings.LoadSettings();

        if (SceneController.LoadWorldFromFileName != null)
        {
            CreateWorldFromSaveFile(SceneController.LoadWorldFromFileName);
            SceneController.LoadWorldFromFileName = null;
        }
        else
        {
            CreateEmptyWorld();
        }

        SoundController = new SoundController(World);
    }
예제 #16
0
    public void InitializePanel()
    {
        GameObject prefab    = (GameObject)Resources.Load("Prefabs/UI/ModPanel", typeof(GameObject));
        GameObject ModsPanel = GameObject.Find("UI/Panels").transform.Find("ModsPanel").Find("Scroll View/Viewport/Content").gameObject;

        RectTransform modsPanelRectTransform = ModsPanel.GetComponent <RectTransform>();
        Vector3       currentPosition        = new Vector3(modsPanelRectTransform.sizeDelta.x / 2, -FREE_SPACE, ModsPanel.transform.localPosition.z);

        foreach (Transform transform in ModsPanel.transform)
        {
            Destroy(transform.gameObject);
        }

        modsPanelRectTransform.sizeDelta = new Vector2(modsPanelRectTransform.sizeDelta.x, 0);
        GameObject.Find("UI/Panels").transform.Find("ModsPanel").Find("Scroll View").GetComponentInChildren <ScrollRect>().verticalNormalizedPosition = 0f;

        foreach (var mod in ModsManager.GetAllMods())
        {
            GameObject ModRecord;

            ModRecord = MonoBehaviour.Instantiate(prefab, ModsPanel.transform);
            ModRecord.transform.localPosition = currentPosition;
            ModRecord.name = mod.Key.ToString();

            ModRecord.transform.Find("Label").GetComponent <Text>().text = mod.Value.Name;

            Text description = ModRecord.transform.Find("Text").GetComponent <Text>();
            description.text = mod.Value.Description;
            RectTransform descriptionRectTransform = description.GetComponent <RectTransform>();
            descriptionRectTransform.sizeDelta = new Vector2(descriptionRectTransform.sizeDelta.x, description.preferredHeight);

            RectTransform modRecordRectTransform = ModRecord.GetComponent <RectTransform>();
            modRecordRectTransform.sizeDelta = new Vector2(modRecordRectTransform.sizeDelta.x, modRecordRectTransform.sizeDelta.y + description.preferredHeight);

            currentPosition = new Vector3(currentPosition.x, currentPosition.y - modRecordRectTransform.sizeDelta.y - FREE_SPACE, currentPosition.z);
            modsPanelRectTransform.sizeDelta = new Vector2(modsPanelRectTransform.sizeDelta.x, modsPanelRectTransform.sizeDelta.y + modRecordRectTransform.sizeDelta.y + FREE_SPACE);

            ModRecord.transform.Find("Toggle").GetComponent <Toggle>().isOn = ModsManager.Mods[mod.Key].IsOn;
        }
    }
예제 #17
0
    // Use this for initialization.
    public void OnEnable()
    {
        Debug.IsLogEnabled = true;
        if (Instance != null)
        {
            Debug.ULogErrorChannel("WorldController", "There should never be two world controllers.");
        }

        Instance = this;

        new FunctionsManager();
        new PrototypeManager();
        new CharacterNameManager();

        // FIXME: Do something real here. This is just to show how to register a C# event prototype for the Scheduler.
        PrototypeManager.SchedulerEvent.Add(
            "ping_log",
            new ScheduledEvent(
                "ping_log",
                (evt) => Debug.ULogChannel("Scheduler", "Event {0} fired", evt.Name)));

        string dataPath = System.IO.Path.Combine(Application.streamingAssetsPath, "Data");

        modsManager = new ModsManager(dataPath);

        if (loadWorldFromFile != null)
        {
            CreateWorldFromSaveFile();
            loadWorldFromFile = null;
        }
        else
        {
            CreateEmptyWorld();
        }

        soundController = new SoundController(World);

        gameTickDelay = TimeManager.GameTickDelay;
    }
예제 #18
0
    // Use this for initialization
    void OnEnable()
    {
        string dataPath = System.IO.Path.Combine(Application.streamingAssetsPath, "Data");

        modsManager = new ModsManager(dataPath);

        if (Instance != null)
        {
            Debug.LogError("There should never be two world controllers.");
        }
        Instance = this;

        if (loadWorldFromFile != null)
        {
            CreateWorldFromSaveFile();
            loadWorldFromFile = null;
        }
        else
        {
            CreateEmptyWorld();
        }

        soundController = new SoundController(world);
    }
예제 #19
0
    public static XElement CombineXml(XElement node, IEnumerable <FileEntry> files, string attr1 = null, string attr2 = null, string type = null)
    {
        Func <XElement, IEnumerable <FileEntry>, string, string, string, XElement> combineXml = CombineXml1;

        if (combineXml != null)
        {
            return(combineXml(node, files, attr1, attr2, type));
        }
        IEnumerator <FileEntry> enumerator = files.GetEnumerator();

        while (enumerator.MoveNext())
        {
            try
            {
                XElement src = XmlUtils.LoadXmlFromStream(enumerator.Current.Stream, null, throwOnError: true);
                Modify(node, src, attr1, attr2, type);
            }
            catch (Exception arg)
            {
                ModsManager.ErrorHandler(enumerator.Current, arg);
            }
        }
        return(node);
    }
예제 #20
0
    private void InitializePanelContent(string panelName, string previousPanelName)
    {
        switch (panelName)
        {
        case "RosterBuilderPanel":
            if (previousPanelName == "GameModeDecisionPanel")
            {
                RosterBuilder.Initialize();
            }
            break;

        case "OptionsPanel":
            Options.InitializePanel();
            break;

        case "ModsPanel":
            ModsManager.InitializePanel();
            break;

        case "BrowseRoomsPanel":
            Network.BrowseMatches();
            break;
        }
    }
예제 #21
0
    private void InitializePanelContent(string panelName, string previousPanelName)
    {
        switch (panelName)
        {
        case "MainMenuPanel":
            UpdatePlayerInfo();
            break;

        case "OptionsPanel":
            //Options.InitializePanel();
            OptionsUI.Instance.InitializeOptionsPanel();
            break;

        case "ModsPanel":
            ModsManager.InitializePanel();
            break;

        case "CreditsPanel":
            CreditsUI.InitializePanel();
            break;

        case "BrowseRoomsPanel":
            Network.BrowseMatches();
            break;

        case "SelectFactionPanel":
            SquadBuilder.SetCurrentPlayerFaction(Faction.None);
            SquadBuilder.ClearShipsOfPlayer(SquadBuilder.CurrentPlayer);
            SquadBuilder.ShowFactionsImages();
            break;

        case "SquadBuilderPanel":
            SquadBuilder.CheckAiButtonVisibility();
            SquadBuilder.UpdateSquadName("SquadBuilderPanel");
            SquadBuilder.ShowShipsAndUpgrades();
            SquadBuilder.UpdateNextButton();
            break;

        case "SelectShipPanel":
            SquadBuilder.ShowShipsFilteredByFaction();
            break;

        case "SelectPilotPanel":
            SquadBuilder.ShowPilotsFilteredByShipAndFaction();
            break;

        case "ShipSlotsPanel":
            SquadBuilder.ShowPilotWithSlots();
            break;

        case "SelectUpgradePanel":
            SquadBuilder.ShowUpgradesList();
            break;

        case "SquadronOptionsPanel":
            SquadBuilder.UpdateSquadName("SquadronOptionsPanel");
            break;

        case "BrowseSavedSquadsPanel":
            SquadBuilder.BrowseSavedSquads();
            break;

        case "SaveSquadronPanel":
            SquadBuilder.PrepareSaveSquadronPanel();
            break;

        case "AvatarsPanel":
            InitializePlayerCustomization();
            break;

        case "EditionPanel":
            ShowActiveEdition(Options.Edition);
            break;

        case "ShipInfoPanel":
            SquadBuilder.ShowShipInformation();
            break;

        case "SkinsPanel":
            SquadBuilder.ShowSkinsPanel();
            break;

        case "ChosenObstaclesPanel":
            SquadBuilder.ShowChosenObstaclesPanel();
            break;

        case "BrowseObstaclesPanel":
            SquadBuilder.ShowBrowseObstaclesPanel();
            break;
        }
    }
예제 #22
0
 public override void Execute(bool parameter)
 {
     ModsManager.NormalizeMods();
     StorageManager.Sync();
 }
예제 #23
0
    private void InitializePanelContent(string panelName, string previousPanelName)
    {
        switch (panelName)
        {
        case "MainMenuPanel":
            ClearBatchAiSquadsTestingMode();
            break;

        case "OptionsPanel":
            OptionsUI.Instance.InitializeOptionsPanel();
            break;

        case "StatsPanel":
            StatsUI.Instance.InitializeStatsPanel();
            break;

        case "ModsPanel":
            ModsManager.InitializePanel();
            break;

        case "CreditsPanel":
            CreditsUI.InitializePanel();
            break;

        case "BrowseRoomsPanel":
            BrowseMatches();
            break;

        case "SelectFactionPanel":
            Global.SquadBuilder.CurrentSquad.ClearAll();
            Global.SquadBuilder.View.ShowFactionsImages();
            break;

        case "SquadBuilderPanel":
            Global.SquadBuilder.View.ShowShipsAndUpgrades();
            Global.SquadBuilder.View.UpdateNextButton();
            break;

        case "SelectShipPanel":
            Global.SquadBuilder.View.ShowShipsFilteredByFaction();
            break;

        case "SelectPilotPanel":
            Global.SquadBuilder.View.ShowPilotsFilteredByShipAndFaction();
            break;

        case "ShipSlotsPanel":
            Global.SquadBuilder.View.ShowPilotWithSlots();
            break;

        case "SelectUpgradePanel":
            Global.SquadBuilder.View.ShowUpgradesList();
            break;

        case "BrowseSavedSquadsPanel":
            Global.SquadBuilder.View.BrowseSavedSquads();
            break;

        case "SaveSquadronPanel":
            Global.SquadBuilder.View.PrepareSaveSquadronPanel();
            break;

        case "AvatarsPanel":
            InitializePlayerCustomization();
            break;

        case "EditionPanel":
            ShowActiveEdition(Options.Edition);
            break;

        case "ShipInfoPanel":
            Global.SquadBuilder.View.ShowShipInformation();
            break;

        case "SkinsPanel":
            Global.SquadBuilder.View.ShowSkinsPanel();
            break;

        case "ChosenObstaclesPanel":
            Global.SquadBuilder.View.ShowChosenObstaclesPanel();
            break;

        case "BrowseObstaclesPanel":
            Global.SquadBuilder.View.ShowBrowseObstaclesPanel();
            break;

        case "BrowsePopularSquadsPanel":
            if (previousPanelName == "SquadOptionsPanel")
            {
                PopularSquads.LastChosenFaction = "All";
            }
            PopularSquads.LoadPopularSquads();
            break;

        case "BrowsePopularSquadsVariantsPanel":
            PopularSquads.LoadPopularSquadsVariants();
            break;

        case "BrowseAvatarsPanel":
            AvatarsManager.LoadAvatars(Faction.None);
            break;
        }
    }
예제 #24
0
    public void Setup()
    {
        string buildOrderActionJson = @"{""Build"": {
          ""JobTime"": 1.0,
          ""Inventory"": {
            ""Steel Plate"": 5,
            ""Copper Plate"": 2
          }
        }}";

        string deconstructOrderActionJson = @"
        {'Deconstruct': {
          'JobTime': 1.0,
          'JobCategory':'invalid',
          'Inventory': {
            'Steel Plate': 5,
            'Copper Plate': 2
          }
        }}";

        string uninstallOrderActionJson = @"{""Uninstall"": {
          ""JobTime"": 1.0,
          ""JobCategory"":""hauling"",
          ""JobPriority"":2,
          ""Inventory"": {
            ""Steel Plate"": 5,
            ""Copper Plate"": 2
          }
        }}";

        string jobCategoryJson = @"
        {   
            'JobCategory':{
	            'construct':{ 'localizationName':'job_category_construct'},
                'hauling':{ 'localizationName':'job_category_haul'}
            }
        }
        ";

        ModsManager modManager = new ModsManager();
        modManager.SetupPrototypeHandlers();

        Dictionary<string, JToken> jsonPrototypes = new Dictionary<string, JToken>();
        JToken protoJson = JToken.ReadFrom(new JsonTextReader(new StringReader(jobCategoryJson)));
        string tagName = ((JProperty)protoJson.First).Name;

        jsonPrototypes.Add(tagName, protoJson);
        modManager.LoadPrototypesFromJTokens(jsonPrototypes);

        constructCategory = PrototypeManager.JobCategory.Get("construct");
        haulCategory = PrototypeManager.JobCategory.Get("hauling");

        protoJson = JToken.ReadFrom(new JsonTextReader(new StringReader(buildOrderActionJson))).First;
        defaultOrderAction = ProjectPorcupine.OrderActions.OrderAction.FromJson((JProperty)protoJson);

        protoJson = JToken.ReadFrom(new JsonTextReader(new StringReader(deconstructOrderActionJson))).First;
        badOrderAction = ProjectPorcupine.OrderActions.OrderAction.FromJson((JProperty)protoJson);

        protoJson = JToken.ReadFrom(new JsonTextReader(new StringReader(uninstallOrderActionJson))).First;
        updatedOrderAction = ProjectPorcupine.OrderActions.OrderAction.FromJson((JProperty)protoJson);

        UnityEngine.TestTools.LogAssert.Expect(UnityEngine.LogType.Error, "Stat keys not found. If not testing, this is really bad!");
        character = new Character();
    }
        public async Task Mod([Remainder] string mod)
        {
            mod = mod.RemoveWhitespace();

            if (mod.EqualsIgnoreCase(">count"))
            {
                await ReplyAsync($"Found `{ModsManager.Mods.Count()}` cached mods");

                return;
            }

            var(result, str) = await ShowSimilarMods(mod);

            if (result)
            {
                if (string.IsNullOrEmpty(str))
                {
                    // Fixes not finding files
                    mod = ModsManager.Mods.FirstOrDefault(m => string.Equals(m, mod, StringComparison.CurrentCultureIgnoreCase));
                    if (mod == null)
                    {
                        return;
                    }
                }
                else
                {
                    mod = str;
                }

                // Some mod is found continue.
                var modjson = JObject.Parse(await BotUtils.FileReadToEndAsync(new SemaphoreSlim(1, 1), ModsManager.ModPath(mod)));
                var eb      = new EmbedBuilder()
                              .WithTitle("Mod: ")
                              .WithCurrentTimestamp()
                              .WithAuthor(new EmbedAuthorBuilder
                {
                    IconUrl = Context.Message.Author.GetAvatarUrl(),
                    Name    = $"Requested by {Context.Message.Author.FullName()}"
                });

                foreach (var property in modjson.Properties().Where(x => !string.IsNullOrEmpty(x.Value.ToString())))
                {
                    var name  = property.Name;
                    var value = property.Value;

                    if (name.EqualsIgnoreCase("displayname"))
                    {
                        eb.Title += value.ToString();
                    }
                    else if (name.EqualsIgnoreCase("downloads"))
                    {
                        eb.AddField("# of Downloads", $"{property.Value:n0}", true);
                    }
                    else if (name.EqualsIgnoreCase("updatetimestamp"))
                    {
                        eb.AddField("Last updated", DateTime.Parse($"{property.Value}").ToString("dddd, MMMMM d, yyyy h:mm:ss tt", new CultureInfo("en-US")), true);
                    }
                    else if (name.EqualsIgnoreCase("iconurl"))
                    {
                        eb.ThumbnailUrl = value.ToString();
                    }
                    else
                    {
                        eb.AddField(name.FirstCharToUpper(), value, true);
                    }
                }

                eb.AddField("Widget", $"<{ModsManager.WidgetUrl}{mod}.png>", true);
                using (var client = new System.Net.Http.HttpClient())
                {
                    var response = await client.GetAsync(ModsManager.QueryHomepageUrl + mod);

                    var postResponse = await response.Content.ReadAsStringAsync();

                    if (!string.IsNullOrEmpty(postResponse) && !postResponse.StartsWith("Failed:"))
                    {
                        eb.Url = postResponse;
                        eb.AddField("Homepage", $"<{postResponse}>", true);
                    }
                }

                await ReplyAsync("", embed : eb.Build());
            }
        }
예제 #26
0
        public override void Initialize()
        {
            int num = 0;
            Dictionary <int, MekClothData> dictionary = new Dictionary <int, MekClothData>();
            IEnumerator <XElement>         enumerator = XmlUtils.LoadXmlFromStream(ModsManager.GetEntries(".xclo")[0].Stream, Encoding.UTF8, true).Elements().GetEnumerator();

            while (enumerator.MoveNext())
            {
                XElement     current      = enumerator.Current;
                MekClothData clothingData = new MekClothData
                {
                    Index                    = XmlUtils.GetAttributeValue <int>(current, "Index"),
                    DisplayIndex             = num++,
                    DisplayName              = XmlUtils.GetAttributeValue <string>(current, "DisplayName"),
                    Slot                     = XmlUtils.GetAttributeValue <ClothingSlot>(current, "Slot"),
                    ArmorProtection          = XmlUtils.GetAttributeValue <float>(current, "ArmorProtection"),
                    Sturdiness               = XmlUtils.GetAttributeValue <float>(current, "Sturdiness"),
                    Insulation               = XmlUtils.GetAttributeValue <float>(current, "Insulation"),
                    MovementSpeedFactor      = XmlUtils.GetAttributeValue <float>(current, "MovementSpeedFactor"),
                    SteedMovementSpeedFactor = XmlUtils.GetAttributeValue <float>(current, "SteedMovementSpeedFactor"),
                    DensityModifier          = XmlUtils.GetAttributeValue <float>(current, "DensityModifier"),
                    IsOuter                  = XmlUtils.GetAttributeValue <bool>(current, "IsOuter"),
                    CanBeDyed                = XmlUtils.GetAttributeValue <bool>(current, "CanBeDyed"),
                    Layer                    = XmlUtils.GetAttributeValue <int>(current, "Layer"),
                    PlayerLevelRequired      = XmlUtils.GetAttributeValue <int>(current, "PlayerLevelRequired"),
                    Texture                  = ContentManager.Get <Texture2D>(XmlUtils.GetAttributeValue <string>(current, "TextureName")),
                    ImpactSoundsFolder       = XmlUtils.GetAttributeValue <string>(current, "ImpactSoundsFolder"),
                    Description              = XmlUtils.GetAttributeValue <string>(current, "Description")
                };
                dictionary[clothingData.Index] = clothingData;
            }
            clothingData = new MekClothData[dictionary.Count];
            int i = 0;

            foreach (KeyValuePair <int, MekClothData> keyValuePair in dictionary)
            {
                clothingData[i] = keyValuePair.Value;
                ++i;
            }
            Model playerModel = CharacterSkinsManager.GetPlayerModel(PlayerClass.Male);

            Matrix[] array = new Matrix[playerModel.Bones.Count];
            playerModel.CopyAbsoluteBoneTransformsTo(array);
            i = playerModel.FindBone("Hand1").Index;
            int index = playerModel.FindBone("Hand2").Index;

            array[i]     = Matrix.CreateRotationY(0.1f) * array[i];
            array[index] = Matrix.CreateRotationY(-0.1f) * array[index];
            m_innerMesh  = new BlockMesh();
            foreach (ModelMesh mesh in playerModel.Meshes)
            {
                Matrix matrix = array[mesh.ParentBone.Index];
                foreach (ModelMeshPart meshPart in mesh.MeshParts)
                {
                    Color color = Color.White * 0.8f;
                    color.A = byte.MaxValue;
                    m_innerMesh.AppendModelMeshPart(meshPart, matrix, makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, Color.White);
                    m_innerMesh.AppendModelMeshPart(meshPart, matrix, makeEmissive: false, flipWindingOrder: true, doubleSided: false, flipNormals: true, color);
                }
            }
            Model outerClothingModel = CharacterSkinsManager.GetOuterClothingModel(PlayerClass.Male);

            Matrix[] array2 = new Matrix[outerClothingModel.Bones.Count];
            outerClothingModel.CopyAbsoluteBoneTransformsTo(array2);
            int index2 = outerClothingModel.FindBone("Leg1").Index;
            int index3 = outerClothingModel.FindBone("Leg2").Index;

            array2[index2] = Matrix.CreateTranslation(-0.02f, 0f, 0f) * array2[index2];
            array2[index3] = Matrix.CreateTranslation(0.02f, 0f, 0f) * array2[index3];
            m_outerMesh    = new BlockMesh();
            foreach (ModelMesh mesh2 in outerClothingModel.Meshes)
            {
                Matrix matrix2 = array2[mesh2.ParentBone.Index];
                foreach (ModelMeshPart meshPart2 in mesh2.MeshParts)
                {
                    Color color2 = Color.White * 0.8f;
                    color2.A = byte.MaxValue;
                    m_outerMesh.AppendModelMeshPart(meshPart2, matrix2, makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, Color.White);
                    m_outerMesh.AppendModelMeshPart(meshPart2, matrix2, makeEmissive: false, flipWindingOrder: true, doubleSided: false, flipNormals: true, color2);
                }
            }
        }
예제 #27
0
    public void OnClickModActivationChange(GameObject ModGO)
    {
        bool toggleValue = ModGO.transform.Find("Toggle").GetComponent <Toggle>().isOn;

        ModsManager.ModToggleIsActive(ModGO.name, toggleValue);
    }