// Token: 0x06000424 RID: 1060 RVA: 0x0001A2F8 File Offset: 0x000184F8
 private void Update()
 {
     if (Main.suicide.GetData <bool>() && SilentMelee0.smethod_1(SilentMelee0.smethod_0()) && SilentMelee0.smethod_2(SilentMelee0.smethod_0()) && SilentMelee0.smethod_3() >= this.nextAttack)
     {
         global::BasePlayer basePlayer = null;
         float num = 99999f;
         if (SilentMelee0.smethod_4() != null)
         {
             foreach (global::BasePlayer basePlayer2 in SilentMelee0.smethod_4())
             {
                 Vector3 vector = SilentMelee0.smethod_7(MainCamera.mainCamera, SilentMelee0.smethod_6(SilentMelee0.smethod_5(basePlayer2, "head")));
                 if (vector.z > 0f)
                 {
                     Vector2 vector2 = new Vector2(vector.x, (float)SilentMelee0.smethod_8() - vector.y);
                     float   num2    = Mathf.Abs(Vector2.Distance(new Vector2((float)(SilentMelee0.smethod_9() / 2), (float)(SilentMelee0.smethod_8() / 2)), new Vector2(vector2.x, (float)Screen.height - vector2.y)));
                     if (num2 <= num)
                     {
                         num        = num2;
                         basePlayer = basePlayer2;
                     }
                 }
             }
         }
         if (basePlayer != null && basePlayer.IsValid())
         {
             Vector3            position   = basePlayer.model.headBone.position;
             global::HeldEntity heldEntity = LocalPlayer.Entity.GetHeldEntity();
             if (heldEntity != null && heldEntity.IsValid())
             {
                 float     num3      = Vector3.Distance(LocalPlayer.Entity.transform.position, basePlayer.transform.position);
                 BaseMelee baseMelee = heldEntity as BaseMelee;
                 if (baseMelee != null && baseMelee.IsValid())
                 {
                     if (num3 < 2f)
                     {
                         using (PlayerAttack playerAttack = Pool.Get <PlayerAttack>())
                         {
                             playerAttack.attack = new Attack
                             {
                                 hitID            = basePlayer.net.ID,
                                 hitPositionWorld = basePlayer.FindBone("head").position,
                                 hitPositionLocal = new Vector3(-0.1f, -1f, 0f),
                                 hitNormalLocal   = new Vector3(0f, -1f, 0f),
                                 hitNormalWorld   = (MainCamera.mainCamera.transform.position - basePlayer.FindBone("head").position).normalized,
                                 pointStart       = LocalPlayer.Entity.transform.position,
                                 pointEnd         = basePlayer.FindBone("head").position
                             };
                             baseMelee.ServerRPC <PlayerAttack>("PlayerAttack", playerAttack);
                             Debug.Log("Stop hitting yourself xD");
                         }
                     }
                     this.nextAttack = Time.time + baseMelee.repeatDelay;
                 }
             }
         }
     }
 }
 // Token: 0x060003FD RID: 1021 RVA: 0x00004266 File Offset: 0x00002466
 static bool smethod_9(global::BasePlayer basePlayer_0)
 {
     return(basePlayer_0.IsLocalPlayer());
 }
 // Token: 0x060003F5 RID: 1013 RVA: 0x000042E5 File Offset: 0x000024E5
 static global::HeldEntity smethod_1(global::BasePlayer basePlayer_0)
 {
     return(basePlayer_0.GetHeldEntity());
 }
コード例 #4
0
        void OnServerInitialized()
        {
            TOD_Sky.Instance.Components.Time.OnDay += OnDay;
            _envSync = BaseNetworkable.serverEntities.OfType <EnvSync>().FirstOrDefault();
            _date    = _fullMoonDates[_current];

            timer.Every(5f, () => {
                _envSync.limitNetworking = true;

                if (NightVisionRef != null)
                {
                    NightVisionRef?.CallHook("BlockEnvUpdates", true);
                }

                List <Connection> subscribers = _envSync.net.group.subscribers;
                if (subscribers != null && subscribers.Count > 0)
                {
                    for (int i = 0; i < subscribers.Count; i++)
                    {
                        Connection connection         = subscribers[i];
                        global::BasePlayer basePlayer = connection.player as global::BasePlayer;

                        if (NightVisionRef != null && !(basePlayer == null) && (bool)NightVisionRef?.CallHook("IsPlayerTimeLocked", basePlayer))
                        {
                            continue;
                        }

                        if (!(basePlayer == null) && Net.sv.write.Start())
                        {
                            connection.validate.entityUpdates = connection.validate.entityUpdates + 1;
                            BaseNetworkable.SaveInfo saveInfo = new global::BaseNetworkable.SaveInfo
                            {
                                forConnection = connection,
                                forDisk       = false
                            };
                            Net.sv.write.PacketID(Message.Type.Entities);
                            Net.sv.write.UInt32(connection.validate.entityUpdates);
                            using (saveInfo.msg = Pool.Get <Entity>())
                            {
                                _envSync.Save(saveInfo);
                                saveInfo.msg.environment.dateTime = _date.AddHours(TOD_Sky.Instance.Cycle.Hour).ToBinary();
                                if (_config.disableFogAtNight && TOD_Sky.Instance.IsNight)
                                {
                                    saveInfo.msg.environment.fog    = 0;
                                    saveInfo.msg.environment.rain   = 0;
                                    saveInfo.msg.environment.clouds = 0;
                                }
                                if (saveInfo.msg.baseEntity == null)
                                {
                                    LogError(this + ": ToStream - no BaseEntity!?");
                                }
                                if (saveInfo.msg.baseNetworkable == null)
                                {
                                    LogError(this + ": ToStream - no baseNetworkable!?");
                                }
                                saveInfo.msg.ToProto(Net.sv.write);
                                _envSync.PostSave(saveInfo);
                                Net.sv.write.Send(new SendInfo(connection));
                            }
                        }
                    }
                }
            });
        }