/// <summary>
        /// Builds the CardData represented by this builder's parameters recursively
        /// and registers it and its components with the appropriate managers.
        /// </summary>
        /// <returns>The newly registered CardData</returns>
        public CardData BuildAndRegister(int ChampionIndex = 0)
        {
            var cardData = this.Build();

            Trainworks.Log(LogLevel.Debug, "Adding custom card: " + cardData.GetName());
            CustomCardManager.RegisterCustomCard(cardData, this.CardPoolIDs);

            var Clan = cardData.GetLinkedClass();

            ChampionData ClanChamp = Clan.GetChampionData(ChampionIndex);

            ClanChamp.championCardData = cardData;
            if (this.ChampionIconPath != null)
            {
                Sprite championIconSprite = CustomAssetManager.LoadSpriteFromPath(this.BaseAssetPath + "/" + this.ChampionIconPath);
                ClanChamp.championIcon = championIconSprite;
            }
            ClanChamp.starterCardData = StarterCardData;
            if (this.UpgradeTree != null)
            {
                ClanChamp.upgradeTree = UpgradeTree.Build();
            }
            ClanChamp.championSelectedCue = ChampionSelectedCue;

            return(cardData);
        }
        /// <summary>
        /// Create a GameObject for the custom card with the given asset reference.
        /// Used for loading custom card art.
        /// </summary>
        /// <param name="assetRef">Reference containing the asset information</param>
        /// <returns>The GameObject for the custom card specified by the asset reference</returns>
        public static GameObject CreateCardGameObject(AssetReference assetRef)
        {
            Sprite sprite = CustomAssetManager.LoadSpriteFromRuntimeKey(assetRef.RuntimeKey);

            if (sprite != null)
            {
                return(CreateCardGameObject(assetRef, sprite));
            }
            return(null);
        }
        public WardStatePyreHarvest()
        {
            ID = "PyreHarvest";
            tooltipTitleKey = "HaruspexWardBeta_Name";
            tooltipBodyKey  = "HaruspexWardBeta_Desc";

            var localPath = Path.GetDirectoryName(new Uri(Assembly.GetCallingAssembly().CodeBase).LocalPath);

            wardIcon = CustomAssetManager.LoadSpriteFromPath(Path.Combine(localPath, "Unit Assets/HaruspexWard.png"));
        }
예제 #4
0
        public WardStateRandomDamage()
        {
            ID = "RandomDamage";
            tooltipTitleKey = "SpikeWard_Name";
            tooltipBodyKey  = "SpikeWard_Desc";

            var localPath = Path.GetDirectoryName(new Uri(Assembly.GetCallingAssembly().CodeBase).LocalPath);

            wardIcon = CustomAssetManager.LoadSpriteFromPath(Path.Combine(localPath, "Unit Assets/SpikeWard.png"));
        }
예제 #5
0
        public AssetReferenceGameObject BuildAndRegister()
        {
            var assetRef = this.Build();

            CustomAssetManager.RegisterCustomAsset(this.AssetGUID, this.AssetLoadingInfo);
            if (this.AssetLoadingInfo is BundleAssetLoadingInfo)
            {
                BundleManager.RegisterBundle(this.AssetGUID, this.AssetLoadingInfo as BundleAssetLoadingInfo);
            }
            return(assetRef);
        }
예제 #6
0
        /// <summary>
        /// Create a GameObject for the custom character with the given asset reference.
        /// Used for loading custom character art.
        /// </summary>
        /// <param name="assetRef">Reference containing the asset information</param>
        /// <returns>The GameObject for the custom character specified by the asset reference</returns>
        public static GameObject CreateCharacterGameObject(AssetReference assetRef)
        {
            Sprite sprite = CustomAssetManager.LoadSpriteFromRuntimeKey(assetRef.RuntimeKey);

            if (sprite != null)
            {
                var charObj = CreateCharacterGameObject(assetRef, sprite);
                GameObject.DontDestroyOnLoad(charObj);
                return(charObj);
            }
            return(null);
        }
예제 #7
0
        public WardStatePyrebound()
        {
            ID = "Pyrebound";
            tooltipTitleKey = "PyromancyWardBeta_Name";
            tooltipBodyKey  = "PyromancyWardBeta_Desc";

            var localPath = Path.GetDirectoryName(new Uri(Assembly.GetCallingAssembly().CodeBase).LocalPath);

            wardIcon    = CustomAssetManager.LoadSpriteFromPath(Path.Combine(localPath, "Unit Assets/SwordWard.png"));
            saveManager = ProviderManager.SaveManager;
            Setup();
        }
        /// <summary>
        /// Builds the EnhancerData represented by this builder's parameters.
        /// </summary>
        /// <returns>The newly created EnhancerData</returns>
        public EnhancerData Build()
        {
            EnhancerData enhancerData = new EnhancerData();
            var          t            = Traverse.Create(enhancerData);

            // Set the name for the unity object
            enhancerData.name = this.ID;

            // Upgrades are contained within a relic effect - this is mandatory or the game will crash
            List <RelicEffectData> Effects = new List <RelicEffectData>
            {
                new RelicEffectDataBuilder
                {
                    relicEffectClassName  = "RelicEffectCardUpgrade",
                    ParamCardUpgradeData  = Upgrade.Build(),
                    ParamCardType         = CardType,
                    ParamCharacterSubtype = "SubtypesData_None",
                }.Build()
            };

            t.Field("effects").SetValue(Effects);

            // Grab the LinkedClass from the ClanID
            this.LinkedClass = ProviderManager.SaveManager.GetAllGameData().FindClassData(this.ClanID);
            t.Field("linkedClass").SetValue(LinkedClass);

            // Take care of the localized strings
            BuilderUtils.ImportStandardLocalization(this.DescriptionKey, this.Description);
            t.Field("descriptionKey").SetValue(DescriptionKey);

            BuilderUtils.ImportStandardLocalization(this.NameKey, this.Name);
            t.Field("nameKey").SetValue(NameKey);

            // Create the icon from the asset path
            if (this.AssetPath != null)
            {
                Sprite iconSprite = CustomAssetManager.LoadSpriteFromPath(this.BaseAssetPath + "/" + this.AssetPath);
                t.Field("icon").SetValue(iconSprite);
            }

            // A steak pun is a rare medium well done.
            t.Field("rarity").SetValue(Rarity);

            return(enhancerData);
        }
예제 #9
0
        public WardStatePower()
        {
            ID = "Power";
            tooltipTitleKey = "PowerWardBeta_Name";
            tooltipBodyKey  = "PowerWardBeta_Desc";

            var localPath = Path.GetDirectoryName(new Uri(Assembly.GetCallingAssembly().CodeBase).LocalPath);

            wardIcon = CustomAssetManager.LoadSpriteFromPath(Path.Combine(localPath, "Unit Assets/PowerWard.png"));

            CardUpgradeData upgrade = new CardUpgradeDataBuilder
            {
                BonusDamage = power
            }.Build();

            upgradeState = new CardUpgradeState();
            upgradeState.Setup(upgrade);
        }
예제 #10
0
        public StatusEffectData Build()
        {
            StatusEffectData statusEffect = new StatusEffectData();

            AccessTools.Field(typeof(StatusEffectData), "addedVFX").SetValue(statusEffect, AddedVFX);
            AccessTools.Field(typeof(StatusEffectData), "affectedVFX").SetValue(statusEffect, AffectedVFX);
            AccessTools.Field(typeof(StatusEffectData), "appliedSFXName").SetValue(statusEffect, AppliedSFXName);
            AccessTools.Field(typeof(StatusEffectData), "displayCategory").SetValue(statusEffect, DisplayCategory);
            AccessTools.Field(typeof(StatusEffectData), "isStackable").SetValue(statusEffect, IsStackable);
            AccessTools.Field(typeof(StatusEffectData), "moreAddedVFX").SetValue(statusEffect, MoreAddedVFX);
            AccessTools.Field(typeof(StatusEffectData), "morePersistentVFX").SetValue(statusEffect, MorePersistentVFX);
            AccessTools.Field(typeof(StatusEffectData), "moreRemovedVFX").SetValue(statusEffect, MoreRemovedVFX);
            AccessTools.Field(typeof(StatusEffectData), "moreTriggeredVFX").SetValue(statusEffect, MoreTriggeredVFX);
            AccessTools.Field(typeof(StatusEffectData), "paramFloat").SetValue(statusEffect, ParamFloat);
            AccessTools.Field(typeof(StatusEffectData), "paramInt").SetValue(statusEffect, ParamInt);
            AccessTools.Field(typeof(StatusEffectData), "paramSecondaryInt").SetValue(statusEffect, ParamSecondaryInt);
            AccessTools.Field(typeof(StatusEffectData), "paramStr").SetValue(statusEffect, ParamStr);
            AccessTools.Field(typeof(StatusEffectData), "persistentVFX").SetValue(statusEffect, PersistentVFX);
            AccessTools.Field(typeof(StatusEffectData), "removeAtEndOfTurn").SetValue(statusEffect, RemoveAtEndOfTurn);
            AccessTools.Field(typeof(StatusEffectData), "removedVFX").SetValue(statusEffect, RemovedVFX);
            AccessTools.Field(typeof(StatusEffectData), "removeStackAtEndOfTurn").SetValue(statusEffect, RemoveStackAtEndOfTurn);
            AccessTools.Field(typeof(StatusEffectData), "removeWhenTriggered").SetValue(statusEffect, RemoveWhenTriggered);
            AccessTools.Field(typeof(StatusEffectData), "removeWhenTriggeredAfterCardPlayed").SetValue(statusEffect, RemoveWhenTriggeredAfterCardPlayed);
            AccessTools.Field(typeof(StatusEffectData), "showNotificationsOnRemoval").SetValue(statusEffect, ShowNotificationsOnRemoval);
            AccessTools.Field(typeof(StatusEffectData), "showStackCount").SetValue(statusEffect, ShowStackCount);
            AccessTools.Field(typeof(StatusEffectData), "statusEffectStateName").SetValue(statusEffect, StatusEffectStateName);
            AccessTools.Field(typeof(StatusEffectData), "statusId").SetValue(statusEffect, StatusId);
            AccessTools.Field(typeof(StatusEffectData), "triggeredSFXName").SetValue(statusEffect, TriggeredSFXName);
            AccessTools.Field(typeof(StatusEffectData), "triggeredVFX").SetValue(statusEffect, TriggeredVFX);
            AccessTools.Field(typeof(StatusEffectData), "triggerStage").SetValue(statusEffect, TriggerStage);

            if (this.IconPath != null)
            {
                Sprite draftIconSprite = CustomAssetManager.LoadSpriteFromPath(this.BaseAssetPath + "/" + this.IconPath);
                AccessTools.Field(typeof(StatusEffectData), "icon").SetValue(statusEffect, draftIconSprite);
            }

            StatusEffectManager manager = GameObject.FindObjectOfType <StatusEffectManager>() as StatusEffectManager;

            manager.GetAllStatusEffectsData().GetStatusEffectData().Add(statusEffect);

            return(statusEffect);
        }
예제 #11
0
        static bool Prefix(ref AssetLoadingManager __instance,
                           ref Dictionary <Hash128, AssetLoadingManager.AssetInfo> ____assetsLoaded,
                           ref int ____numLoadingTasksRunning,
                           ref AssetReference assetRef,
                           ref IAddressableAssetOwner assetOwner
                           )
        {
            if (CustomAssetManager.RuntimeKeyToAssetInfo.ContainsKey(assetRef.RuntimeKey))
            {
                if (____assetsLoaded.TryGetValue(assetRef.RuntimeKey, out AssetLoadingManager.AssetInfo info))
                {
                    info.assetCount++;
                }
                else
                {
                    info = new AssetLoadingManager.AssetInfo(assetRef);
                    ____assetsLoaded[assetRef.RuntimeKey] = info;
                }
                if (!info.Loading && !info.Loaded)
                {
                    info.status = AssetLoadingManager.AssetStatus.Loading;
                    ____numLoadingTasksRunning++;

                    // TODO: asynchronize this load
                    var asset = CustomAssetManager.LoadGameObjectFromAssetRef(assetRef);

                    ____numLoadingTasksRunning--;

                    if (setAssetInfoAssetMethod == null)
                    {
                        setAssetInfoAssetMethod = AccessTools.Method(typeof(AssetLoadingManager), "SetAssetInfoAsset");
                    }
                    setAssetInfoAssetMethod.Invoke(__instance, new object[] { info, asset });
                    info.status = AssetLoadingManager.AssetStatus.Loaded;
                }
                return(false);
            }
            return(true);
        }
        /// <summary>
        /// Builds the RelicData represented by this builder's parameters recursively;
        /// all Builders represented in this class's various fields will also be built.
        /// </summary>
        /// <returns>The newly created RelicData</returns>
        public CollectableRelicData Build()
        {
            foreach (var builder in this.EffectBuilders)
            {
                this.Effects.Add(builder.Build());
            }

            if (this.LinkedClass == null)
            {
                this.LinkedClass = CustomClassManager.GetClassDataByID(this.ClanID);
            }

            var relicData = ScriptableObject.CreateInstance <CollectableRelicData>();

            AccessTools.Field(typeof(GameData), "id").SetValue(relicData, this.CollectableRelicID);
            relicData.name = this.CollectableRelicID;
            // RelicData fields
            BuilderUtils.ImportStandardLocalization(this.DescriptionKey, this.Description);
            AccessTools.Field(typeof(RelicData), "descriptionKey").SetValue(relicData, this.DescriptionKey);
            AccessTools.Field(typeof(RelicData), "effects").SetValue(relicData, this.Effects);
            if (this.IconPath != null)
            {
                Sprite iconSprite = CustomAssetManager.LoadSpriteFromPath(this.FullAssetPath);
                AccessTools.Field(typeof(RelicData), "icon").SetValue(relicData, iconSprite);
            }
            BuilderUtils.ImportStandardLocalization(this.NameKey, this.Name);
            AccessTools.Field(typeof(RelicData), "nameKey").SetValue(relicData, this.NameKey);
            AccessTools.Field(typeof(RelicData), "relicActivatedKey").SetValue(relicData, this.RelicActivatedKey);
            AccessTools.Field(typeof(RelicData), "relicLoreTooltipKeys").SetValue(relicData, this.RelicLoreTooltipKeys);

            // CollectableRelicData fields
            AccessTools.Field(typeof(CollectableRelicData), "fromStoryEvent").SetValue(relicData, this.FromStoryEvent);
            AccessTools.Field(typeof(CollectableRelicData), "isBossGivenRelic").SetValue(relicData, this.IsBossGivenRelic);
            AccessTools.Field(typeof(CollectableRelicData), "linkedClass").SetValue(relicData, this.LinkedClass);
            AccessTools.Field(typeof(CollectableRelicData), "rarity").SetValue(relicData, this.Rarity);
            AccessTools.Field(typeof(CollectableRelicData), "unlockLevel").SetValue(relicData, this.UnlockLevel);
            return(relicData);
        }
예제 #13
0
        /// <summary>
        /// Builds the ClassData represented by this builder's parameters recursively;
        /// all Builders represented in this class's various fields will also be built.
        /// </summary>
        /// <returns>The newly created ClassData</returns>
        public ClassData Build()
        {
            ClassData classData = ScriptableObject.CreateInstance <ClassData>();

            classData.name = this.ClassID;

            AccessTools.Field(typeof(ClassData), "id").SetValue(classData, GUIDGenerator.GenerateDeterministicGUID(this.ClassID));
            AccessTools.Field(typeof(ClassData), "cardStyle").SetValue(classData, this.CardStyle);
            AccessTools.Field(typeof(ClassData), "classUnlockCondition").SetValue(classData, this.ClassUnlockCondition);
            AccessTools.Field(typeof(ClassData), "classUnlockParam").SetValue(classData, this.ClassUnlockParam);
            AccessTools.Field(typeof(ClassData), "classUnlockPreviewTexts").SetValue(classData, this.ClassUnlockPreviewTexts);
            BuilderUtils.ImportStandardLocalization(this.DescriptionLoc, this.Description);
            AccessTools.Field(typeof(ClassData), "descriptionLoc").SetValue(classData, this.DescriptionLoc);
            var icons = new List <Sprite>();

            foreach (string iconPath in this.IconAssetPaths)
            {
                icons.Add(CustomAssetManager.LoadSpriteFromPath(this.BaseAssetPath + "/" + iconPath));
            }
            Type iconSetType = AccessTools.Inner(typeof(ClassData), "IconSet");
            var  iconSet     = Activator.CreateInstance(iconSetType);

            AccessTools.Field(iconSetType, "small").SetValue(iconSet, icons[0]);
            AccessTools.Field(iconSetType, "medium").SetValue(iconSet, icons[1]);
            AccessTools.Field(iconSetType, "large").SetValue(iconSet, icons[2]);
            AccessTools.Field(iconSetType, "silhouette").SetValue(iconSet, icons[3]);
            AccessTools.Field(typeof(ClassData), "icons").SetValue(classData, iconSet);
            AccessTools.Field(typeof(ClassData), "champions").SetValue(classData, this.Champions);
            BuilderUtils.ImportStandardLocalization(this.SubclassDescriptionLoc, this.SubclassDescription);
            AccessTools.Field(typeof(ClassData), "subclassDescriptionLoc").SetValue(classData, this.SubclassDescriptionLoc);
            BuilderUtils.ImportStandardLocalization(this.TitleLoc, this.Name);
            AccessTools.Field(typeof(ClassData), "titleLoc").SetValue(classData, this.TitleLoc);
            AccessTools.Field(typeof(ClassData), "uiColor").SetValue(classData, this.UiColor);
            AccessTools.Field(typeof(ClassData), "uiColorDark").SetValue(classData, this.UiColorDark);
            //AccessTools.Field(typeof(ClassData), "UNLOCK_KEYS").SetValue(classData, this.);


            // Card Frame
            if (this.CardFrameSpellPath != null && this.CardFrameUnitPath != null)
            {
                Sprite cardFrameSpellSprite = CustomAssetManager.LoadSpriteFromPath(this.BaseAssetPath + "/" + this.CardFrameSpellPath);
                Sprite cardFrameUnitSprite  = CustomAssetManager.LoadSpriteFromPath(this.BaseAssetPath + "/" + this.CardFrameUnitPath);
                CustomClassManager.CustomClassFrame.Add(GUIDGenerator.GenerateDeterministicGUID(this.ClassID), new List <Sprite>()
                {
                    cardFrameUnitSprite, cardFrameSpellSprite
                });
            }

            // Draft Icon
            if (this.DraftIconPath != null)
            {
                Sprite draftIconSprite = CustomAssetManager.LoadSpriteFromPath(this.BaseAssetPath + "/" + this.DraftIconPath);
                CustomClassManager.CustomClassDraftIcons.Add(GUIDGenerator.GenerateDeterministicGUID(this.ClassID), draftIconSprite);
            }
            // Class select character IDs
            CustomClassManager.CustomClassSelectScreenCharacterIDsMain.Add(GUIDGenerator.GenerateDeterministicGUID(this.ClassID), this.ClassSelectScreenCharacterIDsMain);
            CustomClassManager.CustomClassSelectScreenCharacterIDsSub.Add(GUIDGenerator.GenerateDeterministicGUID(this.ClassID), this.ClassSelectScreenCharacterIDsSub);


            return(classData);
        }
예제 #14
0
        /// <summary>
        /// Builds the RewardNodeData represented by this builder's parameters recursively;
        /// all Builders represented in this class's various fields will also be built.
        /// </summary>
        /// <returns>The newly created RewardNodeData</returns>
        public RewardNodeData Build()
        {
            foreach (var builder in this.RewardBuilders)
            {
                this.Rewards.Add(builder.Build());
            }
            RewardNodeData rewardNodeData = ScriptableObject.CreateInstance <RewardNodeData>();

            AccessTools.Field(typeof(GameData), "id").SetValue(rewardNodeData, this.RewardNodeID);
            AccessTools.Field(typeof(MapNodeData), "ignoreIfNodesPresent").SetValue(rewardNodeData, this.IgnoreIfNodesPresent);
            AccessTools.Field(typeof(MapNodeData), "mapIcon").SetValue(rewardNodeData, CustomAssetManager.LoadSpriteFromPath(this.BaseAssetPath + "/" + this.MapIconPath));
            if (this.MapIconPrefab == null)
            { // These are too complicated to create from scratch, so by default we copy from an existing game banner and apply our sprites to it
                RewardNodeData copyBanner = (ProviderManager.SaveManager.GetAllGameData().FindMapNodeData("5f35b7b7-75d1-4957-9f78-7d2072237038") as RewardNodeData);
                this.MapIconPrefab = GameObject.Instantiate(copyBanner.GetMapIconPrefab());
                this.MapIconPrefab.transform.parent = null;
                this.MapIconPrefab.name             = this.RewardNodeID;
                GameObject.DontDestroyOnLoad(this.MapIconPrefab);
                var           images      = this.MapIconPrefab.GetComponentsInChildren <Image>(true);
                List <string> spritePaths = new List <string>
                { // This is the order they're listed on the prefab
                    this.ControllerSelectedOutline,
                    this.EnabledSpritePath,
                    this.EnabledVisitedSpritePath,
                    this.DisabledVisitedSpritePath,
                    this.DisabledSpritePath,
                    this.FrozenSpritePath
                };
                for (int i = 0; i < images.Length; i++)
                { // This method of modifying the image's sprite has the unfortunate side-effect of removing the white mouse-over outline
                    var sprite = CustomAssetManager.LoadSpriteFromPath(this.BaseAssetPath + "/" + spritePaths[i]);
                    if (sprite != null)
                    {
                        images[i].sprite   = sprite;
                        images[i].material = null;
                    }
                }
            }
            AccessTools.Field(typeof(MapNodeData), "mapIconPrefab").SetValue(rewardNodeData, this.MapIconPrefab);
            AccessTools.Field(typeof(MapNodeData), "minimapIcon").SetValue(rewardNodeData, CustomAssetManager.LoadSpriteFromPath(this.BaseAssetPath + "/" + this.MinimapIconPath));
            AccessTools.Field(typeof(MapNodeData), "nodeSelectedSfxCue").SetValue(rewardNodeData, this.NodeSelectedSfxCue);

            AccessTools.Field(typeof(MapNodeData), "skipCheckSettings").SetValue(rewardNodeData, SkipCheckSettings);

            if (this.Description != null)
            {
                this.TooltipBodyKey = "RewardNodeData_" + this.RewardNodeID + "_TooltipBodyKey";
                // Use Description field for all languages
                // This should be changed in the future to add proper localization support to custom content
                CustomLocalizationManager.ImportSingleLocalization(this.TooltipBodyKey, "Text", "", "", "", "", this.Description, this.Description, this.Description, this.Description, this.Description, this.Description);
            }
            AccessTools.Field(typeof(MapNodeData), "tooltipBodyKey").SetValue(rewardNodeData, this.TooltipBodyKey);
            if (this.Name != null)
            {
                this.TooltipTitleKey = "RewardNodeData_" + this.RewardNodeID + "_TooltipTitleKey";
                // Use Name field for all languages
                // This should be changed in the future to add proper localization support to custom content
                CustomLocalizationManager.ImportSingleLocalization(this.TooltipTitleKey, "Text", "", "", "", "", this.Name, this.Name, this.Name, this.Name, this.Name, this.Name);
            }
            AccessTools.Field(typeof(MapNodeData), "tooltipTitleKey").SetValue(rewardNodeData, this.TooltipTitleKey);
            AccessTools.Field(typeof(RewardNodeData), "grantImmediately").SetValue(rewardNodeData, this.GrantImmediately);
            AccessTools.Field(typeof(RewardNodeData), "OverrideTooltipTitleBody").SetValue(rewardNodeData, this.OverrideTooltipTitleBody);
            AccessTools.Field(typeof(RewardNodeData), "requiredClass").SetValue(rewardNodeData, this.RequiredClass);
            AccessTools.Field(typeof(RewardNodeData), "rewards").SetValue(rewardNodeData, this.Rewards);
            return(rewardNodeData);
        }
예제 #15
0
        public CardUpgradeData Build()
        {
            CardUpgradeData cardUpgradeData = ScriptableObject.CreateInstance <CardUpgradeData>();

            foreach (var builder in this.TraitDataUpgradeBuilders)
            {
                this.TraitDataUpgrades.Add(builder.Build());
            }
            foreach (var builder in this.TriggerUpgradeBuilders)
            {
                this.TriggerUpgrades.Add(builder.Build());
            }
            foreach (var builder in this.CardTriggerUpgradeBuilders)
            {
                this.CardTriggerUpgrades.Add(builder.Build());
            }
            foreach (var builder in this.RoomModifierUpgradeBuilders)
            {
                this.RoomModifierUpgrades.Add(builder.Build());
            }
            foreach (var builder in this.FiltersBuilders)
            {
                this.Filters.Add(builder.Build());
            }
            foreach (var builder in this.UpgradesToRemoveBuilders)
            {
                this.UpgradesToRemove.Add(builder.Build());
            }

            AccessTools.Field(typeof(CardUpgradeData), "bonusDamage").SetValue(cardUpgradeData, this.BonusDamage);
            AccessTools.Field(typeof(CardUpgradeData), "bonusHeal").SetValue(cardUpgradeData, this.BonusHeal);
            AccessTools.Field(typeof(CardUpgradeData), "bonusHP").SetValue(cardUpgradeData, this.BonusHP);
            AccessTools.Field(typeof(CardUpgradeData), "bonusSize").SetValue(cardUpgradeData, this.BonusSize);
            AccessTools.Field(typeof(CardUpgradeData), "cardTriggerUpgrades").SetValue(cardUpgradeData, this.CardTriggerUpgrades);
            AccessTools.Field(typeof(CardUpgradeData), "costReduction").SetValue(cardUpgradeData, this.CostReduction);
            AccessTools.Field(typeof(CardUpgradeData), "filters").SetValue(cardUpgradeData, this.Filters);
            AccessTools.Field(typeof(CardUpgradeData), "hideUpgradeIconOnCard").SetValue(cardUpgradeData, this.HideUpgradeIconOnCard);
            AccessTools.Field(typeof(CardUpgradeData), "removeTraitUpgrades").SetValue(cardUpgradeData, this.RemoveTraitUpgrades);
            AccessTools.Field(typeof(CardUpgradeData), "roomModifierUpgrades").SetValue(cardUpgradeData, this.RoomModifierUpgrades);
            AccessTools.Field(typeof(CardUpgradeData), "statusEffectUpgrades").SetValue(cardUpgradeData, this.StatusEffectUpgrades);
            AccessTools.Field(typeof(CardUpgradeData), "traitDataUpgrades").SetValue(cardUpgradeData, this.TraitDataUpgrades);
            AccessTools.Field(typeof(CardUpgradeData), "triggerUpgrades").SetValue(cardUpgradeData, this.TriggerUpgrades);
            BuilderUtils.ImportStandardLocalization(this.UpgradeDescriptionKey, this.UpgradeDescription);
            AccessTools.Field(typeof(CardUpgradeData), "upgradeDescriptionKey").SetValue(cardUpgradeData, this.UpgradeDescriptionKey);
            if (this.UpgradeIconPath != null && this.UpgradeIconPath != "")
            {
                AccessTools.Field(typeof(CardUpgradeData), "upgradeIcon").SetValue(cardUpgradeData, CustomAssetManager.LoadSpriteFromPath(this.BaseAssetPath + "/" + this.UpgradeIconPath));
            }
            BuilderUtils.ImportStandardLocalization(this.UpgradeNotificationKey, this.UpgradeNotification);
            AccessTools.Field(typeof(CardUpgradeData), "upgradeNotificationKey").SetValue(cardUpgradeData, this.UpgradeNotificationKey);
            AccessTools.Field(typeof(CardUpgradeData), "upgradesToRemove").SetValue(cardUpgradeData, this.UpgradesToRemove);
            BuilderUtils.ImportStandardLocalization(this.UpgradeTitleKey, this.UpgradeTitle);
            AccessTools.Field(typeof(CardUpgradeData), "upgradeTitleKey").SetValue(cardUpgradeData, this.UpgradeTitleKey);
            AccessTools.Field(typeof(CardUpgradeData), "useUpgradeHighlightTextTags").SetValue(cardUpgradeData, this.UseUpgradeHighlightTextTags);
            AccessTools.Field(typeof(CardUpgradeData), "xCostReduction").SetValue(cardUpgradeData, this.XCostReduction);

            cardUpgradeData.name = UpgradeTitleKey;
            Traverse.Create(cardUpgradeData).Field("id").SetValue(UpgradeTitleKey);

            // If CardUpgrades are not added to allGameData, there are many troubles.
            var field       = Traverse.Create(ProviderManager.SaveManager.GetAllGameData()).Field("cardUpgradeDatas");
            var upgradeList = field.GetValue <List <CardUpgradeData> >();

            upgradeList.Add(cardUpgradeData);
            field.SetValue(upgradeList);

            return(cardUpgradeData);
        }
예제 #16
0
        /// <summary>
        /// Builds the RewardData represented by this builder's parameters recursively;
        /// all Builders represented in this class's various fields will also be built.
        /// </summary>
        /// <returns>The newly created RewardData</returns>
        public RewardData Build()
        {
            RewardData rewardData = ScriptableObject.CreateInstance <DraftRewardData>();

            AccessTools.Field(typeof(GameData), "id").SetValue(rewardData, this.DraftRewardID);
            AccessTools.Field(typeof(DraftRewardData), "classDataOverride").SetValue(rewardData, this.ClassDataOverride);
            AccessTools.Field(typeof(DraftRewardData), "classType").SetValue(rewardData, this.ClassType);
            AccessTools.Field(typeof(DraftRewardData), "classTypeOverride").SetValue(rewardData, this.ClassTypeOverride);
            AccessTools.Field(typeof(DraftRewardData), "draftOptionsCount").SetValue(rewardData, this.DraftOptionsCount);
            AccessTools.Field(typeof(DraftRewardData), "draftPool").SetValue(rewardData, this.DraftPool);
            AccessTools.Field(typeof(DraftRewardData), "grantSingleCard").SetValue(rewardData, this.GrantSingleCard);
            AccessTools.Field(typeof(DraftRewardData), "rarityFloorOverride").SetValue(rewardData, this.RarityFloorOverride);
            AccessTools.Field(typeof(DraftRewardData), "useRunRarityFloors").SetValue(rewardData, this.UseRunRarityFloors);
            AccessTools.Field(typeof(GrantableRewardData), "CanBeSkippedOverride").SetValue(rewardData, this.CanBeSkippedOverride);
            AccessTools.Field(typeof(GrantableRewardData), "ForceContentUnlocked").SetValue(rewardData, this.ForceContentUnlocked);
            AccessTools.Field(typeof(GrantableRewardData), "saveManager").SetValue(rewardData, this.SaveManager);
            AccessTools.Field(typeof(GrantableRewardData), "_isServiceMerchantReward").SetValue(rewardData, this._IsServiceMerchantReward);
            AccessTools.Field(typeof(GrantableRewardData), "_merchantServiceIndex").SetValue(rewardData, this._MerchantServiceIndex);
            AccessTools.Field(typeof(RewardData), "costs").SetValue(rewardData, this.Costs);
            AccessTools.Field(typeof(RewardData), "ShowRewardAnimationInEvent").SetValue(rewardData, this.ShowRewardAnimationInEvent);
            AccessTools.Field(typeof(RewardData), "_collectSFXCueName").SetValue(rewardData, this._CollectSFXCueName);
            if (this.Description != null)
            {
                this._RewardDescriptionKey = "DraftRewardData_" + this.DraftRewardID + "_RewardDescriptionKey";
                // Use Description field for all languages
                // This should be changed in the future to add proper localization support to custom content
                CustomLocalizationManager.ImportSingleLocalization(this._RewardDescriptionKey, "Text", "", "", "", "", this.Description, this.Description, this.Description, this.Description, this.Description, this.Description);
            }
            AccessTools.Field(typeof(RewardData), "_rewardDescriptionKey").SetValue(rewardData, this._RewardDescriptionKey);
            AccessTools.Field(typeof(RewardData), "_rewardSprite").SetValue(rewardData, CustomAssetManager.LoadSpriteFromPath(this.BaseAssetPath + "/" + this._RewardSpritePath));
            if (this.Name != null)
            {
                this._RewardTitleKey = "DraftRewardData_" + this.DraftRewardID + "_RewardTitleKey";
                // Use Name field for all languages
                // This should be changed in the future to add proper localization support to custom content
                CustomLocalizationManager.ImportSingleLocalization(this._RewardTitleKey, "Text", "", "", "", "", this.Name, this.Name, this.Name, this.Name, this.Name, this.Name);
            }
            AccessTools.Field(typeof(RewardData), "_rewardTitleKey").SetValue(rewardData, this._RewardTitleKey);
            AccessTools.Field(typeof(RewardData), "_showCancelOverride").SetValue(rewardData, this._ShowCancelOverride);
            AccessTools.Field(typeof(RewardData), "_showRewardFlowInEvent").SetValue(rewardData, this._ShowRewardFlowInEvent);
            return(rewardData);
        }
예제 #17
0
 static void Postfix(SaveManager __instance)
 {
     CustomCharacterManager.LoadTemplateCharacter(__instance);
     CustomAssetManager.InitializeAssetConstructors();
 }