Example #1
0
        public bool ChangeAmmo(DirectItem charge)
        {
            if (charge.ItemId <= 0)
            {
                return(false);
            }

            if (charge.TypeId <= 0)
            {
                return(false);
            }

            if (charge.Stacksize <= 0)
            {
                return(false);
            }

            var realoadInfo = _pyModule.Call("GetChargeReloadInfo").ToList();

            if (charge.TypeId == (int)realoadInfo[0])
            {
                return(ReloadAmmo(charge));
            }
            else
            {
                _pyModule.Attribute("stateManager").Call("ChangeAmmoTypeForModule", ItemId, charge.TypeId);
                return(ReloadAmmo(charge));
            }
        }
        internal DirectMarketActionWindow(DirectEve directEve, PyObject pyWindow) : base(directEve, pyWindow)
        {
            IsReady      = (bool)pyWindow.Attribute("ready");
            IsBuyAction  = Name == "marketbuyaction";
            IsSellAction = Name == "marketsellaction";

            Item        = new DirectItem(directEve);
            Item.PyItem = pyWindow.Attribute("sr").Attribute("sellItem");

            var order = pyWindow.Attribute("sr").Attribute("currentOrder");

            Price           = (double?)order.Attribute("price");
            RemainingVolume = (double?)order.Attribute("volRemaining");
            Range           = (int?)order.Attribute("range");
            OrderId         = (long?)order.Attribute("orderID");
            EnteredVolume   = (int?)order.Attribute("volEntered");
            MinimumVolume   = (int?)order.Attribute("minVolume");
            IsBid           = (bool?)order.Attribute("bid");
            Issued          = (DateTime?)order.Attribute("issued");
            Duration        = (int?)order.Attribute("duration");
            StationId       = (long?)order.Attribute("stationID");
            RegionId        = (long?)order.Attribute("regionID");
            SolarSystemId   = (long?)order.Attribute("solarSystemID");
            Jumps           = (int?)order.Attribute("jumps");
        }
Example #3
0
        /// <summary>
        ///     Add an item to this container
        /// </summary>
        /// <param name="item"></param>
        /// <param name="quantity"></param>
        /// <returns></returns>
        public bool Add(DirectItem item, int quantity)
        {
            // You can't fit modules like this
            if (_shipModules)
            {
                return(false);
            }

            if (item.LocationId == -1 || quantity < 1)
            {
                return(false);
            }

            var keywords = new Dictionary <string, object>();

            keywords.Add("qty", quantity);
            if (_pyFlag.IsValid)
            {
                keywords.Add("flag", _pyFlag);
            }
            if (!_pyFlag.IsValid && GroupId == (int)DirectEve.Const.GroupAuditLogSecureContainer)
            {
                keywords.Add("flag", DirectEve.Const.FlagUnlocked);
            }
            return(DirectEve.ThreadedCallWithKeywords(_pyInventory.Attribute("Add"), keywords, item.ItemId, item.LocationId));
        }
        internal DirectMarketActionWindow(DirectEve directEve, PyObject pyWindow)
            : base(directEve, pyWindow)
        {
            IsReady = (bool) pyWindow.Attribute("ready");
            IsBuyAction = Name == "marketbuyaction";
            IsSellAction = Name == "marketsellaction";

            Item = new DirectItem(directEve);
            Item.PyItem = pyWindow.Attribute("sr").Attribute("sellItem");

            var order = pyWindow.Attribute("sr").Attribute("currentOrder");
            Price = (double?) order.Attribute("price");
            RemainingVolume = (double?) order.Attribute("volRemaining");
            Range = (int?) order.Attribute("range");
            OrderId = (long?) order.Attribute("orderID");
            EnteredVolume = (int?) order.Attribute("volEntered");
            MinimumVolume = (int?) order.Attribute("minVolume");
            IsBid = (bool?) order.Attribute("bid");
            Issued = (DateTime?) order.Attribute("issued");
            Duration = (int?) order.Attribute("duration");
            StationId = (long?) order.Attribute("stationID");
            RegionId = (long?) order.Attribute("regionID");
            SolarSystemId = (long?) order.Attribute("solarSystemID");
            Jumps = (int?) order.Attribute("jumps");
        }
Example #5
0
        public bool ReloadAmmo(DirectItem charge)
        {
            if (charge.ItemId <= 0)
            {
                return(false);
            }

            return(DirectEve.ThreadedCall(_pyModule.Attribute("ReloadAmmo"), charge.ItemId, 1, charge.IsSingleton));
        }
Example #6
0
        public bool Add(DirectItem item)
        {
            if (item.LocationId == -1)
            {
                return(false);
            }

            //This method instead of _AddItem to prevent quantity popup
            return(DirectEve.ThreadedCall(PyWindow.Attribute("sr").Attribute("my").Attribute("invController").Attribute("_BaseInvContainer__AddItem"), item.ItemId, item.LocationId, item.Quantity));
        }
Example #7
0
        public ItemCache(DirectItem item)
        {
            Id = item.ItemId;
            Name = item.TypeName;

            TypeId = item.TypeId;
            GroupId = item.GroupId;
            MarketGroupId = item.MarketGroupId;

            Quantity = item.Quantity;
            QuantitySold = 0;
        }
Example #8
0
        internal DirectContainer(DirectEve directEve, PyObject pyInventory, PyObject pyFlag)
            : base(directEve)
        {
            _pyInventory = pyInventory;
            _pyFlag      = pyFlag;

            TypeId = (int)pyInventory.Attribute("typeID");

            if (!pyInventory.Attribute("listed").IsValid || pyInventory.Attribute("listed").IsNull || pyInventory.Attribute("listed").IsNone)
            {
                DirectItem.RefreshItems(directEve, pyInventory, pyFlag);
            }
        }
Example #9
0
 public ItemCache(DirectItem item, bool cacheRefineOutput)
 {
     BasePrice = item.BasePrice;
     Capacity = item.Capacity;
     MarketGroupId = item.MarketGroupId;
     PortionSize = item.PortionSize;
     QuantitySold = 0;
     RefineOutput = new List<ItemCache>();
     if (cacheRefineOutput)
     {
         foreach (DirectItem i in item.Materials)
             RefineOutput.Add(new ItemCache(i, false));
     }
 }
Example #10
0
 public bool Sell(DirectItem item, int StationId, int quantity, double price, int duration, bool useCorp)
 {
     if (!item.PyItem.IsValid)
     {
         return(false);
     }
     //if (!HasSupportInstances())
     //{
     //    Log("DirectEve: Error: This method requires a support instance.");
     //    return false;
     //}
     //var pyRange = GetRange(range);
     //def SellStuff(self, stationID, typeID, itemID, price, quantity, duration = 0, useCorp = False, located = None):
     return(ThreadedLocalSvcCall("marketQuote", "SellStuff", StationId, item.TypeId, item.ItemId, price, quantity, duration, useCorp)); //pyRange);
 }
Example #11
0
        // If this is not the right place to do the calls themself, let me know. I thought placing them in DirectContainer was not neat ~ Ferox
        /// <summary>
        ///     Assets list
        /// </summary>
        /// <returns></returns>
        public List <DirectItem> GetAssets()
        {
            if (_listGlobalAssets == null)
            {
                _listGlobalAssets = new List <DirectItem>();
                var pyItemDict = GetLocalSvc("invCache").Attribute("containerGlobal").Attribute("cachedItems").ToDictionary <long>();
                foreach (var pyItem in pyItemDict)
                {
                    var item = new DirectItem(this);
                    item.PyItem = pyItem.Value;
                    _listGlobalAssets.Add(item);
                }
            }

            return(_listGlobalAssets);
        }
Example #12
0
        internal DirectFitting(DirectEve directEve, long ownerId, int fittingId, PyObject pyFitting) : base(directEve)
        {
            _pyFitting = pyFitting;

            OwnerId    = ownerId;
            FittingId  = fittingId;
            Name       = (string)pyFitting.Attribute("name");
            ShipTypeId = (int)pyFitting.Attribute("shipTypeID");
            Modules    = new List <DirectItem>();
            foreach (var module in pyFitting.Attribute("fitData").ToList())
            {
                var item = new DirectItem(directEve);
                item.TypeId   = (int)module.Item(0);
                item.FlagId   = (int)module.Item(1);
                item.Quantity = (int)module.Item(2);
                item.OwnerId  = (int)OwnerId;
                Modules.Add(item);
            }
        }
Example #13
0
        internal DirectFitting(DirectEve directEve, long ownerId, int fittingId, PyObject pyFitting)
            : base(directEve)
        {
            _pyFitting = pyFitting;

            OwnerId = ownerId;
            FittingId = fittingId;
            Name = (string) pyFitting.Attribute("name");
            ShipTypeId = (int) pyFitting.Attribute("shipTypeID");
            Modules = new List<DirectItem>();
            foreach (var module in pyFitting.Attribute("fitData").ToList())
            {
                var item = new DirectItem(directEve);
                item.TypeId = (int) module.Item(0);
                item.FlagId = (int) module.Item(1);
                item.Quantity = (int) module.Item(2);
                item.OwnerId = (int) OwnerId;
                Modules.Add(item);
            }
        }
Example #14
0
        public ItemCache(DirectItem item, bool cacheRefineOutput)
        {
            Id = item.ItemId;
            Name = item.TypeName;

            TypeId = item.TypeId;
            GroupId = item.GroupId;
            MarketGroupId = item.MarketGroupId;
            PortionSize = item.PortionSize;

            Quantity = item.Quantity;
            QuantitySold = 0;

            RefineOutput = new List<ItemCache>();
            if (cacheRefineOutput)
            {
                foreach (var i in item.Materials)
                    RefineOutput.Add(new ItemCache(i, false));
            }
        }
Example #15
0
        internal static List <DirectItem> GetItems(DirectEve directEve, PyObject inventory, PyObject flag)
        {
            var items       = new List <DirectItem>();
            var cachedItems = inventory.Attribute("cachedItems").ToDictionary();
            var pyItems     = cachedItems.Values;

            foreach (var pyItem in pyItems)
            {
                var item = new DirectItem(directEve);
                item.PyItem = pyItem;

                // Do not add the item if the flags do not coincide
                if (flag.IsValid && (int)flag != item.FlagId)
                {
                    continue;
                }

                items.Add(item);
            }

            return(items);
        }
Example #16
0
        public ItemCacheMarket(DirectItem item, bool cacheRefineOutput)
        {
            Id = item.ItemId;
            Name = item.TypeName;

            TypeId = item.TypeId;
            GroupId = item.GroupId;
            BasePrice = item.BasePrice;
            Volume = item.Volume;
            Capacity = item.Capacity;
            MarketGroupId = item.MarketGroupId;
            PortionSize = item.PortionSize;

            Quantity = item.Quantity;
            QuantitySold = 0;

            RefineOutput = new List<ItemCacheMarket>();
            if (cacheRefineOutput)
            {
                foreach (DirectItem i in item.Materials)
                    RefineOutput.Add(new ItemCacheMarket(i, false));
            }
        }
Example #17
0
        public bool ChangeAmmo(DirectItem charge)
        {
            if (charge.ItemId <= 0)
                return false;

            if (charge.TypeId <= 0)
                return false;

            if (charge.Stacksize <= 0)
                return false;

            var realoadInfo = _pyModule.Call("GetChargeReloadInfo").ToList();
            if (charge.TypeId == (int) realoadInfo[0])
                return ReloadAmmo(charge);
            else
            {
                _pyModule.Attribute("stateManager").Call("ChangeAmmoTypeForModule", ItemId, charge.TypeId);
                return ReloadAmmo(charge);
            }
        }
Example #18
0
 public SellItem(DirectItem item, bool createOrder)
 {
     _item = item;
     _createOrder = createOrder;
 }
Example #19
0
        private bool LoadthisScript(DirectItem scriptToLoad, ModuleCache module)
        {
            if (scriptToLoad != null)
            {
                if (module.IsReloadingAmmo || module.IsActive || module.IsDeactivating || module.IsChangingAmmo || module.InLimboState || module.IsGoingOnline || !module.IsOnline)
                    return false;

                // We have enough ammo loaded
                if (module.Charge != null && module.Charge.TypeId == scriptToLoad.TypeId && module.CurrentCharges == module.MaxCharges)
                {
                    Logging.Log("LoadthisScript", "module is already loaded with the script we wanted", Logging.Teal);
                    NextScriptReload[module.ItemId] = DateTime.UtcNow.AddSeconds(15); //mark this weapon as reloaded... by the time we need to reload this timer will have aged enough...
                    return false;
                }

                // We are reloading, wait 15
                if (NextScriptReload.ContainsKey(module.ItemId) && DateTime.UtcNow < NextScriptReload[module.ItemId].AddSeconds(15))
                {
                    Logging.Log("LoadthisScript", "module was reloaded recently... skipping", Logging.Teal);
                    return false;
                }
                NextScriptReload[module.ItemId] = DateTime.UtcNow.AddSeconds(15);

                // Reload or change ammo
                if (module.Charge != null && module.Charge.TypeId == scriptToLoad.TypeId)
                {
                    if (DateTime.UtcNow.Subtract(Cache.Instance.LastLoggingAction).TotalSeconds > 10)
                    {
                        Cache.Instance.LastLoggingAction = DateTime.UtcNow;
                    }
                    Logging.Log("Defense", "Reloading [" + module.TypeId + "] with [" + scriptToLoad.TypeName + "][TypeID: " + scriptToLoad.TypeId + "]", Logging.Teal);
                    module.ReloadAmmo(scriptToLoad);
                    return true;
                }

                if (DateTime.UtcNow.Subtract(Cache.Instance.LastLoggingAction).TotalSeconds > 10)
                {
                    Cache.Instance.LastLoggingAction = DateTime.UtcNow;
                }
                Logging.Log("Defense", "Changing [" + module.TypeId + "] with [" + scriptToLoad.TypeName + "][TypeID: " + scriptToLoad.TypeId + "]", Logging.Teal);
                module.ChangeAmmo(scriptToLoad);
                return true;
            }
            Logging.Log("LoadthisScript", "script to load was NULL!", Logging.Teal);
            return false;
        }
Example #20
0
 public void ChangeAmmo(DirectItem charge)
 {
     _module.ChangeAmmo(charge);
 }
Example #21
0
 public void ReloadAmmo(DirectItem charge)
 {
     _module.ReloadAmmo(charge);
 }
Example #22
0
 /// <summary>
 ///     Drop bookmarks into people &amp; places
 /// </summary>
 /// <param name="bookmarks"></param>
 /// <returns></returns>
 public bool DropInPeopleAndPlaces(IEnumerable <DirectItem> bookmarks)
 {
     return(DirectItem.DropInPlaces(this, bookmarks));
 }
Example #23
0
 /// <summary>
 ///     Add an item to this container
 /// </summary>
 /// <param name="item"></param>
 /// <returns></returns>
 public bool Add(DirectItem item)
 {
     return(Add(item, item.Stacksize));
 }
Example #24
0
        // If this is not the right place to do the calls themself, let me know. I thought placing them in DirectContainer was not neat ~ Ferox
        /// <summary>
        ///     Assets list
        /// </summary>
        /// <returns></returns>
        public List<DirectItem> GetAssets()
        {
            if (_listGlobalAssets == null)
            {
                _listGlobalAssets = new List<DirectItem>();
                var pyItemDict = GetLocalSvc("invCache").Attribute("containerGlobal").Attribute("cachedItems").ToDictionary<long>();
                foreach (var pyItem in pyItemDict)
                {
                    var item = new DirectItem(this);
                    item.PyItem = pyItem.Value;
                    _listGlobalAssets.Add(item);
                }
            }

            return _listGlobalAssets;
        }
Example #25
0
        private void SellItemFinished(DirectItem item, bool sold)
        {
            if(sold == true)
                _newSellOrders++;

            if (RunNextSellAction() == false)
            {
                Logging.Log("Automation:SellItemFinished", "CreateSellOrders State - End", Logging.Debug);
                ChangeState(State.CreateBuyOrders);
            }
        }
Example #26
0
        private void LogItem(string format, DirectItem item)
        {
            Log(format, "ItemId", item.ItemId);

            Log(format, "TypeId", item.TypeId);

            Log(format, "GroupId", item.GroupId);
            Log(format, "GroupName", item.GroupName);

            Log(format, "CategoryId", item.CategoryId);
            Log(format, "CategoryName", item.CategoryName);

            Log(format, "OwnerId", item.OwnerId);
            Log(format, "LocationId", item.LocationId);

            Log(format, "Quantity", item.Quantity);
            Log(format, "Stacksize", item.Stacksize);

            Log(format, "TypeName", item.TypeName);
            Log(format, "GivenName", item.GivenName);
        }
Example #27
0
 public bool Sell(DirectItem item, int StationId, int quantity, double price, int duration, bool useCorp)
 {
     if (!item.PyItem.IsValid)
         return false;
     //if (!HasSupportInstances())
     //{
     //    Log("DirectEve: Error: This method requires a support instance.");
     //    return false;
     //}
     //var pyRange = GetRange(range);
     //def SellStuff(self, stationID, typeID, itemID, price, quantity, duration = 0, useCorp = False, located = None):
     return ThreadedLocalSvcCall("marketQuote", "SellStuff", StationId, item.TypeId, item.ItemId, price, quantity, duration, useCorp); //pyRange);
 }
Example #28
0
 /// <summary>
 ///     Add an item to this container
 /// </summary>
 /// <param name="item"></param>
 /// <returns></returns>
 public bool Add(DirectItem item)
 {
     return Add(item, item.Stacksize);
 }
Example #29
0
        public bool ReloadAmmo(DirectItem charge, int weaponNumber, double Range)
        {
            if (!IsReloadingAmmo)
            {
                if (!IsChangingAmmo)
                {
                    if (!InLimboState)
                    {
                        Logging.Log("ReloadAmmo", "Reloading [" + weaponNumber + "] [" + _module.TypeName + "] with [" + charge.TypeName + "][" + Math.Round(Range / 1000, 0) + "]", Logging.Teal);
                        _module.ReloadAmmo(charge);
                        Cache.Instance.LastReloadedTimeStamp[ItemId] = DateTime.UtcNow;
                        if (Cache.Instance.ReloadTimePerModule.ContainsKey(ItemId))
                        {
                            Cache.Instance.ReloadTimePerModule[ItemId] = Cache.Instance.ReloadTimePerModule[ItemId] + Time.Instance.ReloadWeaponDelayBeforeUsable_seconds;
                        }
                        else
                        {
                            Cache.Instance.ReloadTimePerModule[ItemId] = Time.Instance.ReloadWeaponDelayBeforeUsable_seconds;
                        }

                        return true;
                    }

                    Logging.Log("ReloadAmmo", "[" + weaponNumber + "][" + _module.TypeName + "] is currently in a limbo state, waiting", Logging.Teal);
                    return false;
                }

                Logging.Log("ReloadAmmo", "[" + weaponNumber + "][" + _module.TypeName + "] is already changing ammo, waiting", Logging.Teal);
                return false;
            }

            Logging.Log("ReloadAmmo", "[" + weaponNumber + "][" + _module.TypeName + "] is already reloading, waiting", Logging.Teal);
            return false;
        }
Example #30
0
        /// <summary>
        ///     Add an item to this container
        /// </summary>
        /// <param name="item"></param>
        /// <param name="quantity"></param>
        /// <returns></returns>
        public bool Add(DirectItem item, int quantity)
        {
            // You can't fit modules like this
            if (_shipModules)
                return false;

            if (item.LocationId == -1 || quantity < 1)
                return false;

            var keywords = new Dictionary<string, object>();
            keywords.Add("qty", quantity);
            if (_pyFlag.IsValid)
                keywords.Add("flag", _pyFlag);
            if (!_pyFlag.IsValid && GroupId == (int) DirectEve.Const.GroupAuditLogSecureContainer)
                keywords.Add("flag", DirectEve.Const.FlagUnlocked);
            return DirectEve.ThreadedCallWithKeywords(_pyInventory.Attribute("Add"), keywords, item.ItemId, item.LocationId);
        }
Example #31
0
        public bool ReloadAmmo(DirectItem charge)
        {
            if (charge.ItemId <= 0)
                return false;

            return DirectEve.ThreadedCall(_pyModule.Attribute("ReloadAmmo"), charge.ItemId, 1, charge.IsSingleton);
        }
Example #32
0
 public ItemCache(DirectItem item)
 {
     _directItem = item;
 }
Example #33
0
        public bool Add(DirectItem item)
        {
            if (item.LocationId == -1)
                return false;

            //This method instead of _AddItem to prevent quantity popup
            return DirectEve.ThreadedCall(PyWindow.Attribute("sr").Attribute("my").Attribute("invController").Attribute("_BaseInvContainer__AddItem"), item.ItemId, item.LocationId, item.Quantity);
        }
Example #34
0
        internal static List<DirectItem> GetItems(DirectEve directEve, PyObject inventory, PyObject flag)
        {
            var items = new List<DirectItem>();
            var cachedItems = inventory.Attribute("cachedItems").ToDictionary();
            var pyItems = cachedItems.Values;

            foreach (var pyItem in pyItems)
            {
                var item = new DirectItem(directEve);
                item.PyItem = pyItem;

                // Do not add the item if the flags do not coincide
                if (flag.IsValid && (int) flag != item.FlagId)
                    continue;

                items.Add(item);
            }

            return items;
        }