Exemplo n.º 1
0
            private static MobAIBase GetOrCreateMob(string uniqueId, MonsterAI instance, ZNetView nview)
            {
                MobAIBase mob;

                if (MobManager.IsAliveMob(uniqueId))
                {
                    mob = MobManager.AliveMobs[uniqueId];
                    if (!mob.HasInstance())
                    {
                        mob = MobManager.CreateMob(uniqueId, instance);
                        MobManager.AliveMobs[uniqueId] = mob;
                        Common.Dbgl($"Replacing old instance of mob '{mob.Character.m_name}', IsOwner:{nview.IsOwner()}");
                    }
                    return(mob);
                }
                else
                {
                    mob = MobManager.CreateMob(uniqueId, instance);
                }

                if (mob == null)
                {
                    Common.Dbgl($"Failed to create mob {uniqueId}', IsOwner:{nview.IsOwner()}");
                    return(null);
                }

                Common.Dbgl($"Adding new instance of mob '{mob.Character.GetHoverName()}', IsOwner:{nview.IsOwner()}");
                MobManager.AliveMobs.Add(uniqueId, mob);
                return(mob);
            }
Exemplo n.º 2
0
        static void Postfix(ZNetView ___m_nview)
        {
            if (Time.time - m_callHomeKeyTimer < m_callHomeKeyDelay)
            {
                return;
            }
            if (Input.GetKey(m_callHomeKey))
            {
                Common.Dbgl($"CallHome command");
                m_callHomeKeyTimer = Time.time;
                ___m_nview.InvokeRPC(ZNetView.Everybody, Constants.Z_CallHomeCommand, Player.m_localPlayer.transform.position);

                var charsInRange = new List <Character>();
                var m_nview      = typeof(Character).GetField("m_nview", BindingFlags.Instance | BindingFlags.NonPublic);
                Character.GetCharactersInRange(Player.m_localPlayer.transform.position, 190, charsInRange);
                foreach (var character in charsInRange)
                {
                    var nview    = m_nview.GetValue(character) as ZNetView;
                    var uniqueId = nview.GetZDO().GetString(Constants.Z_CharacterId);
                    if (MobManager.IsAliveMob(uniqueId))
                    {
                        MobManager.AliveMobs[uniqueId].Follow(Player.m_localPlayer);
                    }
                }
            }
        }
Exemplo n.º 3
0
            public static void RPC_UpdateCharacterName(long sender, string uniqueId, string text)
            {
                if (!MobManager.IsAliveMob(uniqueId))
                {
                    return;
                }
                Character greylingToUpdate;

                try
                {
                    greylingToUpdate = MobManager.AliveMobs[uniqueId].Character;
                }
                catch (System.Exception)
                {
                    return;
                }

                greylingToUpdate.m_name = text;
                var hudsDictObject = EnemyHud.instance.GetType().GetField("m_huds", BindingFlags.GetField | BindingFlags.NonPublic | BindingFlags.Instance).GetValue(EnemyHud.instance);
                var hudsDict       = hudsDictObject as System.Collections.IDictionary;

                if (!hudsDict.Contains(greylingToUpdate))
                {
                    return;
                }
                var hudObject = hudsDict[greylingToUpdate];
                var hudText   = hudObject.GetType().GetField("m_name", BindingFlags.Public | BindingFlags.Instance).GetValue(hudObject) as Text;

                if (hudText == null)
                {
                    return;
                }
                hudText.text = text;
            }
Exemplo n.º 4
0
            static void Prefix(ref Character __instance, ref ZNetView ___m_nview, ref HitData hit)
            {
                var uniqueId = ___m_nview.GetZDO().GetString(Constants.Z_CharacterId);

                if (string.IsNullOrEmpty(uniqueId))
                {
                    return;
                }

                if (MobManager.IsAliveMob(uniqueId))
                {
                    var attacker = hit.GetAttacker();
                    if (attacker != null && attacker.IsPlayer())
                    {
                        hit.m_damage.Modify(0.1f);
                    }
                }
            }