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; }
/*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); }
/*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; }
public ModuleCache(DirectModule module, double reloadTimeThisMission = 0, DateTime activatedTimeStamp = default(DateTime)) { _module = module; _reloadTimeThisMission = reloadTimeThisMission; _activatedTimeStamp = activatedTimeStamp; }
public ModuleCache(DirectModule module) { _module = module; }