private void UpdateVitalText(Character player)
        {
            CharacterBarListener manager = player.CharacterUI.transform.Find("Canvas/GameplayPanels/HUD/MainCharacterBars").GetComponent <CharacterBarListener>();

            if (!manager)
            {
                return;
            }

            var healthBar = At.GetField(manager, "m_healthBar") as Bar;
            var manaBar   = At.GetField(manager, "m_manaBar") as Bar;
            var stamBar   = At.GetField(manager, "m_staminaBar") as Bar;

            if (!healthBar || !manaBar || !stamBar)
            {
                return;
            }

            var healthText = At.GetField(healthBar, "m_lblValue") as Text;
            var manaText   = At.GetField(manaBar, "m_lblValue") as Text;
            var stamText   = At.GetField(stamBar, "m_lblValue") as Text;

            healthText.fontSize = 14;
            manaText.fontSize   = 14;
            stamText.fontSize   = 14;

            healthBar.TextValueDisplayed = (bool)CombatHUD.config.GetValue(Settings.PlayerVitals);
            manaBar.TextValueDisplayed   = (bool)CombatHUD.config.GetValue(Settings.PlayerVitals);
            stamBar.TextValueDisplayed   = (bool)CombatHUD.config.GetValue(Settings.PlayerVitals);
        }
Пример #2
0
        public static bool Prefix(Weapon __instance, Character _hitCharacter, Vector3 _hitPos, Vector3 _dir, bool _blocked)
        {
            var selfChar   = At.GetField(__instance, "m_ownerCharacter") as Character;
            var alreadyhit = At.GetField(__instance, "m_alreadyHitChars") as List <Character>;

            bool eligible = _hitCharacter && (_hitCharacter != selfChar) && (__instance.CanHitEveryoneButOwner || selfChar.TargetingSystem.IsTargetable(_hitCharacter));

            if (eligible && !alreadyhit.Contains(_hitCharacter))
            {
                if (!_blocked)
                {
                    DamageList damages = __instance.GetDamage(0);
                    //_hitCharacter.Stats.GetMitigatedDamage(null, ref damages, false);
                    At.Invoke(_hitCharacter, "ProcessDamageReduction", new object[] { __instance, damages, false });

                    DamageLabels.AddDamageLabel(damages, _hitPos, _hitCharacter);
                }
                else
                {
                    // Attack was blocked.
                }
            }

            return(true);
        }
Пример #3
0
        public static void Postfix(PunctualDamage __instance, Character _targetCharacter)
        {
            if (_targetCharacter.Alive)
            {
                var damageList = At.GetField(__instance, "m_tempList") as DamageList;

                DamageList damages = damageList.Clone();
                _targetCharacter.Stats.GetMitigatedDamage(null, ref damages, false);

                DamageLabels.AddDamageLabel(damages, _targetCharacter.CenterPosition, _targetCharacter);
            }
        }
Пример #4
0
        public static void Postfix(PunctualDamage __instance, Character _targetCharacter)
        {
            if (_targetCharacter.Alive)
            {
                DamageList damages = (At.GetField(__instance, "m_tempList") as DamageList).Clone();

                Weapon weapon = At.GetField(__instance, "m_weapon") as Weapon;

                At.Invoke(_targetCharacter, "ProcessDamageReduction", new object[] { weapon, damages, false });

                // _targetCharacter.Stats.GetMitigatedDamage(null, ref damages, false);

                DamageLabels.AddDamageLabel(damages, _targetCharacter.CenterPosition, _targetCharacter);
            }
        }
Пример #5
0
        public static bool Prefix(Weapon __instance, RaycastHit _hit, Vector3 _dir)
        {
            Hitbox hitbox = _hit.collider?.GetComponent <Hitbox>();

            if (!hitbox)
            {
                return(true);
            }

            var owner  = __instance.OwnerCharacter;
            var target = hitbox.OwnerChar;

            if (!target || !owner)
            {
                return(true);
            }

            var m_alreadyHitChars = (List <Character>)At.GetField(__instance, "m_alreadyHitChars");

            if (!m_alreadyHitChars.Contains(target) && HookUtil.IsElligable(__instance, owner, target))
            {
                bool  blocked = false;
                float num     = Vector3.Angle(hitbox.OwnerChar.transform.forward, owner.transform.position - hitbox.OwnerChar.transform.position);

                if (!__instance.Unblockable && hitbox.OwnerChar.Blocking && num < (float)(hitbox.OwnerChar.ShieldEquipped ? Weapon.SHIELD_BLOCK_ANGLE : Weapon.BLOCK_ANGLE))
                {
                    blocked = true;
                }
                if (!blocked)
                {
                    var attackID = (int)At.GetField(__instance, "m_attackID");
                    if (attackID >= 0)
                    {
                        DamageList damages = __instance.GetDamage(attackID).Clone();

                        //target.Stats.GetMitigatedDamage(null, ref damages, false);
                        At.Invoke(target, "ProcessDamageReduction", new object[] { __instance, damages, false });

                        DamageLabels.AddDamageLabel(damages, _hit.point, target);
                    }
                }
            }

            return(true);
        }
Пример #6
0
        public static void Postfix(PunctualDamage __instance, Character _targetCharacter)
        {
            if (_targetCharacter.Alive)
            {
                var damageList = At.GetField(__instance, "m_tempList") as DamageList;

                bool ignoreBarrier = false;
                if (__instance.ParentSynchronizer is StatusEffect status)
                {
                    ignoreBarrier = status.IgnoreBarrier;
                }

                DamageList damages = damageList.Clone();
                _targetCharacter.Stats.GetMitigatedDamage(null, ref damages, ignoreBarrier);

                DamageLabels.AddDamageLabel(damages, _targetCharacter.CenterPosition, _targetCharacter);
            }
        }
Пример #7
0
        public static void Postfix(PunctualDamage __instance, Character _targetCharacter)
        {
            if (_targetCharacter.Alive)
            {
                bool ignoreBarrier = false;
                if (__instance.ParentSynchronizer is StatusEffect status)
                {
                    ignoreBarrier = status.IgnoreBarrier;
                }

                DamageList damages = (At.GetField(__instance, "m_tempList") as DamageList).Clone();

                At.Invoke(_targetCharacter, "ProcessDamageReduction", new object[] { __instance.ParentSynchronizer, damages, ignoreBarrier });

                // _targetCharacter.Stats.GetMitigatedDamage(null, ref damages, ignoreBarrier);

                DamageLabels.AddDamageLabel(damages, _targetCharacter.CenterPosition, _targetCharacter);
            }
        }
Пример #8
0
        internal void Update()
        {
            m_hideUI        = (bool)At.GetField(Global.Instance, "m_hideUI");
            m_playerShowHud = (bool[])At.GetField <OptionManager>("m_playerShowHUD");

            if (!HUDCanvas || Global.Lobby.PlayersInLobbyCount < 1)
            {
                return;
            }

            // main canvas disable
            if (!NetworkLevelLoader.Instance.IsOverallLoadingDone || !NetworkLevelLoader.Instance.AllPlayerReadyToContinue)
            {
                if (HUDCanvas.activeSelf)
                {
                    //HUDCanvas.SetActive(false);
                }
            }
            else if (!HUDCanvas.activeSelf)
            {
                HUDCanvas.SetActive(true);
            }
        }
Пример #9
0
        private void UpdateOnTargetChange()
        {
            var target = m_LinkedCharacter.TargetingSystem.LockedCharacter;

            m_infoboxName.text = target.Name;

            // only update status immunities when we change targets.
            List <string> immunityTags = new List <string>();

            var statusNaturalImmunities = (TagSourceSelector[])At.GetField(target.Stats, "m_statusEffectsNaturalImmunity");

            foreach (var tagSelector in statusNaturalImmunities)
            {
                immunityTags.Add(tagSelector.Tag.TagName);
            }

            var statusImmunities = (Dictionary <Tag, List <string> >)At.GetField(target.Stats, "m_statusEffectsImmunity");

            foreach (var entry in statusImmunities)
            {
                if (entry.Value.Count > 0)
                {
                    immunityTags.Add(entry.Key.TagName);
                }
            }

            if (immunityTags.Count > 0)
            {
                m_infoboxNoImmuneText.gameObject.SetActive(false);
                float offset = 0f;
                var   pos    = m_infoboxNoImmuneText.rectTransform.position;

                if (immunityTags.Contains("Bleeding"))
                {
                    m_infoboxBleedingSprite.gameObject.SetActive(true);
                    m_infoboxBleedingSprite.rectTransform.position = new Vector3(pos.x, pos.y - 2f, 0);
                    offset += CombatHUD.Rel(22f);
                }
                else
                {
                    m_infoboxBleedingSprite.gameObject.SetActive(false);
                }
                if (immunityTags.Contains("Burning"))
                {
                    m_infoboxBurningSprite.gameObject.SetActive(true);
                    m_infoboxBurningSprite.rectTransform.position = new Vector3(pos.x + offset, pos.y - 2f, 0);
                    offset += CombatHUD.Rel(22f);
                }
                else
                {
                    m_infoboxBurningSprite.gameObject.SetActive(false);
                }
                if (immunityTags.Contains("Poison"))
                {
                    m_infoboxPoisonSprite.gameObject.SetActive(true);
                    m_infoboxPoisonSprite.rectTransform.position = new Vector3(pos.x + offset, pos.y - 2f, 0);
                }
                else
                {
                    m_infoboxPoisonSprite.gameObject.SetActive(false);
                }
            }
            else
            {
                m_infoboxNoImmuneText.gameObject.SetActive(true);

                m_infoboxBurningSprite.gameObject.SetActive(false);
                m_infoboxBleedingSprite.gameObject.SetActive(false);
                m_infoboxPoisonSprite.gameObject.SetActive(false);
            }
        }
Пример #10
0
        private void UpdateStatuses(Character target)
        {
            // update status icons
            float offset         = 0f;
            float offsetInterval = CombatHUD.Rel(30f, true);

            var barPos = RectTransformUtility.WorldToScreenPoint(m_LinkedCharacter.CharacterCamera.CameraScript, target.UIBarPosition);
            var pos    = barPos + new Vector2(CombatHUD.Rel(225f), 0);

            var statuses = target.StatusEffectMngr.Statuses;

            // Key: Status Identifier, float: Buildup / opacity
            var displayDict = new Dictionary <string, float>();

            foreach (var status in statuses)
            {
                if (!displayDict.ContainsKey(status.IdentifierName))
                {
                    displayDict.Add(status.IdentifierName, 100f);
                }
            }

            if ((bool)CombatHUD.config.GetValue(Settings.EnemyBuildup))
            {
                var buildupDict = (IDictionary)At.GetField(target.StatusEffectMngr, "m_statusBuildUp");
                foreach (string name in buildupDict.Keys)
                {
                    if (displayDict.ContainsKey(name) || buildupDict[name] == null)
                    {
                        continue;
                    }

                    if (s_buildupField == null)
                    {
                        s_buildupField = buildupDict[name].GetType().GetField("BuildUp");
                    }

                    float value = (float)s_buildupField.GetValue(buildupDict[name]);

                    if (value > 0 && value < 100)
                    {
                        displayDict.Add(name, value);
                    }
                }
            }

            for (int i = 0; i < m_statusHolder.transform.childCount; i++)
            {
                var holder = m_statusHolder.transform.GetChild(i);

                if (i >= displayDict.Count)
                {
                    if (holder.gameObject.activeSelf)
                    {
                        holder.gameObject.SetActive(false);
                    }
                }
                else
                {
                    var entry = displayDict.ElementAt(i);

                    if (!s_statusIcons.ContainsKey(entry.Key))
                    {
                        var status = ResourcesPrefabManager.Instance.GetStatusEffectPrefab(entry.Key);
                        if (!status)
                        {
                            s_statusIcons.Add(entry.Key, null);
                            continue;
                        }

                        var icon = status.OverrideIcon ?? status.StatusIcon;
                        s_statusIcons.Add(entry.Key, icon);
                    }

                    var sprite = s_statusIcons[entry.Key];
                    if (!sprite)
                    {
                        continue;
                    }

                    if (s_cachedImages == null)
                    {
                        s_cachedImages = new Image[m_statusHolder.transform.childCount];
                        for (int j = 0; j < m_statusHolder.transform.childCount; j++)
                        {
                            s_cachedImages[j] = m_statusHolder.transform.GetChild(j).Find("Image").GetComponent <Image>();
                        }
                    }

                    if (s_cachedImages[i].sprite != sprite)
                    {
                        s_cachedImages[i].sprite = sprite;
                    }

                    holder.position = new Vector3(pos.x, pos.y + offset);

                    var text = holder.Find("Text").GetComponent <Text>();

                    if (!holder.gameObject.activeSelf)
                    {
                        holder.gameObject.SetActive(true);
                    }

                    if (displayDict[entry.Key] >= 100f)
                    {
                        if ((bool)CombatHUD.config.GetValue(Settings.EnemyStatusTimers))
                        {
                            var status = statuses.Find(it => it.IdentifierName == entry.Key);

                            TimeSpan t = TimeSpan.FromSeconds(status.RemainingLifespan);
                            var      s = $"{t.Minutes}:{t.Seconds:00}";
                            text.text  = s;
                            text.color = Color.white;

                            if (!text.gameObject.activeSelf)
                            {
                                text.gameObject.SetActive(true);
                            }

                            offset -= offsetInterval;
                        }
                        else if (text.gameObject.activeSelf)
                        {
                            text.gameObject.SetActive(false);
                        }
                    }
                    else
                    {
                        var parentRect = holder.GetComponent <RectTransform>();
                        parentRect.position = new Vector3(pos.x, pos.y + offset);
                        offset -= offsetInterval;

                        var buildupTxt = holder.GetComponentInChildren <Text>();
                        buildupTxt.text  = Math.Round(displayDict[entry.Key]) + "%";
                        buildupTxt.color = new Color(1.0f, 0.5f, 0.5f, displayDict[entry.Key] * 0.01f + 0.25f);

                        if (!text.gameObject.activeSelf)
                        {
                            text.gameObject.SetActive(true);
                        }
                    }
                }
            }
        }
        private void UpdatePlayerStatuses(int splitID, ref List <StatusEffectInfo> statusInfos)
        {
            var player = SplitScreenManager.Instance.LocalPlayers[splitID];

            if (player == null || !player.AssignedCharacter)
            {
                return;
            }

            var effectsManager = player.AssignedCharacter.StatusEffectMngr;
            var panel          = player.CharUI.GetComponentInChildren <StatusEffectPanel>();

            if (!panel || !effectsManager)
            {
                Debug.LogError("Could not find status effect managers for " + player.AssignedCharacter.Name);
                return;
            }

            var activeIcons = At.GetField(panel, "m_statusIcons") as Dictionary <string, StatusEffectIcon>;

            foreach (var entry in activeIcons)
            {
                if (!entry.Value.gameObject.activeSelf)
                {
                    continue;
                }

                float remainingLifespan = 0f;

                StatusEffect status = effectsManager.Statuses.Find((s => s.IdentifierName == entry.Key));
                if (status)
                {
                    remainingLifespan = status.RemainingLifespan;
                }
                else
                {
                    // some statuses use an identifier tag instead of their own status name for the icon...
                    switch (entry.Key.ToLower())
                    {
                    case "imbuemainweapon":
                        remainingLifespan = panel.LocalCharacter.CurrentWeapon.FirstImbue.RemainingLifespan;
                        break;

                    case "imbueoffweapon":
                        remainingLifespan = panel.LocalCharacter.LeftHandWeapon.FirstImbue.RemainingLifespan;
                        break;

                    case "summonweapon":
                        remainingLifespan = panel.LocalCharacter.CurrentWeapon.SummonedEquipment.RemainingLifespan;
                        break;

                    case "summonghost":
                        remainingLifespan = panel.LocalCharacter.CurrentSummon.RemainingLifespan;
                        break;

                    case "129":     // marsh poison uses "129" for its tag, I think that's its effect preset ID?
                        if (effectsManager.Statuses.Find((it => it.IdentifierName.Equals("Hallowed Marsh Poison Lvl1"))) is StatusEffect marshpoison)
                        {
                            remainingLifespan = marshpoison.RemainingLifespan;
                        }
                        break;

                    default:
                        //Debug.Log("[CombatHUD] Unhandled Status Identifier! Key: " + entry.Key);
                        continue;
                    }
                }

                if (remainingLifespan > 0f && entry.Value)
                {
                    statusInfos.Add(new StatusEffectInfo
                    {
                        TimeRemaining = remainingLifespan,
                        LinkedIcon    = entry.Value
                    });
                }
            }
        }