Пример #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Npc"/> class.
        /// </summary>
        /// <param name="position">
        /// The position.
        /// </param>
        /// <param name="properties">
        /// The properties.
        /// </param>
        /// <param name="itemId">
        /// The item id.
        /// </param>
        /// <param name="itemType">
        /// The item Type.
        /// </param>
        /// <param name="world">
        /// The world.
        /// </param>
        /// <param name="viewDistanceEnter">
        /// The view Distance Enter.
        /// </param>
        /// <param name="viewDistanceExit">
        /// The view Distance Exit.
        /// </param>
        public Npc(Vector position, Hashtable properties, string itemId, byte itemType, IWorld world, Vector viewDistanceEnter, Vector viewDistanceExit)
        {
            this.fiber = new PoolFiber();
            this.representation = new NpcItem(position, properties, itemId, itemType, world, this.fiber);
            if (!world.ItemCache.AddItem(this.representation))
            {
                throw new InvalidOperationException();
            }

            this.fiber.Start();

            this.interestArea = new NpcInterestArea(itemId, world);
            this.interestArea.AttachToItem(this.representation);
            this.interestArea.ViewDistanceEnter = viewDistanceEnter;
            this.interestArea.ViewDistanceExit = viewDistanceExit;
            this.interestArea.UpdateInterestManagement();
            this.representation.Position = position;
            this.representation.UpdateInterestManagement();
        }
Пример #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Npc"/> class.
        /// </summary>
        /// <param name="position">
        /// The position.
        /// </param>
        /// <param name="properties">
        /// The properties.
        /// </param>
        /// <param name="itemId">
        /// The item id.
        /// </param>
        /// <param name="itemType">
        /// The item Type.
        /// </param>
        /// <param name="world">
        /// The world.
        /// </param>
        /// <param name="viewDistanceEnter">
        /// The view Distance Enter.
        /// </param>
        /// <param name="viewDistanceExit">
        /// The view Distance Exit.
        /// </param>
        public Npc(Vector position, Hashtable properties, string itemId, byte itemType, IWorld world, Vector viewDistanceEnter, Vector viewDistanceExit)
        {
            this.fiber          = new PoolFiber();
            this.representation = new NpcItem(position, properties, itemId, itemType, world, this.fiber);
            if (!world.ItemCache.AddItem(this.representation))
            {
                throw new InvalidOperationException();
            }

            this.fiber.Start();

            this.interestArea = new NpcInterestArea(itemId, world);
            this.interestArea.AttachToItem(this.representation);
            this.interestArea.ViewDistanceEnter = viewDistanceEnter;
            this.interestArea.ViewDistanceExit  = viewDistanceExit;
            this.interestArea.UpdateInterestManagement();
            this.representation.Position = position;
            this.representation.UpdateInterestManagement();
        }