/// <summary> /// Initializes a new instance of the <see cref="Creature"/> class. /// </summary> /// <param name="creationMetadata">The metadata for this player.</param> protected Creature(CreatureEntity creationMetadata) { creationMetadata.ThrowIfNull(nameof(creationMetadata)); creationMetadata.Name.ThrowIfNullOrWhiteSpace(nameof(creationMetadata.Name)); if (creationMetadata.MaxHitpoints == 0) { throw new ArgumentException($"{nameof(creationMetadata.MaxHitpoints)} must be positive.", nameof(creationMetadata.MaxHitpoints)); } lock (Creature.IdLock) { this.Id = idCounter++; } this.Name = creationMetadata.Name; this.Article = creationMetadata.Article; this.CorpseTypeId = creationMetadata.Corpse; this.LastMovementCostModifier = 1; this.Outfit = new Outfit { Id = 0, ItemIdLookAlike = 0, }; this.Stats = new Dictionary <CreatureStat, IStat>(); this.creatureAwarenessMap = new Dictionary <ICreature, AwarenessLevel>(); this.Stats.Add(CreatureStat.HitPoints, new Stat(CreatureStat.HitPoints, creationMetadata.CurrentHitpoints == default ? creationMetadata.MaxHitpoints : creationMetadata.CurrentHitpoints, creationMetadata.MaxHitpoints)); this.Stats[CreatureStat.HitPoints].Changed += this.RaiseStatChange; this.Stats.Add(CreatureStat.CarryStrength, new Stat(CreatureStat.CarryStrength, 150, CreatureConstants.MaxCreatureCarryStrength)); this.Stats[CreatureStat.CarryStrength].Changed += this.RaiseStatChange; this.Stats.Add(CreatureStat.BaseSpeed, new Stat(CreatureStat.BaseSpeed, 70, CreatureConstants.MaxCreatureSpeed)); this.Stats[CreatureStat.BaseSpeed].Changed += this.RaiseStatChange; }