Пример #1
0
            public double Lifespan = 45d;       // seconds

            #region Public Methods

            public void BotAdded(IMapObject item)
            {
                lock (_parentLock)
                {
                    this.Bot   = (ArcBotNPC)item;
                    this.Rules = GetRules(this.Bot);

                    this.State = BotState.Added;
                }
            }
Пример #2
0
            public void BotRemoved()
            {
                lock (_parentLock)
                {
                    this.Bot.Dispose();
                    this.Bot = null;
                    // _rules was set to null immediately

                    this.State = BotState.None;
                }
            }
Пример #3
0
        private static void AddBot(AddBotArgs dna, WorldVars arg)
        {
            // Bot
            ArcBotNPC bot = new ArcBotNPC(dna.Bot, dna.Level, dna.Position, arg.World, arg.Map, arg.Keep2D, arg.MaterialIDs, null, arg.EditorOptions, arg.ItemOptions, arg.Gravity, arg.DragPlane, dna.HomingPoint, dna.HomingRadius, true, true);

            if (dna.AngularVelocity != null)
            {
                bot.PhysicsBody.AngularVelocity = dna.AngularVelocity.Value;
            }

            arg.Map.AddItem(bot);

            // Attached Weapon
            if (dna.AttachedWeapon != null)
            {
                Weapon weapon = new Weapon(dna.AttachedWeapon, new Point3D(0, 0, 0), arg.World, arg.MaterialIDs.Weapon);

                bot.AttachWeapon(weapon);
            }

            // Inventory Weapons
            if (dna.InventoryWeapons != null)
            {
                foreach (var weapDNA in dna.InventoryWeapons)
                {
                    Weapon weapon = new Weapon(weapDNA, new Point3D(0, 0, 0), arg.World, arg.MaterialIDs.Weapon);

                    bot.AddToInventory(weapon);
                }
            }

            // Call delegate
            if (dna.ItemAdded != null)
            {
                dna.ItemAdded(bot);
            }
        }