Questor.Modules.EntityCache.Orbit C# (CSharp) Method

Orbit() public method

public Orbit ( int range ) : void
range int
return void
        public void Orbit(int range)
        {
            Cache.Instance.Approaching = this;

            if (_directEntity != null)
                _directEntity.Orbit(range);
        }

Usage Example

Example #1
0
        /// <summary>
        ///   Activate weapons
        /// </summary>
        private void ActivateWeapons(EntityCache target)
        {
            // Enable speed tank
            if (Cache.Instance.Approaching == null && Settings.Instance.SpeedTank)
                target.Orbit(Cache.Instance.OrbitDistance);

            // Get the weapons
            var weapons = Cache.Instance.Weapons;

            // TODO: Add check to see if there is better ammo to use! :)
            // Get distance of the target and compare that with the ammo currently loaded
            foreach (var weapon in weapons)
            {
                if (!weapon.IsActive)
                    continue;

                // No ammo loaded
                if (weapon.Charge == null)
                    continue;

                var ammo = Settings.Instance.Ammo.FirstOrDefault(a => a.TypeId == weapon.Charge.TypeId);

                //use mission specific ammo
                if (Cache.Instance.missionAmmo.Count() != 0)
                {
                    ammo = Cache.Instance.missionAmmo.FirstOrDefault(a => a.TypeId == weapon.Charge.TypeId);
                }

                // How can this happen? Someone manually loaded ammo
                if (ammo == null)
                    continue;

                // Target is in range
                if (target.Distance <= ammo.Range)
                    continue;

                // Target is out of range, stop firing
                weapon.Deactivate();
            }

            // Hax for max charges returning incorrect value
            if (!weapons.Any(w => w.IsEnergyWeapon))
            {
                MaxCharges = Math.Max(MaxCharges, weapons.Max(l => l.MaxCharges));
                MaxCharges = Math.Max(MaxCharges, weapons.Max(l => l.CurrentCharges));
            }

            // Activate the weapons (it not yet activated)))
            foreach (var weapon in weapons)
            {
                // Are we on the right target?
                if (weapon.IsActive)
                {
                    if (weapon.TargetId != target.Id)
                        weapon.Deactivate();

                    continue;
                }

                // Are we reloading, deactivating or changing ammo?
                if (weapon.IsReloadingAmmo || weapon.IsDeactivating || weapon.IsChangingAmmo)
                    continue;

                // No, check ammo type and if thats correct, activate weapon
                if (ReloadAmmo(weapon, target) && CanActivate(weapon, target, true))
                {
                    Logging.Log("Combat: Activating weapon [" + weapon.ItemId + "] on [" + target.Name + "][" + target.Id + "]");
                    weapon.Activate(target.Id);
                }
            }
        }
All Usage Examples Of Questor.Modules.EntityCache::Orbit