Пример #1
0
        private void OnPlayerDamaged(SDG.Unturned.Player uPlayer, ref EDeathCause cause, ref ELimb limb, ref CSteamID killerId, ref global::UnityEngine.Vector3 direction, ref float damage, ref float times, ref bool canDamage)
        {
            if (uPlayer == null)
            {
                return;
            }

            playerManager.TryGetOnlinePlayerById(uPlayer.channel.owner.playerID.steamID.ToString(), out var player);
            playerManager.TryGetOnlinePlayerById(killerId.m_SteamID.ToString(), out var killer);

            UnturnedPlayerDamagedEvent damageEvent =
                new UnturnedPlayerDamagedEvent(player, cause, limb, killer?.User, direction.ToSystemVector(), damage, times)
            {
                IsCancelled = !canDamage
            };

            eventManager.Emit(this, damageEvent);
            cause     = damageEvent.DeathCause;
            limb      = damageEvent.Limb;
            killerId  = damageEvent.DamageDealer != null ? new CSteamID(ulong.Parse(damageEvent.DamageDealer.Id)) : CSteamID.Nil;
            direction = damageEvent.Direction.ToUnityVector();
            damage    = (float)damageEvent.Damage;
            times     = damageEvent.Times;
            canDamage = !damageEvent.IsCancelled;
        }
        internal static void InternalOnPlayerStatIncremented(SDG.Unturned.Player player, EPlayerStat gameStat)
        {
            UnturnedPlayerEvents instance = player.GetComponent <UnturnedPlayerEvents>();
            UnturnedPlayer       rp       = UnturnedPlayer.FromPlayer(player);

            OnPlayerUpdateStat.TryInvoke(rp, gameStat);
            instance.OnUpdateStat.TryInvoke(rp, gameStat);
        }
 static void onDamage(SDG.Unturned.Player player, ref EDeathCause cause, ref ELimb limb, ref CSteamID killer, ref Vector3 direction, ref float damage, ref float times, ref bool canDamage)
 {
     if (OnPlayerDamaged != null && player != null && killer != CSteamID.Nil && killer != null)
     {
         UnturnedPlayer getterDamage = UnturnedPlayer.FromPlayer(player);
         UnturnedPlayer senderDamage = UnturnedPlayer.FromCSteamID(killer);
         OnPlayerDamaged.TryInvoke(getterDamage, cause, limb, senderDamage, direction, damage, times, canDamage);
     }
 }
Пример #4
0
 private UnturnedPlayer(CSteamID cSteamID)
 {
     if (string.IsNullOrEmpty(cSteamID.ToString()) || cSteamID.ToString() == "0")
     {
         throw new PlayerIsConsoleException();
     }
     else
     {
         player = PlayerTool.getPlayer(cSteamID);
     }
 }
 private UnturnedPlayer(CSteamID SteamID)
 {
     if (SteamID == Steamworks.CSteamID.Nil)
     {
         throw new PlayerIsConsoleException();
     }
     else
     {
         player = PlayerTool.getPlayer(SteamID);
     }
 }
Пример #6
0
        public UnturnedUser(IUserDataStore userDataStore, SDG.Unturned.Player player, UnturnedPendingUser pending) : base(userDataStore)
        {
            Type        = KnownActorTypes.Player;
            Player      = player;
            SteamPlayer = Player.channel.owner;

            var steamPlayerIdId = SteamPlayer.playerID;

            SteamId     = steamPlayerIdId.steamID;
            DisplayName = SteamPlayer.playerID.characterName;

            Session = new UnturnedUserSession(this, pending.Session);
        }
Пример #7
0
        public static UnturnedPlayer FromName(string name)
        {
            SDG.Unturned.Player p = null;
            ulong id = 0;

            if (ulong.TryParse(name, out id) && id > 76561197960265728)
            {
                p = PlayerTool.getPlayer(new CSteamID(id));
            }
            else
            {
                p = PlayerTool.getPlayer(name);
            }
            if (p == null)
            {
                return(null);
            }
            return(new UnturnedPlayer(p));
        }
        private void OnPlayerDamaged(SDG.Unturned.Player uPlayer, ref EDeathCause cause, ref ELimb limb, ref CSteamID killerId, ref Vector3 direction, ref float damage, ref float times, ref bool canDamage)
        {
            var player = playerManager.GetOnlinePlayerById(uPlayer.channel.owner.playerID.steamID.m_SteamID.ToString());
            var killer = playerManager.GetOnlinePlayerById(killerId.m_SteamID.ToString());

            UnturnedPlayerDamagedEvent @event =
                new UnturnedPlayerDamagedEvent(player, cause, limb, killer.GetUser(), direction, damage, times)
            {
                IsCancelled = !canDamage
            };

            eventManager.Emit(this, @event);
            cause     = @event.DeathCause;
            limb      = @event.Limb;
            killerId  = @event.DamageDealer != null ? new CSteamID(ulong.Parse(@event.DamageDealer.Id)) : CSteamID.Nil;
            direction = @event.Direction;
            damage    = (float)@event.Damage;
            times     = @event.Times;
            canDamage = [email protected];
        }
Пример #9
0
 private UnturnedPlayer(SteamPlayer player)
 {
     this.player = player.player;
 }
Пример #10
0
 public static UnturnedPlayer FromPlayer(SDG.Unturned.Player player)
 {
     return(new UnturnedPlayer(player.SteamChannel.SteamPlayer.SteamPlayerID.CSteamID));
 }
Пример #11
0
 private UnturnedPlayer(SDG.Unturned.Player p)
 {
     player = p;
 }
Пример #12
0
 public static UnturnedPlayer FromPlayer(SDG.Unturned.Player player)
 {
     return(new UnturnedPlayer(player.channel.owner.playerID.steamID));
 }
Пример #13
0
 public virtual UnturnedUser GetUser(SDG.Unturned.Player player)
 {
     return(GetUser(player.channel.owner));
 }
Пример #14
0
        private void udESP()
        {
            while (!terminate)
            {
                try
                {
                    if (espEnabled)
                    {
                        if (dManager.d_ref)
                        {
                            dManager.drawing_esp.Clear();
                            Collider[] cols = Physics.OverlapSphere(Information.player.transform.position, distance, RayMasks.DAMAGE_CLIENT);
                            foreach (Collider c in cols)
                            {
                                if (DamageTool.getPlayer(c.transform) != null)
                                {
                                    SDG.Unturned.Player ut = DamageTool.getPlayer(c.transform);
                                    if (esp_player)
                                    {
                                        if (ut.gameObject == null)
                                        {
                                            continue;
                                        }
                                        SteamPlayer ply      = Tool.getSteamPlayer(ut.gameObject);
                                        bool        isFriend = ComponentManager.friend_manager.exists(ply.playerID.steamID.m_SteamID);
                                        float       dist     = (float)Math.Round(Tool.getDistance(ut.transform.position));
                                        Vector3     c2s      = MainCamera.instance.WorldToScreenPoint(ut.transform.position);
                                        Highlighter h        = ut.gameObject.GetComponent <Highlighter>();

                                        if (c2s.z <= 0)
                                        {
                                            continue;
                                        }

                                        c2s.x = c2s.x - 64f;
                                        c2s.y = (Screen.height - (c2s.y + 1f)) - 12f;

                                        if (Array.Exists(dManager.drawing_esp.ToArray(), a => a.pos == c2s))
                                        {
                                            continue;
                                        }

                                        dManager.drawing_esp.Add(new DrawType((p_name ? ply.playerID.nickName : "") + (p_distance ? "[" + dist + "]" : ""), c2s, (isFriend ? Information.esp_friends : Information.esp_players), p_name || p_distance, ut.gameObject, Tool.BoundsToScreenRect(c.bounds)));


                                        if (draw_highlight)
                                        {
                                            if (h == null)
                                            {
                                                h = ut.gameObject.AddComponent <Highlighter>();
                                                h.OccluderOn();
                                                h.SeeThroughOn();
                                                h.ConstantOn((isFriend ? Information.esp_friends : Information.esp_players));
                                            }
                                            HighlightType ht = dManager.highlights.Find(a => a.h == h);
                                            if (ht == null)
                                            {
                                                dManager.highlights.Add(new HighlightType(h, ut.gameObject));
                                            }
                                            else
                                            {
                                                ht.hasUd = true;
                                            }
                                        }
                                        continue;
                                    }
                                }

                                if (DamageTool.getZombie(c.transform))
                                {
                                    SDG.Unturned.Zombie ut = DamageTool.getZombie(c.transform);
                                    if (esp_zombie)
                                    {
                                        if (ut.gameObject == null && !ut.isDead)
                                        {
                                            continue;
                                        }
                                        float       dist = (float)Math.Round(Tool.getDistance(ut.transform.position));
                                        Vector3     c2s  = Camera.main.WorldToScreenPoint(ut.transform.position);
                                        Highlighter h    = ut.gameObject.GetComponent <Highlighter>();

                                        if (c2s.z <= 0)
                                        {
                                            continue;
                                        }

                                        c2s.x = c2s.x - 64f;
                                        c2s.y = (Screen.height - (c2s.y + 1f)) - 12f;

                                        if (Array.Exists(dManager.drawing_esp.ToArray(), a => a.pos == c2s))
                                        {
                                            continue;
                                        }

                                        dManager.drawing_esp.Add(new DrawType((z_name ? getZombieName(ut) : "") + (z_distance ? "[" + dist + "]" : ""), c2s, Information.esp_zombies, z_name || z_distance, ut.gameObject, Tool.BoundsToScreenRect(c.bounds)));

                                        if (draw_highlight)
                                        {
                                            if (h == null)
                                            {
                                                h = ut.gameObject.AddComponent <Highlighter>();
                                                h.OccluderOn();
                                                h.SeeThroughOn();
                                                h.ConstantOn(Information.esp_zombies);
                                            }
                                            HighlightType ht = dManager.highlights.Find(a => a.h == h);
                                            if (ht == null)
                                            {
                                                dManager.highlights.Add(new HighlightType(h, ut.gameObject));
                                            }
                                            else
                                            {
                                                ht.hasUd = true;
                                            }
                                        }
                                        continue;
                                    }
                                }
                            }
                            dManager.d_ref = false;
                        }
                    }
                    else
                    {
                        dManager.rm_highlights = true;
                        dManager.drawing_esp.Clear();
                    }
                }
                catch (Exception ex)
                {
                    Debug.LogException(ex);
                }
            }
        }
Пример #15
0
 private void e_OnHurt(SDG.Unturned.Player player, byte damage, Vector3 force, EDeathCause cause, ELimb limb, Steamworks.CSteamID killer)
 {
     player.life.askHeal(100, true, true);
     //StartCoroutine(HealLegs());
 }
Пример #16
0
 /// <summary>
 /// Tries to convert the player to unturned player instance
 /// </summary>
 /// <param name="player">The player instance</param>
 /// <returns>The unturned player instance gotten from the player instance</returns>
 public static UnturnedPlayer ToUnturnedPlayer(this SDG.Unturned.Player player) => UnturnedPlayer.Get(player);