Esempio n. 1
0
            public AddArgs(Point3D position, Vector3D? angularVelocity, ItemAddedHandler itemAdded)
            {
                this.Position = position;
                this.AngularVelocity = angularVelocity;

                this.ItemAdded = itemAdded;
            }
Esempio n. 2
0
            public AddArgs(Point3D position, Vector3D?angularVelocity, ItemAddedHandler itemAdded)
            {
                this.Position        = position;
                this.AngularVelocity = angularVelocity;

                this.ItemAdded = itemAdded;
            }
Esempio n. 3
0
    public void EmitOnItemAdded(Item item, int amount)
    {
        ItemAddedHandler handler = OnItemAdded;

        if (handler != null)
        {
            handler(this, new ItemEventArgs(item, amount));
        }
        GameEventsLogger.LogItemAdded(this, item, amount);
    }
Esempio n. 4
0
 public AddBotArgs(Point3D position, Vector3D? angularVelocity, ItemAddedHandler itemAdded, BotDNA bot, int level, Point3D homingPoint, double homingRadius, WeaponDNA attachedWeapon = null, WeaponDNA[] inventoryWeapons = null)
     : base(position, angularVelocity, itemAdded)
 {
     this.Bot = bot;
     this.Level = level;
     this.HomingPoint = homingPoint;
     this.HomingRadius = homingRadius;
     this.AttachedWeapon = attachedWeapon;
     this.InventoryWeapons = inventoryWeapons;
 }
Esempio n. 5
0
 public AddBotArgs(Point3D position, Vector3D?angularVelocity, ItemAddedHandler itemAdded, BotDNA bot, int level, Point3D homingPoint, double homingRadius, WeaponDNA attachedWeapon = null, WeaponDNA[] inventoryWeapons = null)
     : base(position, angularVelocity, itemAdded)
 {
     this.Bot              = bot;
     this.Level            = level;
     this.HomingPoint      = homingPoint;
     this.HomingRadius     = homingRadius;
     this.AttachedWeapon   = attachedWeapon;
     this.InventoryWeapons = inventoryWeapons;
 }
Esempio n. 6
0
 internal CollectorPump(Collector <T> collector, ItemAddedHandler pumpOutput, bool openPump = false)
 {
     Collector                    = collector;
     Counter                      = 0;
     IsClosed                     = false;
     CollectorAction              = (item, itemnumber, last) => Sucker();
     collector.ItemAddedApproved += (item, itemnumber, last) => LastReceived = last; //Last listener
     ItemReceived                += pumpOutput;
     if (openPump)
     {
         OpenPump();
     }
 }
Esempio n. 7
0
        /// <summary>
        ///     Waits for arrival of an item for <param name="timeout"> milliseconds. </param>
        /// </summary>
        /// <param name="comparer">The comparator for indentifying the wanted item</param>
        /// <param name="timeout">The time in milliseconds to wait. set it to -1 for infinite</param>
        /// <returns></returns>
        public T WaitFor(CompareItems comparer, int timeout = -1) //todo test it
        {
            T   res            = default(T);                      //ignore default(T), it doesnt matter anyway
            var firstOrDefault = this.FirstOrDefault(t => comparer(t));

            if (firstOrDefault != null && firstOrDefault.Equals(default(T)) == false)
            {
                return(firstOrDefault);
            }
            //not found.. wait for it.
            var waiter = new ManualResetEventSlim(false);

            var itemAddedHandler = new ItemAddedHandler(item => { if (comparer(item))
                                                                  {
                                                                      res = item; waiter.Set();
                                                                  }
                                                        });

            ItemAdded += itemAddedHandler;
            var fod = this.FirstOrDefault(t => comparer(t));

            if (fod != null && fod.Equals(default(T)) == false)
            {
                ItemAdded -= itemAddedHandler;
                return(fod);
            }

            if (timeout > -1)
            {
                waiter.Wait(timeout);
            }
            else
            {
                waiter.Wait();
            }
            return(res);
        }
Esempio n. 8
0
 public AddWeaponArgs(Point3D position, Vector3D? angularVelocity, ItemAddedHandler itemAdded, WeaponDNA weapon)
     : base(position, angularVelocity, itemAdded)
 {
     this.Weapon = weapon;
 }
Esempio n. 9
0
 public AddWeaponArgs(Point3D position, Vector3D?angularVelocity, ItemAddedHandler itemAdded, WeaponDNA weapon)
     : base(position, angularVelocity, itemAdded)
 {
     this.Weapon = weapon;
 }