コード例 #1
0
        /// <summary>
        /// Creates an uninitialized world
        /// Each realm provided will be initialized during the worlds initialization.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="gameDayToRealWorldHoursRatio">The game day to real world hours ratio.</param>
        /// <param name="hoursPerDay">The number of hours per day.</param>
        /// <param name="timePeriods">The time periods available to the world.</param>
        /// <param name="realms">The realms being added to the world.</param>
        /// <returns>Returns an IWorld instance</returns>
        public async Task <IWorld> CreateWorld(string name, double gameDayToRealWorldHoursRatio, int hoursPerDay, IEnumerable <ITimePeriod> timePeriods, IEnumerable <IRealm> realms)
        {
            var world = new MudWorld(this.realmFactory, timePeriods);

            world.SetName(name);
            world.GameDayToRealHourRatio = gameDayToRealWorldHoursRatio;
            world.SetHoursPerDay(hoursPerDay);

            if (realms.Count() > 0)
            {
                await world.AddRealmsToWorld(realms);
            }

            return(world);
        }
コード例 #2
0
        /// <summary>
        /// Clones the properties of this instance to a new instance.
        /// </summary>
        /// <returns>
        /// Returns a new instance with the properties of this instance copied to it.
        /// </returns>
        /// <para>
        /// Cloning does not guarantee that the internal state of an object will be cloned nor
        /// does it guarantee that the clone will be a deep clone or a shallow.
        /// </para>
        public IWorld Clone()
        {
            var clone = new MudWorld(this.realmFactory)
            {
                Id = this.Id,
                CurrentTimeOfDay       = this.CurrentTimeOfDay,
                GameDayToRealHourRatio = this.GameDayToRealHourRatio,
                HoursPerDay            = this.HoursPerDay,
                IsEnabled   = this.IsEnabled,
                Name        = this.Name,
                realms      = this.realms,
                timePeriods = this.timePeriods,
            };

            clone.TimePeriodManager = new TimePeriodManager(this.timePeriods);
            return(clone);
        }