private void UpdateVitals(CharacterStats stats, VitalsInfo ratios, ModConfig config) { float _hp, _hpb, _sp, _spb, _mp, _mpb; stats.RefreshVitalMaxStat(); if (!(bool)config.GetValue(Settings.GameBehaviour) && stats.GetComponent <Character>().IsLocalPlayer) { _hp = SaveManager.Instance.GetCharacterSave(stats.GetComponent <Character>().UID).PSave.Health; _hpb = SaveManager.Instance.GetCharacterSave(stats.GetComponent <Character>().UID).PSave.BurntHealth; _sp = SaveManager.Instance.GetCharacterSave(stats.GetComponent <Character>().UID).PSave.Stamina; _spb = SaveManager.Instance.GetCharacterSave(stats.GetComponent <Character>().UID).PSave.BurntStamina; _mp = SaveManager.Instance.GetCharacterSave(stats.GetComponent <Character>().UID).PSave.Mana; _mpb = SaveManager.Instance.GetCharacterSave(stats.GetComponent <Character>().UID).PSave.BurntMana; } else { _hp = stats.MaxHealth * ratios.HealthRatio; _hpb = stats.MaxHealth * ratios.BurntHealthRatio; _sp = stats.MaxStamina * ratios.StaminaRatio; _spb = stats.MaxStamina * ratios.BurntStaminaRatio; _mp = stats.MaxMana * ratios.ManaRatio; _mpb = stats.MaxMana * ratios.BurntManaRatio; } stats.SetHealth(_hp); AT.SetValue(_hpb, typeof(CharacterStats), stats, "m_burntHealth"); AT.SetValue(_sp, typeof(CharacterStats), stats, "m_stamina"); AT.SetValue(_spb, typeof(CharacterStats), stats, "m_burntStamina"); stats.SetMana(_mp); AT.SetValue(_mpb, typeof(CharacterStats), stats, "m_burntMana"); }
private void SaveVitalsInfo(string targetUid = null) { if (!Directory.Exists(_dir)) { Directory.CreateDirectory(_dir); } foreach (SplitPlayer _player in SplitScreenManager.Instance.LocalPlayers) { if (targetUid != null) { if (_player.AssignedCharacter.UID != targetUid) { continue; } } string _path = $"{_file}_{ _player.AssignedCharacter.UID }{ _ext }"; VitalsInfo _vitals = new VitalsInfo { HealthRatio = _player.AssignedCharacter.HealthRatio, BurntHealthRatio = _player.AssignedCharacter.Stats.BurntHealthRatio, StaminaRatio = _player.AssignedCharacter.StaminaRatio, BurntStaminaRatio = _player.AssignedCharacter.Stats.BurntStaminaRatio, ManaRatio = _player.AssignedCharacter.ManaRatio, BurntManaRatio = _player.AssignedCharacter.Stats.BurntManaRatio }; if (File.Exists(_path)) { File.Delete(_path); } if (_lastVitals.ContainsKey(_player.AssignedCharacter.UID)) { _lastVitals.Remove(_player.AssignedCharacter.UID); } _lastVitals.Add(_player.AssignedCharacter.UID, _vitals); File.WriteAllText(_path, JsonUtility.ToJson(_vitals)); } }
private void ApplyCustomStats(Character character, ModConfig config, string stackSource, bool flag) { character.Stats.RefreshVitalMaxStat(); character.Stats.RestoreAllVitals(); VitalsInfo _ratios = LoadVitalsInfo(character.UID) ?? new VitalsInfo { HealthRatio = character.HealthRatio, BurntHealthRatio = character.Stats.BurntHealthRatio, StaminaRatio = character.StaminaRatio, BurntStaminaRatio = character.Stats.BurntStaminaRatio, ManaRatio = character.ManaRatio, BurntManaRatio = character.Stats.BurntManaRatio }; foreach (BBSetting _bbs in config.Settings) { if (_bbs is FloatSetting _f) { Tag _tag = TagSourceManager.Instance.GetTag(AT.GetTagUid(_f.Name)); bool _mult = (bool)config.GetValue(_f.Name + Settings.ModMult); if (flag) { SetCustomStat(character.Stats, stackSource, _tag, _mult ? _f.m_value / 100f : _f.m_value, _mult, config); } else { ClearCustomStat(character.Stats, _tag, stackSource, _mult); } } } UpdateVitals(character.Stats, _ratios, config); if (!character.IsAI) { SaveVitalsInfo(character.UID); } }