Esempio n. 1
0
        public override void OnUpdate()
        {
            if (BasePlayer.LocalPlayer?.CanInteract() == true)
            {
                m_Interval += DeltaTime;

                // Every 0.1s
                if (m_Interval < 0.2f)
                {
                    return;
                }
                m_Interval = 0;
                //ConsoleSystem.Log($"Storage Count => { StorageContainer.Containers}");
                foreach (var player in BasePlayer.ListPlayers)
                {
                    if (player == BasePlayer.LocalPlayer)
                    {
                        continue;
                    }
                    DDraw.DrawBox(player.Position + player.GetCenterVector(), new Vector3(1, 1.8f, 1), Color.magenta, .2f);
                    DDraw.Text(player.Position + new Vector3(0, 1.8f, 0), $"PLAYER", Color.red, .2f);
                }
            }
        }
Esempio n. 2
0
        public override void OnUpdate()
        {
            this.m_interval_update_tick += DeltaTime;
            if (this.m_interval_update_tick >= 0.1f)
            {
                this.m_interval_update_tick = 0f;
                ///
                if (BasePlayer.IsHaveLocalPlayer)
                {
                    if (this.m_no_target_time >= 0.5f)
                    {
                        this.m_no_target_time = 0f;
                        this.TargetPlayer     = null;
                    }

                    #region [Section] Find Target
                    for (int i = 0; i < BasePlayer.ListPlayers.Count; ++i)
                    {
                        if (BasePlayer.ListPlayers[i].IsLocalPlayer == false && BasePlayer.ListPlayers[i].IsAlive)
                        {
                            float distance = Vector3.Distance(BasePlayer.ListPlayers[i].Position, BasePlayer.LocalPlayer.Position);
                            if ((BasePlayer.LocalPlayer.HasActiveItem && OpCodes.IsFireWeapon_Prefab((EPrefabUID)BasePlayer.LocalPlayer.ActiveItem.PrefabID) && distance < 150) || distance < 50)
                            {
                                #region [Section] Range and Radius check
                                Vector3 forward        = BasePlayer.LocalPlayer.GetForward() * distance + BasePlayer.LocalPlayer.EyePos;
                                float   distance_check = 5f;

                                if (distance < 10)
                                {
                                    distance_check = distance / 2;
                                }
                                else if (distance > 30)
                                {
                                    distance_check = 9;
                                }

                                distance_check = 100;
                                float distance_point_and_playuer = Vector3.Distance(forward, BasePlayer.ListPlayers[i].Position + new Vector3(0, BasePlayer.ListPlayers[i].GetHeight() * 0.5f, 0));
                                if (distance_point_and_playuer < distance_check)
                                {
                                    m_list_players.Push(new TargetAimInformation {
                                        Player = BasePlayer.ListPlayers[i], DistanceCursor = distance_point_and_playuer
                                    });
                                }
                                #endregion
                            }
                        }
                    }
                    if (this.m_list_players.Count > 0)
                    {
                        BasePlayer target = null;
                        float      dist   = float.MaxValue;
                        while (this.m_list_players.Count > 0)
                        {
                            TargetAimInformation player = this.m_list_players.Pop();
                            if (dist > player.DistanceCursor)
                            {
                                dist   = player.DistanceCursor;
                                target = player.Player;
                            }
                        }
                        this.TargetPlayer = target;
                    }
                    else if (this.TargetPlayer != null)
                    {
                        m_no_target_time += 0.1f;
                    }

                    #endregion

                    if (this.TargetPlayer != null)
                    {
                        DDraw.Text(this.TargetPlayer.Position + new Vector3(0, this.TargetPlayer.GetHeight(), 0), $"<size=32>.</size>", Color.red, 0.1f);
                    }
//                    if (this.TargetPlayer != null)
//                        DDraw.DrawBox(this.TargetPlayer.Position + new Vector3(0, this.TargetPlayer.GetHeight()*0.5f, 0), this.TargetPlayer.Rotation.ToQuaternion(), new Vector3(1,this.TargetPlayer.GetHeight(), 1), Color.red, 0.05f);
                }

                ///
            }
        }
Esempio n. 3
0
        // Token: 0x06000127 RID: 295 RVA: 0x00009D78 File Offset: 0x00007F78
        public override void OnUpdate()
        {
            this.m_interval_update_tick += SapphireType.DeltaTime;
            bool flag = this.m_interval_update_tick >= 0.1f;

            if (flag)
            {
                this.m_interval_update_tick = 0f;
                bool isHaveLocalPlayer = BasePlayer.IsHaveLocalPlayer;
                if (isHaveLocalPlayer)
                {
                    bool flag2 = this.m_no_target_time >= 0.5f;
                    if (flag2)
                    {
                        this.m_no_target_time = 0f;
                        this.TargetPlayer     = null;
                    }
                    for (int i = 0; i < BasePlayer.ListPlayers.Count; i++)
                    {
                        bool flag3 = !BasePlayer.ListPlayers[i].IsLocalPlayer && BasePlayer.ListPlayers[i].IsAlive;
                        if (flag3)
                        {
                            float distance = Vector3.Distance(BasePlayer.ListPlayers[i].Position, BasePlayer.LocalPlayer.Position);
                            bool  flag4    = (BasePlayer.LocalPlayer.HasActiveItem && OpCodes.IsFireWeapon_Prefab((EPrefabUID)BasePlayer.LocalPlayer.ActiveItem.PrefabID) && distance < 150f) || distance < 70f;
                            if (flag4)
                            {
                                Vector3 forward = BasePlayer.LocalPlayer.GetForward() * distance + BasePlayer.LocalPlayer.EyePos;
                                bool    flag5   = distance < 10f;
                                float   distance_check;
                                if (flag5)
                                {
                                    distance_check = distance / 2f;
                                }
                                else
                                {
                                    bool flag6 = distance > 30f;
                                    if (flag6)
                                    {
                                    }
                                }
                                distance_check = 100f;
                                float distance_point_and_playuer = Vector3.Distance(forward, BasePlayer.ListPlayers[i].Position + new Vector3(0f, BasePlayer.ListPlayers[i].GetHeight() * 0.5f, 0f));
                                bool  flag7 = distance_point_and_playuer < distance_check;
                                if (flag7)
                                {
                                    this.m_list_players.Push(new TargetAimInformation
                                    {
                                        Player         = BasePlayer.ListPlayers[i],
                                        DistanceCursor = distance_point_and_playuer
                                    });
                                }
                            }
                        }
                    }
                    bool flag8 = this.m_list_players.Count > 0;
                    if (flag8)
                    {
                        BasePlayer target = null;
                        float      dist   = float.MaxValue;
                        while (this.m_list_players.Count > 0)
                        {
                            TargetAimInformation player = this.m_list_players.Pop();
                            bool flag9 = dist > player.DistanceCursor;
                            if (flag9)
                            {
                                dist   = player.DistanceCursor;
                                target = player.Player;
                            }
                        }
                        this.TargetPlayer = target;
                    }
                    else
                    {
                        bool flag10 = this.TargetPlayer != null;
                        if (flag10)
                        {
                            this.m_no_target_time += 0.1f;
                        }
                    }
                    bool flag11 = this.TargetPlayer != null;
                    if (flag11)
                    {
                        DDraw.Text(this.TargetPlayer.Position + new Vector3(0f, this.TargetPlayer.GetHeight(), 0f), "<size=32>.</size>", Color.red, 0.1f);
                    }
                }
            }
        }