Ejemplo n.º 1
0
        /// <summary>
        ///     Loads the home state.
        /// </summary>
        public void LoadHomeState(LogicClientHome home, LogicAvatar homeOwnerAvatar, int currentTimestamp, int secondsSinceLastSave, int secondsSinceLastMaintenance)
        {
            if (home != null)
            {
                this._state = 1;

                if (LogicDataTables.GetGlobals().StartInLastUsedVillage())
                {
                    int lastUsedVillage = homeOwnerAvatar.GetVillageToGoTo();

                    if (!this._level.GetMissionManager().HasTravel(homeOwnerAvatar))
                    {
                        lastUsedVillage = 0;
                    }

                    if (lastUsedVillage < 0)
                    {
                        Debugger.Warning("VillageToGoTo<0");
                    }
                    else
                    {
                        if (lastUsedVillage > 1)
                        {
                            Debugger.Warning("VillageToGoTo too big");
                        }
                        else
                        {
                            this._level.SetVillageType(lastUsedVillage);
                        }
                    }
                }

                this._secondsSinceLastMaintenance = secondsSinceLastMaintenance;
                this._currentTimestamp            = currentTimestamp;
                this._configuration.Load((LogicJSONObject)LogicJSONParser.Parse(home.GetGlobalJSON()));
                this._calendar.Load(home.GetCalendarJSON(), currentTimestamp);

                if (this._battleTimer != null)
                {
                    this._battleTimer.Destruct();
                    this._battleTimer = null;
                }

                this._level.SetHome(home, true);
                this._level.SetHomeOwnerAvatar(homeOwnerAvatar);
                this._level.FastForwardTime(secondsSinceLastSave);

                homeOwnerAvatar.SetLevel(this._level);

                this._level.LoadingFinished();

                this._shieldTime      = LogicTime.GetSecondsInTicks(home.GetShieldDurationSeconds());
                this._guardTime       = LogicTime.GetSecondsInTicks(home.GetGuardDurationSeconds());
                this._maintenanceTime = LogicTime.GetSecondsInTicks(home.GetNextMaintenanceSeconds());

                int logicTime      = this._level.GetLogicTime();
                int startGuardTime = logicTime;

                if (this._shieldTime >= logicTime)
                {
                    startGuardTime = this._shieldTime;
                }

                this._startGuardTime = startGuardTime;

                if (LogicDataTables.GetGlobals().UseVillageObjects())
                {
                    this._level.LoadVillageObjects();
                }
            }
        }