Beispiel #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Monster"/> class.
        /// </summary>
        /// <param name="monsterType">The type of this monster.</param>
        /// <param name="itemFactory">A reference to the item factory in use, for inventory generation.</param>
        public Monster(IMonsterTypeEntity monsterType, IItemFactory itemFactory)
            : base(monsterType.Name, monsterType.Article, monsterType.MaxHitpoints, monsterType.Corpse)
        {
            this.Type   = monsterType;
            this.Outfit = monsterType.Outfit;

            this.Stats[CreatureStat.BaseSpeed].Set(monsterType.BaseSpeed);

            this.BloodType = monsterType.BloodType;
            this.ChaseMode = this.AutoAttackRange > 1 ? ChaseMode.KeepDistance : ChaseMode.Chase;
            this.FightMode = FightMode.FullAttack;

            this.Inventory = new MonsterInventory(itemFactory, this, monsterType.InventoryComposition);

            this.hostileCombatants     = new HashSet <ICombatant>();
            this.hostileCombatantsLock = new object();

            this.InitializeSkills();
        }
        /// <summary>
        /// Checks if the monster type has the given creature flag set.
        /// </summary>
        /// <param name="monsterTypeEntity">The monster type entity.</param>
        /// <param name="creatureFlag">The creature flag to check for.</param>
        /// <returns>True if the monster type has the creature flag set, and false otherwise.</returns>
        public static bool HasCreatureFlag(this IMonsterTypeEntity monsterTypeEntity, CreatureFlag creatureFlag)
        {
            monsterTypeEntity.ThrowIfNull(nameof(monsterTypeEntity));

            return((monsterTypeEntity.Flags & (ulong)creatureFlag) == (ulong)creatureFlag);
        }