-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathEveClient.cs
1192 lines (1116 loc) · 30.5 KB
/
EveClient.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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace EveModel
{
public class EveClient : IDisposable
{
public EveClient()
{
}
#region Eve Client Object and Service References
/// <summary>
/// Cache for already referenced EVE Client objects, will be cleared beween every frame
/// </summary>
public Dictionary<string, EveObject> Objects = new Dictionary<string, EveObject>();
/// <summary>
/// Gets the __builtin__ object reference in the EVE CLient process
/// </summary>
public EveObject Builtin
{
get
{
EveObject obj;
if (!Objects.TryGetValue("__builtin__", out obj))
{
obj = new EveObject(PyCall.PyImport_ImportModule("__builtin__"), "__builtin__");
}
return obj;
}
}
internal EveObject Import(string module){
{
EveObject obj;
if (!Objects.TryGetValue(module, out obj))
{
obj = new EveObject(PyCall.PyImport_ImportModule(module), module);
}
return obj;
}
}
/// <summary>
/// Gets the utthread object reference used in creating asynchronous method calls in the EVE Client process
/// </summary>
internal EveObject UThread
{
get
{
EveObject obj;
if (!Objects.TryGetValue("uthread", out obj))
{
obj = new EveObject(PyCall.PyImport_ImportModule("uthread"), "uthread");
}
return obj;
}
}
/// <summary>
/// Gets the services object reference
/// </summary>
internal EveObject Services
{
get
{
EveObject obj;
if (!Objects.TryGetValue("services", out obj))
{
obj = Builtin["sm"]["services"];
}
return obj;
}
}
/// <summary>
/// Gets the invtypes object reference
/// </summary>
internal EveObject InvTypes
{
get
{
EveObject obj;
if (!Objects.TryGetValue("instanceBuiltin", out obj))
{
obj = new EveObject(PyCall.PyImport_ImportModule("__builtin__"), "instanceBuiltin");
}
return obj["cfg"]["invtypes"];
}
}
/// <summary>
/// Gets the Locations object reference
/// </summary>
internal EveObject Locations
{
get
{
EveObject obj;
if (!Objects.TryGetValue("evelocations", out obj))
{
obj = Builtin["cfg"]["evelocations"];
}
return obj;
}
}
// / <summary>
// /// Gets the LocalSvc object reference
// /// </summary>
// internal EveObject LocalSvc
// {
// get
// {
// EveObject obj;
// if (!Objects.TryGetValue("LocalSvc", out obj))
// {
//// obj = Builtin["eve"]["session"].CallMethod("ConnectToService", new object[] { "LocalSvc" }, true);
// obj = Builtin["eve"]["session"].CallMethod("ConnectToService", new object[] { "LocalSvc" }, true);
//
// }
// return obj;
// }
// }
/// <summary>
/// Gets the scanSvc object reference
/// </summary>
public EveObject ScanService
{
get
{
EveObject obj;
if (!Objects.TryGetValue("scanSvc", out obj))
{
obj = GetService("scanSvc");
}
return obj;
}
}
/// <summary>
/// Gets the uix object reference in the EVE CLient process
/// </summary>
internal EveObject Uix
{
get
{
EveObject obj;
if (!Objects.TryGetValue("uix", out obj))
{
obj = new EveObject(PyCall.PyImport_ImportModule("uix"), "uix");
}
return obj;
}
}
internal EveObject movementFunctions
{
get
{
EveObject obj;
if (!Objects.TryGetValue("eve.client.script.ui.services.menuSvcExtras.movementFunctions", out obj))
{
obj = new EveObject(PyCall.PyImport_ImportModule("eve.client.script.ui.services.menuSvcExtras.movementFunctions"), "eve.client.script.ui.services.menuSvcExtras.movementFunctions");
}
return obj;
}
}
internal EveObject menuSvcExtras
{
get
{
EveObject obj;
if (!Objects.TryGetValue("eve.client.script.ui.services.menuSvcExtras", out obj))
{
obj = new EveObject(PyCall.PyImport_ImportModule("eve.client.script.ui.services.menuSvcExtras"), "eve.client.script.ui.services.menuSvcExtras");
}
return obj;
}
}
/// <summary>
/// Gets the blue object reference in the EVE CLient process
/// </summary>
internal EveObject Blue
{
get
{
EveObject obj;
if (!Objects.TryGetValue("blue", out obj))
{
obj = new EveObject(PyCall.PyImport_ImportModule("blue"), "blue");
}
return obj;
}
}
/// <summary>
/// Gets a reference for a running service from the EVE Client process
/// </summary>
/// <param name="serviceName">Name of the service you are looking for, check IsValid property for valid references</param>
/// <returns></returns>
public EveObject GetService(string serviceName)
{
EveObject serviceObject;
if (!Services.GetDictionary<string>().TryGetValue(serviceName, out serviceObject))
// serviceObject = LocalSvc[serviceName];
serviceObject = Builtin["sm"]["services"].GetDictionary<string>()[serviceName];
if(!serviceObject.IsValid) {
// Frame.Log("not valid");
serviceObject = Builtin["sm"].CallMethod("GetService", new object[] { serviceName }, true);
}
return serviceObject;
}
EveSession _eveSession;
/// <summary>
/// Returns an EVE session object
/// </summary>
public EveSession Session
{
get
{
if (_eveSession == null)
_eveSession = new EveSession();
return _eveSession;
}
}
/// <summary>
/// Returns an EVE Login object
/// </summary>
EveLogin _login;
public EveLogin Login
{
get
{
if (_login == null)
_login = new EveLogin();
return _login;
}
}
/// <summary>
/// Returns a CharacterCreation object
/// </summary>
EveCharacterCreation _eveCharacterCreation;
public EveCharacterCreation CharCreation
{
get
{
if (_eveCharacterCreation == null)
_eveCharacterCreation = new EveCharacterCreation();
return _eveCharacterCreation;
}
}
/// <summary>
/// Returns an EVE Skills object
/// </summary>
EveSkills _skills;
public EveSkills Skills
{
get
{
if (_skills == null)
_skills = new EveSkills();
return _skills;
}
}
/// <summary>
/// Gets a reference for the invCache service form the EVE client process
/// </summary>
public EveObject InvCache
{
get
{
EveObject obj;
if (!Objects.TryGetValue("invCache", out obj))
{
obj = GetService("invCache");
}
return obj;
}
}
/// <summary>
/// Gets a reference for the menu service form the EVE client process
/// </summary>
public EveObject MenuService
{
get
{
EveObject obj;
if (!Objects.TryGetValue("menu", out obj))
{
obj = GetService("menu");
}
return obj;
}
}
/// <summary>
/// Gets a reference for the michelle service form the EVE client process
/// </summary>
public EveObject Michelle
{
get
{
EveObject obj;
if (!Objects.TryGetValue("michelle", out obj))
{
obj = GetService("michelle");
}
return obj;
}
}
/// <summary>
/// Gets a reference for the MarketQuote service form the EVE client process
/// </summary>
public EveObject MarketQuote
{
get
{
EveObject obj;
if (!Objects.TryGetValue("marketQuote", out obj))
{
obj = GetService("marketQuote");
}
return obj;
}
}
/// <summary>
/// Gets a reference for the map service form the EVE client process
/// </summary>
public EveObject MapService
{
get
{
EveObject obj;
if (!Objects.TryGetValue("map", out obj))
{
obj = GetService("map");
}
return obj;
}
}
/// <summary>
/// Gets a reference for the tactical service form the EVE client process
/// </summary>
public EveObject Tactical
{
get
{
EveObject obj;
if (!Objects.TryGetValue("tactical", out obj))
{
obj = GetService("tactical");
}
return obj;
}
}
/// <summary>
/// Gets a reference for the target service form the EVE client process
/// </summary>
public EveObject TargetManager
{
get
{
EveObject obj;
if (!Objects.TryGetValue("target", out obj))
{
obj = GetService("target");
}
return obj;
}
}
/// <summary>
/// Gets a reference for the LSC service form the EVE client process
/// </summary>
public EveObject LSCService
{
get
{
EveObject obj;
if (!Objects.TryGetValue("LSC", out obj))
{
obj = GetService("LSC");
}
return obj;
}
}
/// <summary>
/// Gets a reference for the godma service form the EVE client process
/// </summary>
public EveObject GodmaService
{
get
{
EveObject obj;
if (!Objects.TryGetValue("godma", out obj))
{
obj = GetService("godma");
}
return obj;
}
}
/// <summary>
/// Gets a reference for the station service form the EVE client process
/// </summary>
public EveObject StationService
{
get
{
EveObject obj;
if (!Objects.TryGetValue("station", out obj))
{
obj = GetService("station");
}
return obj;
}
}
/// <summary>
/// Gets a reference for the state service form the EVE client process
/// </summary>
public EveObject StateService
{
get
{
EveObject obj;
if (!Objects.TryGetValue("state", out obj))
{
obj = GetService("state");
}
return obj;
}
}
/// <summary>
/// Gets a reference for the addressbook service form the EVE client process
/// </summary>
public EveObject AddressBook
{
get
{
EveObject obj;
if (!Objects.TryGetValue("addressbook", out obj))
{
obj = GetService("addressbook");
}
return obj;
}
}
/// <summary>
/// Gets a reference for the station service form the EVE client process
/// </summary>
public EveObject BookmarkService
{
get
{
EveObject obj;
if (!Objects.TryGetValue("bookmarkSvc", out obj))
{
obj = GetService("bookmarkSvc");
}
return obj;
}
}
/// <summary>
/// Gets a reference for the eveowners object in the EVE client process
/// </summary>
internal EveObject EveOwners
{
get
{
EveObject obj;
if (!Objects.TryGetValue("eveowners", out obj))
{
obj = Builtin["cfg"]["eveowners"];
}
return obj;
}
}
/// <summary>
/// Gets a reference for the localization object in the EVE client process
/// </summary>
public EveObject Localization
{
get
{
EveObject obj;
if (!Objects.TryGetValue("localization", out obj))
{
obj = new EveObject(PyCall.PyImport_ImportModule("localization"), "localization");
}
return obj;
}
}
/// <summary>
/// Gets a reference for the const object in the EVE client process
/// </summary>
public EveObject Const
{
get
{
EveObject obj;
if (!Objects.TryGetValue("const", out obj))
{
obj = Builtin["const"];
}
return obj;
}
}
#endregion
#region Entities
/// <summary>
/// Cache for already referenced entities, will be cleared between every frame
/// </summary>
Dictionary<long, EveEntity> _entityDictionary;
/// <summary>
/// populates a dictionary with current entities
/// </summary>
void PopulateEntityDictionary()
{
var activeTargets = TargetManager["targetsByID"].GetDictionary<long>().Keys;
var beingTargeted = TargetManager["targeting"].GetDictionary<long>(); // Dictionary is <long, datetime> where datetime states when targeting started
var targetedBy = TargetManager["targetedBy"].GetList<long>();
var jammers = Frame.Client.Tactical["jammers"].GetDictionary<long>();
_entityDictionary = new Dictionary<long, EveEntity>();
var ballpark = GetService("michelle").CallMethod("GetBallpark", new object[] { });
var balls = ballpark["balls"];
if (!balls.IsValid)
{
return;
}
if(balls.IsNone){
Frame.Log("[PopulateEntityDictionary] balls.IsNone");
return;
}
List<long> ballKeyList = balls.CallMethod("keys", new object[0]).GetList<long>();
Frame.Log("ballKeyList.size: " + ballKeyList.Count.ToString());
foreach (long ballId in ballKeyList)
{
if (ballId > 0L)
{
if (!ballpark.IsValid) {
Frame.Log("ballpark not valid break");
break;
}
EveObject parent = ballpark.CallMethod("GetInvItem", new object[] { ballId });
if (parent.NotValidOrNone) {
Frame.Log("parent not valid break");
break;
}
EveItem item = new EveItem(parent);
EveObject ball = ballpark.CallMethod("GetBall", new object[] { ballId });
if(ball.IsNone || !ball.IsValid) {
Frame.Log("ball IsNone || not valid => continue");
continue;
}
EveEntity ent = new EveEntity(ball, item, ballId);
_entityDictionary.Add(ballId, ent);
ent.IsTarget = activeTargets.Contains(ballId);
ent.IsBeingTargeted = beingTargeted.Keys.Contains<long>(ballId);
ent.IsTargetingMe = targetedBy.Contains(ballId);
ent.IsActiveTarget = ballId == GetActiveTargetId;
ent.IsAbandoned = ballpark.CallMethod("IsAbandoned", new object[] { ballId }).GetValueAs<bool>();
ent.HaveLootRights = ballpark.CallMethod("HaveLootRight", new object[] { ballId }).GetValueAs<bool>();
ent.IsWreckEmpty = StateService.CallMethod("CheckWreckEmpty", new object[] { item }).GetValueAs<bool>();
ent.IsWreckAlreadyViewed = StateService.CallMethod("CheckWreckViewed", new object[] { item }).GetValueAs<bool>();
// if (jammers.ContainsKey(ballId))
// {
// foreach (var effect in jammers[ballId].GetDictionary<string>())
// {
// switch (effect.Key)
// {
// case "webify":
// ent.IsWebbingMe = true;
// break;
// case "ewTargetPaint":
// ent.IsTargetPaintingMe = true;
// break;
// case "warpScrambler":
// ent.IsWarpScramblingMe = true;
// break;
// case "ewEnergyNeut":
// ent.IsEnergyNeutingMe = true;
// break;
// case "ewEnergyVampire":
// ent.IsEnergyNOSingMe = true;
// break;
// case "electronic":
// ent.IsJammingMe = true;
// break;
// case "ewRemoteSensorDamp":
// ent.IsSensorDampeningMe = true;
// break;
// case "ewTrackingDisrupt":
// ent.IsTrackingDisruptingMe = true;
// break;
// default:
// break;
// }
// }
// }
}
}
}
/// <summary>
/// List of entities present in the current frame, returns null if pilot is not in space
/// </summary>
public List<EveEntity> Entities
{
get
{
if (!Session.InSpace)
return null;
if (_entityDictionary == null || _entityDictionary.Count == 0)
{
PopulateEntityDictionary();
}
return _entityDictionary.Values.ToList<EveEntity>();
}
}
#endregion
/// <summary>
/// Executes an EVE command, similiar to the keyboard shortcuts available int the client
/// </summary>
public void ExecuteCommand(EveCommand command)
{
GetService("cmd").CallMethod(command.ToString(), new object[0], true);
}
/// <summary>
/// Calls GetItem of the Godma Service
/// </summary>
public EveObject GetItem(EveItem eveItem){
EveObject obj;
if(!eveItem.IsValid)
return new EveObject();
obj = GodmaService.CallMethod("GetItem", new object[] { eveItem.ItemId },false );
return obj;
}
#region Navigation
/// <summary>
/// Gets the locationid of the last waypoint
/// </summary>
public long GetLastWaypointLocationId()
{
return GetService("starmap").CallMethod("GetDestinationPath", new object[0]).GetList<long>().Last();
}
/// <summary>
/// Gets the locationid of the next waypoint
/// </summary>
public long GetNextWaypointLocationId()
{
return GetService("starmap").CallMethod("GetDestinationPath", new object[0]).GetList<long>().First();
}
/// <summary>
/// Sets destionation to destinationId
/// </summary>
/// <param name="destinationId">Destination, can be solarsystemId or stationId</param>
public void SetDestination(long destinationId)
{
GetService("starmap").CallMethod("SetWaypoint", new object[] { destinationId, true, true }, true);
}
/// <summary>
/// Returns true if any waypoints has been set
/// </summary>
public bool IsWaypointsSet
{
get { return GetService("starmap").CallMethod("GetDestinationPath", new object[0]).IsValid; }
}
#endregion
#region Inventories
public bool IsUnifiedInventoryOpen
{
get { return GetPrimaryInventoryWindow != null; }
}
public List<EveInventoryWindow> InventoryWindows
{
get { return GetWindows.Where(w => w.Type == EveWindow.EveWindowType.Inventory).ToList<EveWindow>().ConvertAll<EveInventoryWindow>(new Converter<EveWindow, EveInventoryWindow>(EveWindow2EveInventoryWindow)); }
}
public EveInventoryWindow GetPrimaryInventoryWindow
{
get { return InventoryWindows.Where(w => w.IsPrimaryInvWindow).FirstOrDefault(); }
}
public EveWindow JournalWindow
{
get { return GetWindows.Where(w => w.Type == EveWindow.EveWindowType.Journal).FirstOrDefault(); }
}
public EveWindow WalletWindow
{
get { return GetWindows.Where(w => w.Type == EveWindow.EveWindowType.Wallet).FirstOrDefault(); }
}
public EveInventoryContainer GetCargoOfActiveShip()
{
return IsUnifiedInventoryOpen ? GetPrimaryInventoryWindow.CargoHoldOfActiveShip : null;
}
public EveInventoryContainer GetItemHangar()
{
return IsUnifiedInventoryOpen ? GetPrimaryInventoryWindow.ItemHangar : null;
}
public EveInventoryContainer GetShipHangar()
{
return IsUnifiedInventoryOpen ? GetPrimaryInventoryWindow.ShipHangar : null;
}
#endregion
#region Scanner
public EveWindow GetScannerWindow
{
get { return Frame.Client.GetWindows.Where(w => w.Type == EveWindow.EveWindowType.Scanner).FirstOrDefault(); }
}
public List<EveScanResult> GetScanResults
{
get
{
if (GetScannerWindow == null)
return null;
return ScanService.CallMethod("GetScanResults", new object[0]).GetList<EveObject>().ConvertAll<EveScanResult>(new Converter<EveObject, EveScanResult>(EveObject2EveScanResult));
}
}
public void Scan()
{
if (GetScannerWindow == null)
return;
if (Frame.Client.GetScannerWindow["sr"]["analyzeBtn"]["opacity"].GetValueAs<double>() == 0.25)
return;
Frame.Client.GetScannerWindow.CallMethod("Analyze", new object[0], true);
}
#endregion
public void BookmarkCurrentLocation(string name, string comment)
{
if (Frame.Client.Session.InSpace)
Frame.Client.BookmarkService.CallMethod("BookmarkLocation", new object[] { Frame.Client.GetActiveShip.ToEntity.Id, Frame.Client.Session.CharId, name, comment, Frame.Client.Session.SolarSystemId }, true, new Dictionary<string, object>());
}
public EveObject GetLocation(object[] parameters)
{
return new EveObject(Locations.CallMethod("GetIfExists", parameters).PointerToObject, "getlocation");
}
/// <summary>
/// Gets the string represetation of an id number, eg. station names
/// </summary>
public string GetLocationName(long id)
{
return new EveObject(Locations.CallMethod("GetIfExists", new object[] { id }).PointerToObject, null)["name"].GetValueAs<string>();
}
/// <summary>
/// Can only be called while in space
/// </summary>
/// <returns></returns>
public EveEntity GetNextWaypointStargate()
{
if (Session.InSpace)
{
var map = GetService("starmap").CallMethod("GetDestinationPath", new object[0]).GetList<long>();
var dest = GetLocationName(map.First());
return Entities.Where(e => e.Name == dest).FirstOrDefault();
}
else
return null;
}
/// <summary>
/// Returns an EVE Agent object
/// </summary>
/// <param name="agentName"></param>
/// <returns></returns>
// public EveAgent GetAgentByName(string agentName)
// {
// if (EveAgents == null)
// {
// return null;
// }
// var agentNameId = EveAgents.Where(a => a.Key.ToLower() == agentName.ToLower()).FirstOrDefault();
// if (agentNameId.Value == 0)
// {
// return null;
// }
// var eveagent = GetService("agents").CallMethod("GetAgentByID", new object[] { agentNameId.Value });
// return new EveAgent(eveagent.PointerToObject, agentNameId.Key);
// }
/// <summary>
/// Rteuns the id of your active (selected) target or -1 if you have no active target
/// </summary>
public long GetActiveTargetId
{
get { return TargetManager.CallMethod("GetActiveTargetID", new object[0]).GetValueAs<long>(); }
}
public List<EveAgentMission> AgentMissions
{
get
{
return GetService("journal")["agentjournal"].GetListFromTuple<EveObject>()[0].GetList<EveObject>().ConvertAll(new Converter<EveObject, EveAgentMission>(EveObject2EveAgentMission));
}
}
/// <summary>
/// Gets an invtype if it exists
/// </summary>
/// <param name="parameters"></param>
/// <returns></returns>
internal EveObject GetInvType(object[] parameters)
{
return new EveObject(InvTypes.CallMethod("GetIfExists", parameters).PointerToObject, "getinvtype");
}
/// <summary>
/// Gets the owner of an object, often represented by an id, eg. agentID
/// </summary>
/// <param name="parameters"></param>
/// <returns></returns>
internal EveObject GetOwner(object[] parameters)
{
return new EveObject(EveOwners.CallMethod("GetIfExists", parameters).PointerToObject, "getowners");
}
/// <summary>
/// Gets a list of windows from the EVE Client
/// </summary>
public List<EveWindow> GetWindows
{
get
{
EveObject obj = Builtin["uicore"]["registry"];
if (PyCall.PyErr_Occurred() != IntPtr.Zero) {
PyCall.PyErr_Clear();
}
return (obj.IsValid) ? Builtin["uicore"]["registry"].CallMethod("GetWindows", new object[0]).GetList<EveObject>().ConvertAll(new Converter<EveObject, EveWindow>(EveObject2EveWindow)) : new List<EveWindow>();
}
}
EveAgentDialogWindow _agentDialogWindow;
/// <summary>
/// Gets the dialog window og the provided agent
/// </summary>
/// <param name="agentId"></param>
/// <returns>EveAgentDialogWindow or Null</returns>
public EveAgentDialogWindow GetAgentDialogWindow(int agentId)
{
if (_agentDialogWindow == null)
_agentDialogWindow = GetWindows.Where(w => w.Type == EveWindow.EveWindowType.AgentDialog).ToList<EveWindow>().ConvertAll<EveAgentDialogWindow>(new Converter<EveWindow, EveAgentDialogWindow>(EveWindow2EveAgentDialogWindow)).Where(aw => aw.AgentId == agentId).FirstOrDefault();
return _agentDialogWindow;
}
public EveWindow GetFittingWindow
{
get
{
return this.GetWindows.Where(w => w.Type == EveWindow.EveWindowType.FittingWindow).FirstOrDefault();
}
}
public EveWindow GetMarketWindow
{
get
{
return this.GetWindows.Where(w => w.Type == EveWindow.EveWindowType.Market).FirstOrDefault();
}
}
public EveWindow GetCharacterSheet
{
get
{
return this.GetWindows.Where(w => w.Type == EveWindow.EveWindowType.CharacterSheet).FirstOrDefault();
}
}
public EveWindow GetMarketActionWindow
{
get
{
return this.GetWindows.Where(w => w.Type == EveWindow.EveWindowType.MarketActionWindow).FirstOrDefault();
}
}
EveActiveShip _activeship;
public EveActiveShip GetActiveShip
{
get
{
if (_activeship == null)
_activeship = new EveActiveShip(Frame.Client.GetService("clientDogmaIM")["dogmaLocation"].CallMethod("GetShip", new object[0]));
return _activeship;
}
}
EveMe _eveMe;
public EveMe EveMe
{
get
{
if (_eveMe == null)
_eveMe = new EveMe();
return _eveMe;
}
}
public EveChatWindow GetLocalChat
{
get
{
return Frame.Client.GetWindows.Where(w => w.WindowCaption == "Local").FirstOrDefault().ToChatWindow;
}
}
public EveChatWindow GetCorpChat
{
get
{
return Frame.Client.GetWindows.Where(w => w.WindowCaption == "Corp").FirstOrDefault().ToChatWindow;
}
}
public List<EveBookmark> GetMyBookmarks()
{
Dictionary<long, EveObject> bms;
//bms = Frame.Client.BookmarkService.CallMethod("GetMyBookmarks", new object[0]).GetDictionary<EveObject>();
//if (bms.Count == 0)
bms = Frame.Client.BookmarkService["bookmarkCache"].GetDictionary<long>();
//if (PyCall.PyErr_Occurred() != IntPtr.Zero)
// PyCall.PyErr_Clear();
return bms.Values.ToList<EveObject>().ConvertAll<EveBookmark>(EveObject2EveBookmark);
}
public List<EveEntity> GetSortedAsteroidBelts()
{
var list = Entities.Where(ent => ent.Group == Group.AsteroidBelt).ToList<EveEntity>();
list.Sort(CompareAsteroidBelts);
return list;
}
public List<EveEntity> GetNPCTargets()
{
return Entities.Where(
en => en.IsNpc &&
en.Distance < 125000 &&
en._item.Category == Category.Entity &&
en._item.Group != Group.LargeCollidableStructure &&
en._item.Group != Group.SpawnContainer &&
en._item.Group != Group.SentryGun &&
!en.HasExploded && en.IsValid
).OrderBy(en => en.Distance).ToList<EveEntity>();
}
// #region External Resources
// static string _innerspacePath = @"C:\Program Files (x86)\InnerSpace\.NET Programs";
// static System.Runtime.Serialization.Formatters.Binary.BinaryFormatter formatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
//
// static Dictionary<string, int> _eveAgentAndIds;
// public static Dictionary<string, int> EveAgents
// {
// get
// {
// if (_eveAgentAndIds == null)
// {
// Frame.Log("Trying to load agents");
// if (System.IO.File.Exists(_innerspacePath + @"\agents.bin"))
// {
// using (System.IO.FileStream stream = System.IO.File.OpenRead(_innerspacePath + @"\agents.bin"))
// {
// _eveAgentAndIds = (Dictionary<string, int>)formatter.Deserialize(stream);
// Frame.Log("Succesfully loaded agents");
// }
// }