/// <summary> /// Adds an upgrade to the page of the specified <see cref="Mod"/>, if the upgrade is a modded upgrade or not currently used it will also be added to <see cref="UpgradeManager.UpgradeDescriptions"/> /// </summary> /// <param name="upgradeManager"></param> /// <param name="upgrade">The <see cref="UpgradeDescription"/> of the upgrade to add</param> /// <param name="mod">The <see cref="Mod"/> that owns the upgrade</param> public static void AddUpgrade(this UpgradeManager upgradeManager, UpgradeDescription upgrade, Mod mod) { if (upgrade.IsModdedUpgradeType() || !UpgradeManager.Instance.IsUpgradeTypeAndLevelUsed(upgrade.UpgradeType, upgrade.Level)) { UpgradeManager.Instance.UpgradeDescriptions.Add(upgrade); } // Old mod loading system UpgradePagesManager.AddUpgrade(upgrade.UpgradeType, upgrade.Level, mod); // New mod loading system // UpgradePagesManager.AddUpgrade(upgrade.UpgradeType, upgrade.Level, mod.ModInfo.UniqueID); if (upgrade is AbilityUpgrade) { Dictionary <UpgradeType, bool> _abilityUpgradeTypes = Accessor.GetPrivateField <UpgradeManager, Dictionary <UpgradeType, bool> >("_abilityUpgradeTypes", UpgradeManager.Instance); _abilityUpgradeTypes[upgrade.UpgradeType] = true; } if (upgrade.Requirement != null) { recursivelyAddRequirments(upgrade, mod); } string nameID = upgrade.UpgradeName.ToLower().Trim(); ModBotLocalizationManager.TryAddModdedUpgradeLocalizationStringToDictionary(nameID, upgrade.UpgradeName); string descriptionID = upgrade.Description.ToLower().Trim(); ModBotLocalizationManager.TryAddModdedUpgradeLocalizationStringToDictionary(descriptionID, upgrade.Description); }
static IEnumerator downloadImageAndSetIconOnUpgrade(UpgradeDescription upgrade, string url) { UnityWebRequest webRequest = UnityWebRequestTexture.GetTexture(url); yield return(webRequest.SendWebRequest()); if (webRequest.isNetworkError || webRequest.isHttpError) { debug.Log(webRequest.error, Color.red); upgrade.Icon = null; yield break; } Texture2D texture = ((DownloadHandlerTexture)webRequest.downloadHandler).texture; upgrade.Icon = getSpriteFromTexture(texture); string fileName = getFileNameForUpgrade(upgrade); byte[] fileData = texture.EncodeToPNG(); FileStream fileStream = File.Create(upgradeIconsFolderPath + fileName); fileStream.Write(fileData, 0, fileData.Length); fileStream.Close(); }
static string getFileNameForUpgrade(UpgradeDescription upgrade) { string upgradeTypeName = upgrade.UpgradeType.ToString(); string upgradeLevel = upgrade.Level.ToString(); return(upgradeTypeName + UPGRADE_AND_LEVEL_FILE_NAME_SEPARATOR + upgradeLevel + ".png"); }
/// <summary> /// Adds a new upgrade to the upgrade tree /// </summary> /// <param name="UpgradeID">The ID of the upgrade (If ID is already taken, the upgrade will not be added)</param> /// <param name="Name"></param> /// <param name="Description"></param> /// <param name="Icon">The display image of the upgrade</param> /// <param name="AngleOffset">The offset angle in the tree</param> /// <param name="IsLimited">If the upgrade has a limited number of uses (Like Clone)</param> /// <param name="IsRepeatable">Is the upgrade is repeatable (Like Armor)</param> /// <param name="MaxUses">Set the max uses of an upgrade (Will do nothing if IsLimited is false)</param> /// <param name="SortOrder"></param> /// <param name="Requirement">First Requirement</param> /// <param name="SecondRequirement">Second Requirement</param> /// <returns>The created upgrade, will be null if upgrade with ID already exists</returns> public static UpgradeDescription Add(int UpgradeID, string Name, string Description, Sprite Icon, float AngleOffset, bool IsLimited, bool IsRepeatable, int MaxUses, int SortOrder, UpgradeDescription Requirement, UpgradeDescription SecondRequirement) { if (IsIDAlreadyUsed(UpgradeID)) { return(null); } UpgradeDescription upgrade = UpgradeManager.Instance.UpgradeDescriptions[0].gameObject.AddComponent <UpgradeDescription>(); upgrade.AngleOffset = AngleOffset; upgrade.CanBeTransferredInMultiplayer = false; upgrade.Description = Description; upgrade.HideInStoryMode = false; upgrade.Icon = Icon; upgrade.IsAvailableInMultiplayer = false; upgrade.IsConsumable = IsLimited; upgrade.IsDisabledInBattleRoyale = true; upgrade.IsRepeatable = IsRepeatable; upgrade.IsUpgradeVisible = true; upgrade.Level = 1; upgrade.MaxRepetitions = MaxUses; upgrade.RequiredMetagameProgress = MetagameProgress.P0_None; upgrade.Requirement = Requirement; upgrade.Requirement2 = SecondRequirement; upgrade.SkillPointCostBattleRoyale = 5; upgrade.SkillPointCostMultiplayer = 100; upgrade.SortOrder = SortOrder; upgrade.UpgradeName = Name; upgrade.UpgradeType = (UpgradeType)UpgradeID; UpgradeManager.Instance.UpgradeDescriptions.Add(upgrade); return(upgrade); }
/// <summary> /// Validate the object. /// </summary> /// <exception cref="ValidationException"> /// Thrown if validation fails /// </exception> public virtual void Validate() { if (Certificate != null) { Certificate.Validate(); } if (ClientCertificateCommonNames != null) { foreach (var element in ClientCertificateCommonNames) { if (element != null) { element.Validate(); } } } if (ClientCertificateThumbprints != null) { foreach (var element1 in ClientCertificateThumbprints) { if (element1 != null) { element1.Validate(); } } } if (FabricSettings != null) { foreach (var element2 in FabricSettings) { if (element2 != null) { element2.Validate(); } } } if (NodeTypes != null) { foreach (var element3 in NodeTypes) { if (element3 != null) { element3.Validate(); } } } if (ReverseProxyCertificate != null) { ReverseProxyCertificate.Validate(); } if (UpgradeDescription != null) { UpgradeDescription.Validate(); } if (ApplicationTypeVersionsCleanupPolicy != null) { ApplicationTypeVersionsCleanupPolicy.Validate(); } }
/// <summary> /// Sets angle offset of this upgrade on the mod page, NOTE: Needs to be run AFTER <see cref="UpgradeManager"/>.AddUpgrade(<see cref="UpgradeDescription"/>, <see cref="Mod"/>) is called /// </summary> /// <param name="upgradeDescription"></param> /// <param name="angle">The new angle of the <see cref="UpgradeDescription"/></param> /// <param name="mod">The <see cref="Mod"/> that owns the upgrade</param> public static void SetAngleOffset(this UpgradeDescription upgradeDescription, float angle, Mod mod) { // Old mod loading system UpgradePagesManager.SetAngleOfModdedUpgrade(angle, upgradeDescription.UpgradeType, upgradeDescription.Level, mod); // New mod loading system // UpgradePagesManager.SetAngleOfModdedUpgrade(angle, upgradeDescription.UpgradeType, upgradeDescription.Level, mod.ModInfo.UniqueID); }
/// <summary> /// Sets the angle of an upgrade with the specified <see cref="UpgradeType"/> and level /// </summary> /// <param name="upgradeManager"></param> /// <param name="upgradeType">The <see cref="UpgradeType"/> of the <see cref="UpgradeDescription"/> to set the angle on</param> /// <param name="level">The level of the <see cref="UpgradeDescription"/> to set the angle on</param> /// <param name="angle">The new angle to set</param> /// <param name="mod">The <see cref="Mod"/> that owns the upgrade</param> public static void SetUpgradeAngle(this UpgradeManager upgradeManager, UpgradeType upgradeType, int level, float angle, Mod mod) { UpgradeDescription upgradeDescription = UpgradeManager.Instance.GetUpgrade(upgradeType, level); if (upgradeDescription == null) { return; } upgradeDescription.SetAngleOffset(angle, mod); }
private void Start() { _button = GetComponent <Button>(); upgradeDescription = FindObjectOfType <UpgradeDescription>(); level = _upgradeSo.level; cost = _upgradeSo.cost; description = _upgradeSo.description; upgradeImage = _upgradeSo.upgradeImage; costTmp.text = cost.ToString(); icon.sprite = upgradeImage; icon_shade.sprite = upgradeImage; }
void updateIcon(UpgradeUIIcon icon, BaseEventData eventData) { float scrollDelta = eventData.currentInputModule.input.mouseScrollDelta.y; float newAngle = getAngleForIconAtCurrentPage(icon) + scrollDelta; setAngleOfUpgrade(icon, newAngle); UpgradeDescription upgradeDescription = icon.GetDescription(); ModdedUpgradeRepresenter upgrade = new ModdedUpgradeRepresenter(upgradeDescription.UpgradeType, upgradeDescription.Level); _changedIconAngles[upgrade] = newAngle; Accessor.CallPrivateMethod("PopulateIcons", GameUIRoot.Instance.UpgradeUI); RefreshIconEventTriggers(); }
static void setAngleOfUpgrade(UpgradeUIIcon icon, float newAngle) { UpgradeDescription upgradeDescription = icon.GetDescription(); if (upgradeDescription == null) { return; } // Old mod loading system upgradeDescription.SetAngleOffset(newAngle, UpgradePagesManager.TryGetModForPage(UpgradePagesManager.CurrentPage)); // New mod loading system // upgradeDescription.SetAngleOffset(newAngle, ModsManager.Instance.GetLoadedModWithID(UpgradePagesManager.TryGetModIDForPage(UpgradePagesManager.CurrentPage)).ModReference); }
static string getUpgradeName(ModdedUpgradeRepresenter upgrade) { if (upgrade == null) { return(string.Empty); } UpgradeDescription upgradeDescription = UpgradeManager.Instance.GetUpgrade(upgrade.UpgradeType, upgrade.Level); if (upgradeDescription == null) { return(string.Empty); } return(upgradeDescription.UpgradeName); }
/// <summary> /// Sets the icon of the upgrade to the image gotten from the url /// </summary> /// <param name="upgrade"></param> /// <param name="url"></param> public void SetIconOnUpgrade(UpgradeDescription upgrade, string url) { string fileName = getFileNameForUpgrade(upgrade); if (File.Exists(upgradeIconsFolderPath + fileName)) { byte[] imageData = File.ReadAllBytes(upgradeIconsFolderPath + fileName); Texture2D texture = new Texture2D(2, 2, TextureFormat.RGB24, false); texture.LoadImage(imageData); upgrade.Icon = getSpriteFromTexture(texture); } else { StartCoroutine(downloadImageAndSetIconOnUpgrade(upgrade, url)); } }
static void recursivelyAddRequirments(UpgradeDescription upgrade, Mod mod) { if (upgrade == null) { return; } // Old mod loading system UpgradePagesManager.AddUpgrade(upgrade.UpgradeType, upgrade.Level, mod); // New mod loading system // UpgradePagesManager.AddUpgrade(upgrade.UpgradeType, upgrade.Level, mod.ModInfo.UniqueID); if (upgrade.Requirement2 != null) { recursivelyAddRequirments(upgrade.Requirement2, mod); } recursivelyAddRequirments(upgrade.Requirement, mod); }
/// <summary> /// Gives the specified upgrade to a FirstPersonMover /// </summary> /// <param name="Target"></param> /// <param name="Upgrade"></param> public static void Give(FirstPersonMover Target, UpgradeDescription Upgrade) { if (Target == null) { return; } if (Target.IsMainPlayer()) { GameDataManager.Instance.SetUpgradeLevel(Upgrade.UpgradeType, Upgrade.Level); UpgradeDescription upgrade = UpgradeManager.Instance.GetUpgrade(Upgrade.UpgradeType, Upgrade.Level); GlobalEventManager.Instance.Dispatch("UpgradeCompleted", upgrade); } else { UpgradeCollection upgradeCollection = Target.gameObject.GetComponent <UpgradeCollection>(); if (upgradeCollection == null) { debug.Log("Failed to give upgrade '" + Upgrade.UpgradeName + "' (Level: " + Upgrade.Level + ") to " + Target.CharacterName + " (UpgradeCollection is null)", Color.red); return; } UpgradeTypeAndLevel upgradeToGive = new UpgradeTypeAndLevel { UpgradeType = Upgrade.UpgradeType, Level = Upgrade.Level }; List <UpgradeTypeAndLevel> upgrades = ((PreconfiguredUpgradeCollection)upgradeCollection).Upgrades.ToList(); upgrades.Add(upgradeToGive); ((PreconfiguredUpgradeCollection)upgradeCollection).Upgrades = upgrades.ToArray(); ((PreconfiguredUpgradeCollection)upgradeCollection).InitializeUpgrades(); Target.RefreshUpgrades(); } Target.SetUpgradesNeedsRefreshing(); }
/// <summary> /// Gets the angle offset of a upgrade on the current page, if the upgrade isnt in the modded list, returns the defualt angleOffset of that upgrade /// </summary> /// <param name="upgradeType"></param> /// <param name="upgradeLevel"></param> /// <returns></returns> public static float GetAngleOfUpgrade(UpgradeType upgradeType, int upgradeLevel) { UpgradeDescription upgradeInUpgradeList = UpgradeManager.Instance.GetUpgrade(upgradeType, upgradeLevel); if (CurrentPage == 0) // If we are on the first page, only display the normal values { return(upgradeInUpgradeList != null ? upgradeInUpgradeList.AngleOffset : 0f); } var currentMod = GenerateModPages()[CurrentPage - 1]; foreach (ModdedUpgradeRepresenter upgrade in currentMod.Value) { if (upgrade.UpgradeType != upgradeType || upgrade.Level != upgradeLevel) { continue; } return(upgrade.GetAngleOffset()); } return(upgradeInUpgradeList.AngleOffset); }
/// <summary> /// Gives the specified upgrade to a <see cref="FirstPersonMover"/> /// </summary> /// <param name="firstPersonMover"></param> /// <param name="upgradeType">The <see cref="UpgradeType"/> to give</param> /// <param name="level">The level of the upgrade</param> /// <exception cref="ArgumentNullException">If the given <see cref="FirstPersonMover"/> is <see langword="null"/></exception> /// <exception cref="ArgumentException">If the given <see cref="UpgradeType"/> and level has not been defined in <see cref="UpgradeManager.UpgradeDescriptions"/></exception> public static void GiveUpgrade(this FirstPersonMover firstPersonMover, UpgradeType upgradeType, int level) { if (firstPersonMover == null) { throw new ArgumentNullException(nameof(firstPersonMover)); } if (UpgradeManager.Instance.GetUpgrade(upgradeType, level) == null) { throw new ArgumentException("The upgrade with type \"" + upgradeType + "\" and level " + level + " has not been defined!"); } if (firstPersonMover.GetComponent <PreconfiguredUpgradeCollection>() != null) // If we are giving an upgrade to an enemy/ally { PreconfiguredUpgradeCollection upgradeCollection = firstPersonMover.GetComponent <PreconfiguredUpgradeCollection>(); UpgradeTypeAndLevel upgradeToGive = new UpgradeTypeAndLevel { UpgradeType = upgradeType, Level = level }; List <UpgradeTypeAndLevel> upgrades = upgradeCollection.Upgrades.ToList(); upgrades.Add(upgradeToGive); upgradeCollection.Upgrades = upgrades.ToArray(); upgradeCollection.InitializeUpgrades(); firstPersonMover.RefreshUpgrades(); } else if (firstPersonMover.GetComponent <PlayerUpgradeCollection>() != null) // If we are giving it to the player { GameDataManager.Instance.SetUpgradeLevel(upgradeType, level); // Set the level of the upgrade to the given one UpgradeDescription upgrade = UpgradeManager.Instance.GetUpgrade(upgradeType, level); GlobalEventManager.Instance.Dispatch(GlobalEvents.UpgradeCompleted, upgrade); } firstPersonMover.SetUpgradesNeedsRefreshing(); }
/// <summary> /// Gets an UpgradeTypeAndLevel from an UpgradeDescription /// </summary> /// <param name="upgrade"></param> /// <returns></returns> public static UpgradeTypeAndLevel GetUpgradeTypeAndLevelFromUpgradeDescription(UpgradeDescription upgrade) { return(new UpgradeTypeAndLevel { Level = upgrade.Level, UpgradeType = upgrade.UpgradeType }); }
/// <summary> /// Sets the icon of the upgrade to an image, this needs a internet connection (NOTE: This has a cache so if you want to change the icon you'll want to remove it from the cache in the data folder first) /// </summary> /// <param name="upgradeDescription"></param> /// <param name="url">The url to get the image from</param> public static void SetIconFromURL(this UpgradeDescription upgradeDescription, string url) { UpgradeIconDownloader.Instance.SetIconOnUpgrade(upgradeDescription, url); }
/// <summary> /// Checks if the upgrade is a modded upgrade /// </summary> /// <param name="upgrade"></param> /// <returns></returns> public static bool IsModdedUpgradeType(this UpgradeDescription upgrade) { return(upgrade.UpgradeType.IsModdedUpgradeType()); }
/// <summary> /// Validate the object. /// </summary> /// <exception cref="ValidationException"> /// Thrown if validation fails /// </exception> public override void Validate() { base.Validate(); if (ManagementEndpoint == null) { throw new ValidationException(ValidationRules.CannotBeNull, "ManagementEndpoint"); } if (NodeTypes == null) { throw new ValidationException(ValidationRules.CannotBeNull, "NodeTypes"); } if (Certificate != null) { Certificate.Validate(); } if (ClientCertificateCommonNames != null) { foreach (var element in ClientCertificateCommonNames) { if (element != null) { element.Validate(); } } } if (ClientCertificateThumbprints != null) { foreach (var element1 in ClientCertificateThumbprints) { if (element1 != null) { element1.Validate(); } } } if (DiagnosticsStorageAccountConfig != null) { DiagnosticsStorageAccountConfig.Validate(); } if (FabricSettings != null) { foreach (var element2 in FabricSettings) { if (element2 != null) { element2.Validate(); } } } if (NodeTypes != null) { foreach (var element3 in NodeTypes) { if (element3 != null) { element3.Validate(); } } } if (ReverseProxyCertificate != null) { ReverseProxyCertificate.Validate(); } if (UpgradeDescription != null) { UpgradeDescription.Validate(); } }
public static bool UpgradeDescription_IsUpgradeCurrentlyVisible_Postfix(bool __result, UpgradeDescription __instance) { if (!UpgradePagesManager.IsUpgradeVisible(__instance.UpgradeType, __instance.Level)) { return(false); } if (UpgradePagesManager.ForceUpgradeVisible(__instance.UpgradeType, __instance.Level)) { return(true); } return(__result); }
static float getAngleForIconAtCurrentPage(UpgradeUIIcon icon) { UpgradeDescription upgradeDescription = icon.GetDescription(); return(UpgradePagesManager.GetAngleOfUpgrade(upgradeDescription.UpgradeType, upgradeDescription.Level)); }
/// <summary> /// Gives the specified <see cref="UpgradeDescription"/> to a <see cref="FirstPersonMover"/> /// </summary> /// <param name="firstPersonMover"></param> /// <param name="Upgrade">The upgrade to give</param> public static void GiveUpgrade(this FirstPersonMover firstPersonMover, UpgradeDescription Upgrade) { firstPersonMover.GiveUpgrade(Upgrade.UpgradeType, Upgrade.Level); }
public static float UpgradeDescription_GetAngleOffset_Postfix(float __result, UpgradeDescription __instance) { return(UpgradePagesManager.GetAngleOfUpgrade(__instance.UpgradeType, __instance.Level)); }