public void AdjustEndSubtick(LogicLevel level)
        {
            if (this.m_endTimestamp != -1)
            {
                int currentTime = LogicDataTables.GetGlobals().AdjustEndSubtickUseCurrentTime()
                    ? level.GetGameMode().GetServerTimeInSecondsSince1970()
                    : level.GetGameMode().GetStartTime();

                if (currentTime != -1)
                {
                    int remainingSecs = this.m_endTimestamp - currentTime;
                    int clamp         = LogicDataTables.GetGlobals().GetClampLongTimeStampsToDays();

                    if (clamp * 86400 > 0)
                    {
                        if (remainingSecs > 86400 * clamp)
                        {
                            remainingSecs = 86400 * clamp;
                        }
                        else if (remainingSecs < -86400 * clamp)
                        {
                            remainingSecs = -86400 * clamp;
                        }
                    }

                    this.m_remainingTime = level.GetLogicTime().GetTick() + LogicTime.GetSecondsInTicks(remainingSecs);
                }
            }
        }
        public void StartTimer(int totalSecs, LogicTime time, bool setEndTimestamp, int currentTimestamp)
        {
            this.m_remainingTime = LogicTime.GetSecondsInTicks(totalSecs) + time.GetTick();

            if (currentTimestamp != -1 && setEndTimestamp)
            {
                this.m_endTimestamp = currentTimestamp + totalSecs;
            }
        }
        public int GetRemainingMS(LogicTime time)
        {
            int remaining = this.m_remainingTime - time.GetTick() - this.m_fastForward;

            if (LogicDataTables.GetGlobals().MoreAccurateTime())
            {
                return(16 * remaining);
            }

            int ms = 1000 * (remaining / 60);

            if (ms % 60 != 0)
            {
                ms += (2133 * ms) >> 7;
            }

            return(ms);
        }
        public static LogicTimer GetLogicTimer(LogicJSONObject jsonObject, LogicTime time, string key, int maxTime)
        {
            LogicJSONNumber number = (LogicJSONNumber)jsonObject.Get(key);

            if (number != null)
            {
                LogicTimer timer = new LogicTimer();

                int remainingSeconds = LogicMath.Min(number.GetIntValue(), maxTime);
                int tick             = time.GetTick();

                timer.m_remainingTime = tick + LogicTime.GetSecondsInTicks(remainingSeconds);

                return(timer);
            }

            return(null);
        }
        public int GetRemainingSeconds(LogicTime time)
        {
            int remaining = this.m_remainingTime - time.GetTick() - this.m_fastForward;

            if (LogicDataTables.GetGlobals().MoreAccurateTime())
            {
                if (remaining > 0)
                {
                    return(LogicMath.Max((int)(16L * remaining / 1000 + 1), 1));
                }
            }
            else
            {
                if (remaining > 0)
                {
                    return(LogicMath.Max((remaining + 59) / 60, 1));
                }
            }

            return(0);
        }
 public void FastForward(int totalSecs)
 {
     this.m_remainingTime -= LogicTime.GetSecondsInTicks(totalSecs);
 }