Aura.Channel.World.Entities.Creature.LoadDefault C# (CSharp) Method

LoadDefault() public method

Loads race and handles some basic stuff, like adding regens.
Has to be called before anything is actually done with the creature, as it initializes the race data, the inventory, and other vital parts.
public LoadDefault ( ) : void
return void
		public virtual void LoadDefault()
		{
			if (this.RaceId == 0)
				throw new Exception("Set race before calling LoadDefault.");

			this.RaceData = AuraData.RaceDb.Find(this.RaceId);
			if (this.RaceData == null)
			{
				// Try to default to Human
				this.RaceData = AuraData.RaceDb.Find(10000);
				if (this.RaceData == null)
					throw new Exception("Unable to load race data, race '" + this.RaceId.ToString() + "' not found.");

				Log.Warning("Creature.LoadDefault: Race '{0}' not found, using human instead.", this.RaceId);
			}

			if (this.InventoryWidth == 0)
			{
				this.InventoryWidth = this.RaceData.InventoryWidth;
			}

			if (this.InventoryHeight == 0)
			{
				this.InventoryHeight = this.RaceData.InventoryHeight;
			}

			// Add inventory
			this.Inventory.AddMainInventory();
			this.Inventory.StartLiveUpdate();

			// Add regens
			// The wiki says it's 0.125 life, but the packets have 0.12.
			this.Regens.Add(Stat.Life, 0.12f * this.RaceData.LifeRecoveryRate, this.LifeMax);
			this.Regens.Add(Stat.Mana, 0.05f, this.ManaMax);
			this.Regens.Add(Stat.Stamina, 0.4f, this.StaminaMax);
			if (ChannelServer.Instance.Conf.World.EnableHunger)
				this.Regens.Add(Stat.Hunger, 0.01f, this.StaminaMax);

			// Subscribe to time events
			ChannelServer.Instance.Events.SecondsTimeTick += this.OnSecondsTimeTick;
			ChannelServer.Instance.Events.MabiTick += this.OnMabiTick;

			if (this.IsPlayer)
				ChannelServer.Instance.Events.PlayTimeTick += this.OnPlayTimeTick;
		}