コード例 #1
0
ファイル: NewBuffLogics.cs プロジェクト: jp-bennett/Arcanist
        public override void OnTurnOn()
        {
            base.OnTurnOn();

            var unit = base.Owner;

            foreach (var subBuff in GreaterMetamagicKnowledge.subBuffs)
            {
                if (subBuff == this.Buff.Blueprint)
                {
                    continue;
                }
                if (unit.Buffs.HasFact(subBuff))
                {
                    unit.Buffs.RemoveFact(subBuff);
                }
            }
            if (spellMixer == null)
            {
                spellMixer = spellMixerGetter(Game.Instance.UI.SpellBookController) as SpellBookMetamagicMixer;
                if (spellMixer == null)
                {
                    base.Buff.Remove();
                    throw new Exception("BuffChangeSingleSelectedFeature.OnTurnOn(): Get Null SpellBookMetamagicMixer!");
                }
            }

            unit.Resources.Spend(ArcaneReservoir.resource, 1);
            //UnityModManager.Logger.Log($"Unit = {unit.CharacterName}");
            FeatureSelectionData selectionData = unit.Progression.GetSelectionData(selectionBlue);

            if (selectionData.SelectionsByLevel.Count != 1)
            {
                return;
            }
            level = selectionData.SelectionsByLevel.ElementAt(0).Key;

            this.replacedOriginalFeats = new List <BlueprintFeature>(selectionData.GetSelections(level));
            //UnityModManager.Logger.Log($"Replaced Original Feats has {this.replacedOriginalFeats.Count} feats.");

            foreach (var feat in this.replacedOriginalFeats)
            {
                //UnityModManager.Logger.Log($"Remove Feat {feat.Name}");
                unit.Progression.Features.RemoveFact(feat);
                RemoveMetamagicFeatInSpellSlots(feat);
                selectionData.RemoveSelection(level, feat);
                //UnityModManager.Logger.Log($"Remove Feat {feat.Name} Finish.");
            }
            //UnityModManager.Logger.Log($"Start to add Feat.");
            selectionData.AddSelection(level, newFeatBlue);
            unit.AddFact(newFeatBlue);
            builder_setter(spellMixer, null);
            //UnityModManager.Logger.Log($"Added feat {newFeatBlue.Name}");
        }
コード例 #2
0
ファイル: NewBuffLogics.cs プロジェクト: jp-bennett/Arcanist
        public override void OnTurnOff()
        {
            if (this.replacedOriginalFeats != null && spellMixer != null && level != -1)
            {
                var unit = base.Owner;
                FeatureSelectionData selectionData = unit.Progression.GetSelectionData(selectionBlue);
                unit.Progression.Features.RemoveFact(newFeatBlue);
                RemoveMetamagicFeatInSpellSlots(newFeatBlue);
                selectionData.RemoveSelection(level, newFeatBlue);
                foreach (var feat in this.replacedOriginalFeats)
                {
                    unit.AddFact(feat);
                    selectionData.AddSelection(level, feat);
                }
                builder_setter(spellMixer, null);
            }

            base.OnTurnOff();
        }