-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathEveActiveShip.cs
209 lines (197 loc) · 7.06 KB
/
EveActiveShip.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace EveModel
{
public class EveActiveShip : EveItem
{
public EveActiveShip(EveObject parent) : base(parent) { }
List<EveEntity> _activeDrones;
public List<EveEntity> ActiveDrones
{
get
{
if (_activeDrones == null)
_activeDrones = Frame.Client.Entities.Where(ent => Frame.Client.Michelle.CallMethod("GetDrones", new object[0])["items"].GetDictionary<long>().Keys.ToList().Contains(ent.Id)).ToList();
return _activeDrones;
}
}
public void Fit(string fittingName){
if (Frame.Client.GetFittingWindow == null)
return;
var fs = Frame.Client.GetService("fittingSvc")["fittings"].GetDictionary<int>().Where(f => f.Key == Frame.Client.Session.CharId).FirstOrDefault().Value;
if (fs != null)
{
foreach (var item in fs.GetDictionary<int>())
{
if (fittingName.ToLower() == item.Value["name"].GetValueAs<string>().ToLower())
{
Frame.Client.GetService("fittingSvc").CallMethod("LoadFitting", new object[] { Frame.Client.Session.CharId, item.Key }, true);
break;
}
}
}
}
public int DronesInBay
{
get
{
var shipInv = Frame.Client.InvCache.CallMethod("GetInventoryFromId", new object[] { Frame.Client.Session.ShipId });
return shipInv.CallMethod("ListDroneBay", new object[0]).GetList<EveObject>().Count;
}
}
public void ReleaseDrones()
{
var shipInv = Frame.Client.InvCache.CallMethod("GetInventoryFromId", new object[] { Frame.Client.Session.ShipId });
var drones = shipInv.CallMethod("ListDroneBay", new object[0]);
Frame.Client.MenuService.CallMethod("LaunchDrones", new object[] { drones }, true);
}
EveEntity _entity;
public EveEntity ToEntity
{
get
{
if (_entity == null)
_entity = Frame.Client.Entities.Where(en => en.Id == this.ItemId).FirstOrDefault();
return _entity;
}
}
List<EveModule> _modules;
public List<EveModule> Modules
{
get
{
if (_modules == null)
{
_modules = new List<EveModule>();
foreach (var item in Frame.Client.Builtin["uicore"]["layer"]["shipui"]["sr"]["modules"].GetDictionary<long>())
{
_modules.Add(new EveModule(item.Value, item.Key));
}
}
return _modules;
}
}
public void ManipulateModuleGroup(Group group, bool activate)
{
foreach (var module in Modules.Where(mo => mo.Group == group))
{
if (activate && module.CapacitorNeed < Capacitor)
{
module.Activate();
}
else
{
module.DeActivate();
}
}
}
public double WeaponsFiringRange
{
get { return Weapons.Max(w => w.OptimalRange + w.FallOff); }
}
public double WeaponsOptimalRange
{
get { return Weapons.Average(w => w.OptimalRange); }
}
public double MiningOptimalRange
{
get
{
return Miners.Min(en => en.OptimalRange);
}
}
public List<EveModule> Miners
{
get
{
return Modules.Where(m => m.Group == Group.MiningLaser || m.Group == Group.StripMiner).ToList<EveModule>();
}
}
int[] _weaponGroups = { 53, 55, 56, 72, 74, 506, 507, 508, 509, 510, 511, 512 };
public List<EveModule> Weapons
{
get
{
return Modules.Where(m => _weaponGroups.Contains(m.GroupId)).ToList<EveModule>();
}
}
double? charge;
public double Capacitor
{
get
{
if (!charge.HasValue)
{
EveObject attrib;
charge = this.Attributes.TryGetValue("charge", out attrib) ? attrib.GetValueAs<double>() : 0;
}
return charge.Value;
}
}
public bool HasTravelCloak { get { return Cloak != null && Cloak.TypeName == "Covert Ops Cloaking Device II"; } }
public bool HasCloak { get { return Cloak != null; } }
public bool IsCloaked { get { return Cloak != null && Cloak.IsActive; } }
EveModule _cloak;
public EveModule Cloak
{
get
{
if (_cloak == null)
_cloak = this.Modules.Where(m => m.Group == EveModel.Group.CloakingDevice).FirstOrDefault();
return _cloak;
}
}
public bool IsMissileBoat
{
get
{
bool allLaunchers = false;
foreach (var weapon in Weapons)
{
allLaunchers = weapon.TypeName.Contains("Missile Launcher") |
weapon.TypeName.Contains("Missile Bay") |
weapon.TypeName.Contains("Rocket Launcher") |
weapon.TypeName.Contains("Cruise Launcher");
}
return allLaunchers;
}
}
public bool IsOutOfAmmo
{
get
{
if (!Frame.Client.IsUnifiedInventoryOpen)
{
Frame.Log("Can't check ammo when inventory is closed");
Frame.Client.ExecuteCommand(EveCommand.OpenInventory);
return false;
}
double chargesUsed = 0, chargesInCargo = 0, chargeId = -1;
foreach (var weapon in Weapons)
{
if (weapon.IsReloadingAmmo || weapon.Charge.Stacksize == 0 || weapon.Charge == null)
return false;
chargesUsed += weapon.Capacity / weapon.Charge.Volume;
chargeId = weapon.Charge.TypeId;
}
foreach (var item in Frame.Client.GetCargoOfActiveShip().Items)
{
if (item.TypeId == chargeId)
{
chargesInCargo += item.Quantity;
}
}
return chargesInCargo < Weapons.Count;
}
}
public double MaxLockedTargets
{
get
{
return Attributes["maxLockedTargets"].GetValueAs<double>();
}
}
}
}