示例#1
0
        public FactionFleet(long facId, GridOwner.OWNER_TYPE ownerType)
        {
            //if (s_Settings == null) {
            //    s_Settings = ConquestSettings.getInstance();
            //}
            if (s_Rules == null)
            {
                s_Rules = ConquestSettings.getInstance().HullRules;
            }
            if (s_Logger == null)
            {
                s_Logger = new Logger("Static", "FactionFleet");
            }
            log("start", "ctr", Logger.severity.TRACE);

            m_FactionId = facId;
            m_OwnerType = ownerType;

            // = init count holders
            m_TotalCount = 0;

            int classCount = Enum.GetValues(typeof(HullClass.CLASS)).Length;

            m_Counts = new uint[classCount];

            m_SupportedGrids = new Dictionary <long, GridEnforcer> [classCount];
            for (int i = 0; i < classCount; i++)
            {
                m_SupportedGrids[i] = new Dictionary <long, GridEnforcer>();
            }

            m_UnsupportedGrids = new Dictionary <long, GridEnforcer> [classCount];
            for (int i = 0; i < classCount; i++)
            {
                m_UnsupportedGrids[i] = new Dictionary <long, GridEnforcer>();
            }

            m_Maximums = new uint[classCount];
            if (ownerType == GridOwner.OWNER_TYPE.FACTION)
            {
                for (int i = 0; i < classCount; i++)
                {
                    m_Maximums[i] = (uint)s_Rules[i].MaxPerFaction;
                }
            }
            else if (ownerType == GridOwner.OWNER_TYPE.PLAYER)
            {
                for (int i = 0; i < classCount; i++)
                {
                    m_Maximums[i] = (uint)s_Rules[i].MaxPerSoloPlayer;
                }
            }
            else
            {
                for (int i = 0; i < classCount; i++)
                {
                    m_Maximums[i] = 0;
                }
            }
        }
示例#2
0
        private void processSettingsRequest(SettingsRequest req)
        {
            log("", "processSettingsRequest");
            SettingsResponse resp = new SettingsResponse()
            {
                Settings    = ConquestSettings.getInstance().Settings,
                Destination = new List <long>()
                {
                    req.ReturnAddress
                },
                DestType = BaseResponse.DEST_TYPE.PLAYER
            };

            send(resp);
        }
        /// <summary>
        /// Starts or resumes the derelict timer
        /// </summary>
        /// <returns>Returns false if dereliction is disabled</returns>
        public bool start()
        {
            int seconds             = ConquestSettings.getInstance().CleanupPeriod;
            int settingsTimerLength = seconds * 1000;

            log("Starting timer with settings start value of " + seconds + " seconds.",
                "start", Logger.severity.TRACE);
            if (seconds < 0)
            {
                log("Dereliction timers disabled.  No timer started.", "start");
                return(false);
            }

            // Check if there is a timer to resume for this entity
            DT_INFO existing = StateTracker.getInstance().findActiveDerelictTimer(m_Grid.EntityId);

            if (existing != null)
            {
                // Resuming an existing timer
                log("Resuming existing timer", "start");

                m_TimerInfo = existing;

                // If the settings Timer Length has changed, update this timer accordingly
                if (m_TimerInfo.TimerLength != settingsTimerLength)
                {
                    log("Timer length has changed from " + m_TimerInfo.TimerLength +
                        "ms to " + settingsTimerLength + "ms", "start");

                    int     savedMillis     = m_TimerInfo.MillisRemaining;
                    decimal lengthRatio     = (decimal)settingsTimerLength / (decimal)m_TimerInfo.TimerLength;
                    int     correctedMillis = (int)(savedMillis * lengthRatio);

                    log("Changing this timer from " + savedMillis + "ms to " + correctedMillis +
                        "ms using ratio " + lengthRatio, "start");

                    m_TimerInfo.MillisRemaining = correctedMillis;
                    m_TimerInfo.TimerLength     = settingsTimerLength;
                }

                m_Timer = new MyTimer(m_TimerInfo.MillisRemaining, timerExpired);
                m_Timer.Start();
                log("Timer resumed with " + m_TimerInfo.MillisRemaining + "ms", "start");
            }
            else
            {
                // Starting a new timer
                log("Starting new timer", "start");

                m_TimerInfo                 = new DT_INFO();
                m_TimerInfo.GridID          = m_Grid.EntityId;
                m_TimerInfo.Phase           = DT_INFO.PHASE.INITIAL;
                m_TimerInfo.TimerLength     = seconds * 1000;
                m_TimerInfo.MillisRemaining = m_TimerInfo.TimerLength;
                m_TimerInfo.LastUpdated     = DateTime.UtcNow;

                m_Timer = new MyTimer(m_TimerInfo.MillisRemaining, timerExpired);
                m_Timer.Start();
                log("Timer started with " + m_TimerInfo.MillisRemaining + "ms", "start");

                StateTracker.getInstance().addNewDerelictTimer(m_TimerInfo);
            }

            return(true);
        }