private bool RemoveAction <T>([CanBeNull] Predicate <T> predicate = null) where T : ILevelUpAction { if (this.AutoCommit) { return(false); } for (int i = 0; i < this.LevelUpActions.Count; i++) { ILevelUpAction levelUpAction = this.LevelUpActions[i]; LevelUpActionPriority priority = levelUpAction.Priority; if (!(levelUpAction.GetType() != typeof(T))) { if (predicate == null || predicate((T)((object)levelUpAction))) { this.LevelUpActions.RemoveAt(i); this.m_RecalculatePreview = true; if (!this.m_ApplyingPlan && priority > LevelUpActionPriority.Visual && priority < LevelUpActionPriority.Alignment) { this.m_PlanChanged = true; } return(true); } } } return(false); }
private bool AddAction([NotNull] ILevelUpAction action, bool ignoreOrder = false) { LevelUpActionPriority levelUpActionPriority = (this.LevelUpActions.Count <= 0) ? LevelUpActionPriority.Visual : this.LevelUpActions[this.LevelUpActions.Count - 1].Priority; if (ignoreOrder || this.AutoCommit || action.Priority >= levelUpActionPriority) { if (!this.m_RecalculatePreview) { if (!action.Check(this.State, this.Preview)) { return(false); } this.LevelUpActions.Add(action); action.Apply(this.State, this.Preview); this.State.OnApplyAction(); if (this.Doll != null) { this.Doll.UpdateMechanicsEntities(this.Preview); } if (!this.m_ApplyingPlan) { this.m_PlanChanged = true; } return(true); } else { this.LevelUpActions.Add(action); } } else { for (int i = 0; i < this.LevelUpActions.Count; i++) { if (this.LevelUpActions[i].Priority > action.Priority) { this.LevelUpActions.Insert(i, action); this.m_RecalculatePreview = true; break; } } } this.UpdatePreview(); bool flag = this.LevelUpActions.Contains(action); if (flag && !this.m_ApplyingPlan) { this.m_PlanChanged = true; } return(flag); }
public static string MakeActionReadable(ILevelUpAction action) { var result = ""; result += action.GetType().Name; if (action is AddArchetype addArchtype) { result += $"({addArchtype.Archetype.Name})"; } if (action is AddStatPoint addStatPoint) { result += $"({addStatPoint.Attribute})"; } if (action is ApplyClassMechanics applyClassMechanics) { result += $"()"; } if (action is ApplySkillPoints applySkillPoints) { result += $"()"; } if (action is ApplySpellbook applySpellbook) { result += $"()"; } if (action is RemoveStatPoint removeStatPoint) { result += $"({removeStatPoint.Attribute})"; } if (action is SelectAlignment selectAlignment) { result += $"({selectAlignment.Alignment})"; } if (action is SelectClass selectClass) { var m_CharacterClass = Traverse.Create(selectClass).Field("m_CharacterClass").GetValue <BlueprintCharacterClass>(); result += $"({m_CharacterClass.Name})"; } if (action is SelectFeature selectFeature) { var selection = selectFeature.Selection; var item = selectFeature.Item; result += $"({selection}, {item})"; } if (action is SelectGender selectGender) { result += $"({selectGender.Gender})"; } if (action is SelectName selectName) { result += $"({selectName.Name})"; } if (action is SelectPortrait selectPortrait) { result += $"({selectPortrait.Portrait.name})"; } if (action is SelectRace selectRace) { result += $"({selectRace.Race.Name})"; } if (action is SelectRaceStat selectRaceStat) { result += $"({selectRaceStat.Attribute})"; } if (action is SelectSpell selectSpell) { result += $"({selectSpell.Spellbook.Name}, {selectSpell.SpellList.name}, {selectSpell.SpellLevel}, {selectSpell.Spell.Name}, {selectSpell.SlotIndex})"; } if (action is SelectVoice selectVoice) { result += $"({selectVoice.Voice.DisplayName})"; } if (action is SpendAttributePoint spendAttributePoint) { result += $"({spendAttributePoint.Attribute})"; } if (action is SpendSkillPoint spendSkillPoint) { result += $"({spendSkillPoint.Skill})"; } result += ", " + action.Priority; return(result); }