コード例 #1
0
ファイル: Slasher.cs プロジェクト: k1lly0u/EventManager
        private object CanNetworkTo(EnvSync env, BasePlayer player)
        {
            if (env == null || player == null || !EventPlayers.Contains(player))
            {
                return(null);
            }

            if (Net.sv.write.Start())
            {
                Connection connection = player.net.connection;
                connection.validate.entityUpdates = connection.validate.entityUpdates + 1;
                BaseNetworkable.SaveInfo saveInfo = new BaseNetworkable.SaveInfo
                {
                    forConnection = player.net.connection,
                    forDisk       = false
                };

                Net.sv.write.PacketID(Network.Message.Type.Entities);
                Net.sv.write.UInt32(player.net.connection.validate.entityUpdates);

                using (saveInfo.msg = Facepunch.Pool.Get <ProtoBuf.Entity>())
                {
                    env.Save(saveInfo);

                    saveInfo.msg.environment.dateTime = (EventManager.BaseManager as SlasherEvent).IsPlayingRound ? _midnightTime : _middayTime;

                    saveInfo.msg.ToProto(Net.sv.write);
                    Net.sv.write.Send(new SendInfo(player.net.connection));
                }
            }

            return(false);
        }
コード例 #2
0
ファイル: Slasher.cs プロジェクト: k1lly0u/EventManager
            private void EndRound()
            {
                slasherPlayer = null;

                Timer.StopTimer();

                IsPlayingRound = false;

                GodmodeEnabled = true;

                EnvSync.SendNetworkUpdateImmediate();

                if (currentRound >= rounds)
                {
                    Status = EventManager.EventStatus.Finished;

                    StartCoroutine(ResetPlayers());
                    InvokeHandler.Invoke(this, EndEvent, 5f);
                }
                else
                {
                    StartCoroutine(ResetPlayers());

                    InvokeHandler.Invoke(this, StartRound, Configuration.TimeBetweenRounds);
                    BroadcastToPlayers(GetMessage, "Notification.RoundStartsIn", Configuration.TimeBetweenRounds);
                }
            }
コード例 #3
0
ファイル: Slasher.cs プロジェクト: k1lly0u/EventManager
        private void OnServerInitialized()
        {
            EventManager.RegisterEvent(Title, this);

            GetMessage = Message;

            EnvSync = GameObject.FindObjectOfType <EnvSync>();

            FindValidWeapons();
        }
コード例 #4
0
ファイル: Slasher.cs プロジェクト: k1lly0u/EventManager
            private void StartRound()
            {
                GodmodeEnabled = false;

                IsPlayingRound = true;

                EnvSync.SendNetworkUpdateImmediate();

                currentRound += 1;

                slasherPlayer = GetRandomSlasher();

                StartCoroutine(ResetPlayers());

                Timer.StartTimer(slasherTime, GetMessage("Timer.Slasher", 0UL), OnSlasherTimerExpired);

                BroadcastToPlayers(GetMessage, "Notification.RoundStarted", slasherPlayer.Player.displayName);

                UpdateScoreboard();
            }
コード例 #5
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));
                            }
                        }
                    }
                }
            });
        }