示例#1
0
 public ModuleCache(DirectModule module)
 {
     //
     // reminder: this class and all the info within it is created (and destroyed!) each frame for each module!
     //
     _module = module;
     ThisModuleCacheCreated = DateTime.UtcNow;
 }
示例#2
0
        /*public List<DirectItem> MatchingAmmo
         * {
         *  get
         *  {
         *      if (_matchingAmmo == null)
         *      {
         *          _matchingAmmo = new List<DirectItem>();
         *
         *          var pyCharges = _pyModule.Call("GetMatchingAmmo", TypeId).ToList();
         *          foreach (var pyCharge in pyCharges)
         *          {
         *              var charge = new DirectItem(DirectEve);
         *              charge.PyItem = pyCharge;
         *              _matchingAmmo.Add(charge);
         *          }
         *      }
         *
         *      return _matchingAmmo;
         *  }
         * }*/

        internal static List <DirectModule> GetModules(DirectEve directEve)
        {
            var modules = new List <DirectModule>();

            var pySharp = directEve.PySharp;
            var builtin = pySharp.Import("__builtin__");

            var pyModules = builtin.Attribute("uicore").Attribute("layer").Attribute("shipui").Attribute("sr").Attribute("modules").ToDictionary <long>();

            foreach (var pyModule in pyModules)
            {
                var module = new DirectModule(directEve, pyModule.Value);
                module.PyItem          = pyModule.Value.Attribute("sr").Attribute("moduleInfo");
                module.ItemId          = pyModule.Key;
                module.IsOnline        = (bool)pyModule.Value.Attribute("online");
                module.IsGoingOnline   = (bool)pyModule.Value.Attribute("goingOnline");
                module.IsReloadingAmmo = (bool)pyModule.Value.Attribute("reloadingAmmo");
                module.IsChangingAmmo  = (bool)pyModule.Value.Attribute("changingAmmo");

                module.Damage                   = (double)pyModule.Value.Attribute("sr").Attribute("damage");
                module.Hp                       = (double)pyModule.Value.Attribute("sr").Attribute("hp");
                module.IsOverloaded             = (int)directEve.GetLocalSvc("godma").Call("GetOverloadState", module.ItemId) == 1;
                module.IsPendingOverloading     = (int)directEve.GetLocalSvc("godma").Call("GetOverloadState", module.ItemId) == 2;
                module.IsPendingStopOverloading = (int)directEve.GetLocalSvc("godma").Call("GetOverloadState", module.ItemId) == 3;
                module.IsBeingRepaired          = (bool)pyModule.Value.Attribute("isBeingRepaired");
                module.AutoReload               = (bool)pyModule.Value.Attribute("autoreload");

                var effect = pyModule.Value.Attribute("def_effect");
                module.IsActivatable  = effect.IsValid;
                module.IsActive       = (bool)effect.Attribute("isActive");
                module.IsDeactivating = (bool)effect.Attribute("isDeactivating");
                module.TargetId       = (long?)effect.Attribute("targetID");

                var pyCharge = pyModule.Value.Attribute("charge");
                if (pyCharge.IsValid)
                {
                    module.Charge        = new DirectItem(directEve);
                    module.Charge.PyItem = pyCharge;
                }

                modules.Add(module);
            }

            return(modules);
        }
示例#3
0
        /*public List<DirectItem> MatchingAmmo
        {
            get
            {
                if (_matchingAmmo == null)
                {
                    _matchingAmmo = new List<DirectItem>();

                    var pyCharges = _pyModule.Call("GetMatchingAmmo", TypeId).ToList();
                    foreach (var pyCharge in pyCharges)
                    {
                        var charge = new DirectItem(DirectEve);
                        charge.PyItem = pyCharge;
                        _matchingAmmo.Add(charge);
                    }
                }

                return _matchingAmmo;
            }
        }*/
        internal static List<DirectModule> GetModules(DirectEve directEve)
        {
            var modules = new List<DirectModule>();

            var pySharp = directEve.PySharp;
            var builtin = pySharp.Import("__builtin__");

            var pyModules = builtin.Attribute("uicore").Attribute("layer").Attribute("shipui").Attribute("sr").Attribute("modules").ToDictionary<long>();
            foreach (var pyModule in pyModules)
            {
                var module = new DirectModule(directEve, pyModule.Value);
                module.PyItem = pyModule.Value.Attribute("sr").Attribute("moduleInfo");
                module.ItemId = pyModule.Key;
                module.IsOnline = (bool) pyModule.Value.Attribute("online");
                module.IsGoingOnline = (bool) pyModule.Value.Attribute("goingOnline");
                module.IsReloadingAmmo = (bool) pyModule.Value.Attribute("reloadingAmmo");
                module.IsChangingAmmo = (bool) pyModule.Value.Attribute("changingAmmo");

                module.Damage = (double) pyModule.Value.Attribute("sr").Attribute("damage");
                module.Hp = (double) pyModule.Value.Attribute("sr").Attribute("hp");
                module.IsOverloaded = (int) directEve.GetLocalSvc("godma").Call("GetOverloadState", module.ItemId) == 1;
                module.IsPendingOverloading = (int) directEve.GetLocalSvc("godma").Call("GetOverloadState", module.ItemId) == 2;
                module.IsPendingStopOverloading = (int) directEve.GetLocalSvc("godma").Call("GetOverloadState", module.ItemId) == 3;
                module.IsBeingRepaired = (bool) pyModule.Value.Attribute("isBeingRepaired");
                module.AutoReload = (bool) pyModule.Value.Attribute("autoreload");

                var effect = pyModule.Value.Attribute("def_effect");
                module.IsActivatable = effect.IsValid;
                module.IsActive = (bool) effect.Attribute("isActive");
                module.IsDeactivating = (bool) effect.Attribute("isDeactivating");
                module.TargetId = (long?) effect.Attribute("targetID");

                var pyCharge = pyModule.Value.Attribute("charge");
                if (pyCharge.IsValid)
                {
                    module.Charge = new DirectItem(directEve);
                    module.Charge.PyItem = pyCharge;
                }

                modules.Add(module);
            }

            return modules;
        }
示例#4
0
 public ModuleCache(DirectModule module, double reloadTimeThisMission = 0, DateTime activatedTimeStamp = default(DateTime))
 {
     _module = module;
     _reloadTimeThisMission = reloadTimeThisMission;
     _activatedTimeStamp = activatedTimeStamp;
 }
示例#5
0
 public ModuleCache(DirectModule module)
 {
     _module = module;
 }