Пример #1
0
            internal override void OnEventPlayerDeath(EventManager.BaseEventPlayer victim, EventManager.BaseEventPlayer attacker = null, HitInfo info = null)
            {
                if (victim == null)
                {
                    return;
                }

                victim.OnPlayerDeath(attacker, Configuration.RespawnTime);

                if (attacker != null && victim != attacker)
                {
                    attacker.OnKilledPlayer(info);

                    if (GetAlivePlayerCount() <= 1)
                    {
                        winner = attacker;
                        InvokeHandler.Invoke(this, EndEvent, 0.1f);
                        return;
                    }
                }

                UpdateScoreboard();

                base.OnEventPlayerDeath(victim, attacker);
            }
Пример #2
0
            internal override void OnEventPlayerDeath(EventManager.BaseEventPlayer victim, EventManager.BaseEventPlayer attacker = null, HitInfo info = null)
            {
                if (victim == null)
                {
                    return;
                }

                victim.OnPlayerDeath(attacker, Configuration.RespawnTime);

                if (attacker != null && victim != attacker && victim.Team != attacker.Team)
                {
                    int score;
                    if (attacker.Team == EventManager.Team.B)
                    {
                        score = teamBScore += 1;
                    }
                    else
                    {
                        score = teamAScore += 1;
                    }

                    attacker.OnKilledPlayer(info);

                    if (Config.ScoreLimit > 0 && score >= Config.ScoreLimit)
                    {
                        winningTeam = attacker.Team;
                        InvokeHandler.Invoke(this, EndEvent, 0.1f);
                        return;
                    }
                }

                UpdateScoreboard();
                base.OnEventPlayerDeath(victim, attacker);
            }
Пример #3
0
            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);
                }
            }
Пример #4
0
            internal void OnFlagCaptured(CaptureTheFlagPlayer eventPlayer, EventManager.Team team)
            {
                int flagCaptures;

                if (eventPlayer.Team == EventManager.Team.B)
                {
                    flagCaptures = teamBScore += 1;
                }
                else
                {
                    flagCaptures = teamAScore += 1;
                }

                eventPlayer.FlagCaptures += 1;

                BroadcastToPlayers(GetMessage, "Notification.FlagCaptured", eventPlayer.Player.displayName, team, GetTeamColor(eventPlayer.Team), GetTeamColor(team));

                UpdateScoreboard();

                if (flagCaptures >= Config.ScoreLimit)
                {
                    winningTeam = eventPlayer.Team;
                    InvokeHandler.Invoke(this, EndEvent, 0.1f);
                }
            }
Пример #5
0
        private void OnEntityBuilt(Planner builder, GameObject gameObject)
        {
            if (builder == null || gameObject == null)
            {
                return;
            }
            BaseEntity entity = gameObject.GetComponent <BaseEntity>();

            if (config.debugMode)
            {
                Puts($"[DEBUG] => {entity.ShortPrefabName}");
            }
            if (entity == null)
            {
                return;
            }
            if (config.barricadePrefabs.Contains(entity.ShortPrefabName))
            {
                BasePlayer player = builder.GetOwnerPlayer();
                if (player == null)
                {
                    return;
                }
                if (player.IsBuildingAuthed())
                {
                    return;
                }
                InvokeHandler.Invoke(entity, delegate { entity.Kill(); }, config.removeAfter);
            }
        }
Пример #6
0
    protected void DoCycle()
    {
        if (this.target == null)
        {
            return;
        }
        float extrapolationTime      = this.target.GetExtrapolationTime();
        float interpolationDelay     = this.target.GetInterpolationDelay();
        float interpolationSmoothing = this.target.GetInterpolationSmoothing();

        TransformInterpolator.Segment segment = this.interpolator.Query(Time.get_time(), interpolationDelay, extrapolationTime, interpolationSmoothing);
        this.extrapolatedTime = (double)segment.next.time < (double)this.interpolator.last.time ? Mathf.Max(this.extrapolatedTime - Time.get_deltaTime(), 0.0f) : Mathf.Min(this.extrapolatedTime + Time.get_deltaTime(), extrapolationTime);
        if ((double)this.extrapolatedTime > 0.0 && (double)extrapolationTime > 0.0 && (double)interpolationSmoothing > 0.0)
        {
            float num = Time.get_deltaTime() / (this.extrapolatedTime / extrapolationTime * interpolationSmoothing);
            segment.tick.pos = Vector3.Lerp(this.target.GetNetworkPosition(), segment.tick.pos, num);
            segment.tick.rot = Quaternion.Slerp(this.target.GetNetworkRotation(), segment.tick.rot, num);
        }
        this.target.SetNetworkPosition(segment.tick.pos);
        this.target.SetNetworkRotation(segment.tick.rot);
        if (PositionLerp.DebugDraw)
        {
            this.target.DrawInterpolationState(segment, this.interpolator.list);
        }
        if ((double)Time.get_time() - (double)this.lastClientTime <= 10.0)
        {
            return;
        }
        if (this.idleDisable == null)
        {
            this.idleDisable = new Action(this.IdleDisable);
        }
        InvokeHandler.Invoke((Behaviour)this, this.idleDisable, 0.0f);
    }
Пример #7
0
        public object Invoke(object target, params object[] parameters)
        {
            if (m_MethodEmpty)
            {
                return(null);
            }

            return(m_MethodHandler.Invoke(target, parameters));
        }
Пример #8
0
        IEnumerator SendRequest()
        {
            var request = new UnityWebRequest(_uri, UnityWebRequest.kHttpVerbPOST)
            {
                uploadHandler   = new UploadHandlerRaw(_data),
                downloadHandler = new DownloadHandlerBuffer(),
                timeout         = 5,
                useHttpContinue = true,
                redirectLimit   = 5
            };

            yield return(request.SendWebRequest());

            if (request.isNetworkError)
            {
                if (_attempt >= 2)
                {
                    if (_throttleNetworkErrorMessages)
                    {
                        _accumulatedNetworkErrors += 1;
                    }
                    else
                    {
                        Debug.LogError($"Two consecutive network failures occurred while submitting a batch of metrics");
                        InvokeHandler.Invoke(this, _notifySubsequentNetworkFailuresAction, 5);
                        _throttleNetworkErrorMessages = true;
                    }
                    yield break;
                }

                _attempt++;
                yield return(SendRequest());

                yield break;
            }

            if (request.isHttpError)
            {
                if (_throttleHttpErrorMessages)
                {
                    _accumulatedHttpErrors += 1;
                }
                else
                {
                    Debug.LogError($"A HTTP error occurred while submitting batch of metrics: {request.error}");
                    if (_metricsLogger.DebugLogging)
                    {
                        Debug.LogError(request.downloadHandler.text);
                    }
                    InvokeHandler.Invoke(this, _notifySubsequentHttpFailuresAction, 5);
                    _throttleHttpErrorMessages = true;
                }

                yield break;
            }
        }
Пример #9
0
 public static bool SafeInvoke(this Control control, InvokeHandler handler)
 {
     if (control.InvokeRequired)
     {
         control.Invoke(handler);
         return false;
     }
     else
         handler.Invoke();
     return true;
 }
Пример #10
0
 /// <summary>
 ///     Safely invokes the specified handler.
 /// </summary>
 /// <param name="control">The Windows forms control.</param>
 /// <param name="handler">The handler to invoke.</param>
 public static void SafeInvoke(this Control control, InvokeHandler handler)
 {
     if (control.InvokeRequired)
     {
         control.Invoke(handler);
     }
     else
     {
         handler?.Invoke();
     }
 }
Пример #11
0
            protected override void StartEvent()
            {
                base.StartEvent();

                GodmodeEnabled = true;

                InvokeHandler.Invoke(this, StartRound, Configuration.TimeBetweenRounds);

                BroadcastToPlayers(GetMessage, "Notification.RoundStartsIn", Configuration.TimeBetweenRounds);

                InvokeHandler.InvokeRepeating(this, UpdateScoreboard, 1f, 1f);
            }
Пример #12
0
        private void OnEntityBuilt(Planner plan, GameObject go)
        {
            if (plan == null || go == null)
            {
                return;
            }

            string name = go.name;

            if (name == null || (name.Length != HighStoneWallName.Length && name.Length != HighWoodWallName.Length))
            {
                return;
            }
            else if (name != HighStoneWallName && name != HighWoodWallName)
            {
                return;
            }

            BasePlayer ownerPlayer = plan.GetOwnerPlayer();

            if (ownerPlayer == null)
            {
                return;
            }
            if (ownerPlayer.IsBuildingAuthed())
            {
                return;
            }

            BaseCombatEntity entity = go.GetComponent <BaseCombatEntity>();

            if (entity == null)
            {
                return;
            }

            float barricadeHealth = entity.MaxHealth() * barricadeHealthPercentage;

            entity.health = barricadeHealth;
            entity.SendNetworkUpdate(BasePlayer.NetworkQueue.Update);

            InvokeHandler.Invoke(entity, delegate
            {
                if (entity.health > barricadeHealth)
                {
                    return;
                }

                entity.Kill();
            }, decayTime);
        }
Пример #13
0
            internal override void OnEventPlayerDeath(EventManager.BaseEventPlayer victim, EventManager.BaseEventPlayer attacker = null, HitInfo hitInfo = null)
            {
                if (victim == null)
                {
                    return;
                }

                victim.OnPlayerDeath(attacker, Configuration.RespawnTime);

                if (attacker != null && victim != attacker)
                {
                    if (Configuration.ResetHealthOnKill)
                    {
                        attacker.Player.health = attacker.Player.MaxHealth();
                        attacker.Player.SendNetworkUpdate(BasePlayer.NetworkQueue.Update);
                    }

                    attacker.OnKilledPlayer(hitInfo);

                    string attackersWeapon = GetWeaponShortname(hitInfo);

                    if (!string.IsNullOrEmpty(attackersWeapon))
                    {
                        if (KilledByRankedWeapon(attacker as GunGamePlayer, attackersWeapon))
                        {
                            (attacker as GunGamePlayer).Rank += 1;

                            if ((attacker as GunGamePlayer).Rank > weaponSet.Count)
                            {
                                winner = attacker;
                                InvokeHandler.Invoke(this, EndEvent, 0.1f);
                                return;
                            }
                            else
                            {
                                (attacker as GunGamePlayer).RemoveRankWeapon();
                                (attacker as GunGamePlayer).GiveRankWeapon(weaponSet.CreateItem((attacker as GunGamePlayer).Rank));
                            }
                        }
                        else if (KilledByDowngradeWeapon(attackersWeapon))
                        {
                            (victim as GunGamePlayer).Rank = Mathf.Clamp((victim as GunGamePlayer).Rank - 1, 1, weaponSet.Count);
                        }
                    }
                }

                UpdateScoreboard();
                base.OnEventPlayerDeath(victim, attacker);
            }
Пример #14
0
            private void EndRound()
            {
                GodmodeEnabled = true;

                if (currentRound >= rounds)
                {
                    winners.AddRange(eventPlayers);
                    InvokeHandler.Invoke(this, EndEvent, 0.1f);
                }
                else
                {
                    InvokeHandler.Invoke(this, StartRound, Configuration.TimeBetweenRounds);
                    BroadcastToPlayers(GetMessage, "Notification.RoundStartsIn", Configuration.TimeBetweenRounds);

                    StartCoroutine(ResetPlayers());
                }
            }
Пример #15
0
            public void StopToDie()
            {
                enabled = false;
                isDying = true;

                if (entity != null)
                {
                    entity.SetFlag(BaseEntity.Flags.Reserved1, false, false);
                    foreach (var wheel in entity.wheels)
                    {
                        wheel.wheelCollider.motorTorque = 0;
                        wheel.wheelCollider.brakeTorque = float.MaxValue;
                    }
                }

                EjectAllPlayers();
                InvokeHandler.Invoke(this, OnDeath, 5f);
            }
Пример #16
0
            internal void DropFlag(bool resetToBase)
            {
                primary.SetParent(null, true);

                if (FlagHolder != null)
                {
                    FlagHolder.IsCarryingFlag = false;
                    FlagHolder = null;
                }

                primary.UpdateNetworkGroup();
                primary.SendNetworkUpdate(BasePlayer.NetworkQueue.Update);

                if (resetToBase)
                {
                    InvokeHandler.Invoke(this, DroppedTimeExpired, captureTheFlagEvent.flagRespawnTime);
                }
            }
Пример #17
0
            internal override void OnEventPlayerDeath(EventManager.BaseEventPlayer victim, EventManager.BaseEventPlayer attacker = null, HitInfo info = null)
            {
                if (victim == null)
                {
                    return;
                }

                (victim as ChopperSurvivalPlayer).LivesRemaining -= 1;

                if (GetPlayersRemainingCount() == 0)
                {
                    victim.AddPlayerDeath(null);

                    InvokeHandler.Invoke(this, EndEvent, 0.1f);
                    return;
                }

                victim.OnPlayerDeath(attacker, Configuration.RespawnTime);

                base.OnEventPlayerDeath(victim, attacker);
            }
Пример #18
0
    protected void DoCycle()
    {
        if (this.target == null)
        {
            return;
        }
        float extrapolationTime      = this.target.GetExtrapolationTime();
        float interpolationDelay     = this.target.GetInterpolationDelay();
        float interpolationSmoothing = this.target.GetInterpolationSmoothing();

        TransformInterpolator.Segment segment = this.interpolator.Query(Time.time, interpolationDelay, extrapolationTime, interpolationSmoothing);
        if (segment.next.time < this.interpolator.last.time)
        {
            this.extrapolatedTime = Mathf.Max(this.extrapolatedTime - Time.deltaTime, 0f);
        }
        else
        {
            this.extrapolatedTime = Mathf.Min(this.extrapolatedTime + Time.deltaTime, extrapolationTime);
        }
        if (this.extrapolatedTime > 0f && extrapolationTime > 0f && interpolationSmoothing > 0f)
        {
            float single = Time.deltaTime / (this.extrapolatedTime / extrapolationTime * interpolationSmoothing);
            segment.tick.pos = Vector3.Lerp(this.target.GetNetworkPosition(), segment.tick.pos, single);
            segment.tick.rot = Quaternion.Slerp(this.target.GetNetworkRotation(), segment.tick.rot, single);
        }
        this.target.SetNetworkPosition(segment.tick.pos);
        this.target.SetNetworkRotation(segment.tick.rot);
        if (PositionLerp.DebugDraw)
        {
            this.target.DrawInterpolationState(segment, this.interpolator.list);
        }
        if (Time.time - this.lastClientTime > 10f)
        {
            if (this.idleDisable == null)
            {
                this.idleDisable = new Action(this.IdleDisable);
            }
            InvokeHandler.Invoke(this, this.idleDisable, 0f);
        }
    }
Пример #19
0
            private void OnDeath()
            {
                isDieing = true;

                if (player != null)
                {
                    player.EnsureDismounted();
                }

                InvokeHandler.Invoke(this, () =>
                {
                    Effect.server.Run(heliExplosion, transform.position);
                    ins.NextTick(() =>
                    {
                        if (entity != null && !entity.IsDestroyed)
                        {
                            entity.DieInstantly();
                        }
                        Destroy(this);
                    });
                }, 5f);
            }
Пример #20
0
 public void Invoke(object handler, IMessageSender handlerContext)
 {
     _invoker.Invoke(handler, handlerContext);
 }
Пример #21
0
 public void Invoke(Action action, float time)
 {
     InvokeHandler.Invoke(this, action, time);
 }
Пример #22
0
 public void Invoke(IPipelineEvent @event)
 {
     _invoker.Invoke(_pipelineObserver, @event);
 }