-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSimcraftProxies.cs
More file actions
1021 lines (877 loc) · 33.7 KB
/
SimcraftProxies.cs
File metadata and controls
1021 lines (877 loc) · 33.7 KB
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
#region Honorbuddy
#endregion
#region System
using System;
using System.Collections.Generic;
using System.Dynamic;
using System.Linq;
using System.Windows.Media;
using System.Windows.Navigation;
using Bots.DungeonBuddy.Helpers;
using Styx;
using Styx.Common;
using Styx.CommonBot;
using Styx.TreeSharp;
using Styx.WoWInternals;
using Styx.WoWInternals.WoWObjects;
using Action = Styx.TreeSharp.Action;
#endregion
namespace Simcraft
{
public partial class SimcraftImpl
{
public class CacheInternal
{
protected Dictionary<WoWGuid, ProxyCacheEntry> _cache = new Dictionary<WoWGuid, ProxyCacheEntry>();
public class ProxyCacheEntry : DynamicObject
{
private readonly Dictionary<String, object> _values = new Dictionary<string, object>();
public override bool TryGetMember(
GetMemberBinder binder, out object result)
{
// Converting the property name to lowercase
// so that property names become case-insensitive.
var name = binder.Name.ToLower();
// If the property name is found in a dictionary,
// set the result parameter to the property value and return true.
// Otherwise, return false.
if (!_values.ContainsKey(name)) _values[name] = new CacheValue();
return _values.TryGetValue(name, out result);
}
public class CacheValue
{
public CacheValue()
{
Ite = -1;
}
public int Ite { get; set; }
public object Value { get; set; }
}
}
}
public class ActionProxy : DynamicObject
{
private readonly Dictionary<string, object> itemsByName = new Dictionary<string, object>();
public ActionImpl Selector = new ActionImpl("base");
public ActionImpl this[String name]
{
get
{
if (!itemsByName.ContainsKey(name)) itemsByName.Add(name, new ActionImpl(name));
return (ActionImpl) itemsByName[name];
}
set { itemsByName[name] = value; }
}
public void Reset()
{
Selector.Children.Clear();
itemsByName.Clear();
}
public override bool TryGetMember(
GetMemberBinder binder, out object result)
{
// Converting the property name to lowercase
// so that property names become case-insensitive.
var name = binder.Name.ToLower();
// If the property name is found in a dictionary,
// set the result parameter to the property value and return true.
// Otherwise, return false.
return itemsByName.TryGetValue(name, out result);
}
// If you try to set a value of a property that is
// not defined in the class, this method is called.
public override bool TrySetMember(
SetMemberBinder binder, object value)
{
// Converting the property name to lowercase
// so that property names become case-insensitive.
itemsByName[binder.Name.ToLower()] = value;
// You can always add a value to a dictionary,
// so this method always returns true.
return true;
}
public static ActionProxy operator +(ActionProxy h1, Composite val)
{
h1.Selector.AddChild(val);
return h1;
}
public class ActionImpl : PrioritySelector
{
public static String oocapl = "out_of_combat";
public PrioritySelector Content = new PrioritySelector();
private PrioritySelector End = new PrioritySelector();
private PrioritySelector Enter = new PrioritySelector();
private String name;
public ActionImpl(String name)
{
this.name = name;
AddChild(new Action(delegate
{
//Logging.Write(DateTime.Now + ": Entering " + name+ " "+Children.Count);
Lua.DoString("_G[\"apl\"] = \"" + name.Replace("_", " ") + "\";");
if (name.Equals(oocapl)) ooc = DateTime.Now;
return RunStatus.Failure;
}));
//AddChild(Content);
//AddChild(new Action(delegate { }));
}
public static ActionImpl operator +(ActionImpl h1, Composite val)
{
h1.AddChild(val);
return h1;
}
}
}
public class BuffProxy : Proxy
{
public static int cShots;
private readonly Dictionary<int, BuffInternal> itemsById = new Dictionary<int, BuffInternal>();
private readonly Dictionary<string, BuffInternal> itemsByName = new Dictionary<string, BuffInternal>();
public BuffProxy(GetUnitDelegate del, SimcraftImpl simc)
: base(del, simc)
{
}
public bool Pre_Steady_Focus
{
get { return cShots == 1; }
}
public BuffInternal this[String name]
{
get
{
if (!itemsByName.ContainsKey(name)) itemsByName.Add(name, new BuffInternal(name));
return itemsByName[name];
}
}
public BuffInternal this[int id]
{
get
{
if (!itemsById.ContainsKey(id)) itemsById.Add(id, new BuffInternal(id));
return itemsById[id];
}
}
public class BuffInternal : CacheInternal
{
private readonly string _name;
private readonly int spellid;
private double _remains;
private int _stack;
private bool _up;
private int lastIteRemains = -1;
private int lastIteStack = -1;
private int lastIteUp = -1;
public BuffInternal(string name)
{
_name = name;
}
public BuffInternal(int spellid)
{
this.spellid = spellid;
}
public bool down
{
get { return !up; }
}
public bool up
{
get
{
if (lastIteUp + iterationCache < iterationCounter || lastIteUp > iterationCounter)
{
_up =
spellid == 0
? !Lua.GetReturnVal<bool>(
"name, rank, icon, count, debuffType, duration, expirationTime, unitCaster, isStealable, shouldConsolidate, spellId = UnitAura(\"player\", \"" +
_name + "\"); return name == nil", 0)
: !Lua.GetReturnVal<bool>(
"name, rank, icon, count, debuffType, duration, expirationTime, unitCaster, isStealable, shouldConsolidate, spellId = UnitAura(\"player\", \"" +
spellid + "\"); return name == nil", 0);
lastIteUp = iterationCounter;
}
return _up;
}
}
public double remains
{
get
{
if (lastIteRemains + iterationCache < iterationCounter || lastIteRemains > iterationCounter)
{
_remains = spellid == 0
? GetAuraTimeLeft(StyxWoW.Me.ToUnit(), _name).TotalSeconds
: GetAuraTimeLeft(StyxWoW.Me.ToUnit(), spellid).TotalSeconds;
lastIteRemains = iterationCounter;
}
return _remains;
}
}
public int Stack
{
get
{
if (lastIteStack + iterationCache < iterationCounter || lastIteStack > iterationCounter)
{
_stack = spellid == 0
? GetAuraStacks(StyxWoW.Me.ToUnit(), _name)
: GetAuraStacks(StyxWoW.Me.ToUnit(), spellid);
lastIteStack = iterationCounter;
}
return _stack;
}
}
public bool react
{
get { return remains > 0.1; }
}
}
}
public class CooldownProxy : Proxy
{
private readonly Dictionary<int, CooldownInternal> itemsById = new Dictionary<int, CooldownInternal>();
private readonly Dictionary<string, CooldownInternal> itemsByName =
new Dictionary<string, CooldownInternal>();
public CooldownProxy(GetUnitDelegate del, SimcraftImpl simc)
: base(del, simc)
{
}
public CooldownInternal this[String name]
{
get
{
if (!itemsByName.ContainsKey(name)) itemsByName.Add(name, new CooldownInternal(name));
return itemsByName[name];
}
}
public CooldownInternal this[int id]
{
get
{
if (!itemsById.ContainsKey(id)) itemsById.Add(id, new CooldownInternal(id));
return itemsById[id];
}
}
public class CooldownInternal : CacheInternal
{
private readonly string _name;
private readonly int spellid;
private double _remains;
private bool _up;
private int lastIteRemains = -1;
private int lastIteUp = -1;
public CooldownInternal(string name)
{
_name = name;
}
public CooldownInternal(int spellid)
{
this.spellid = spellid;
}
public bool Down
{
get { return !up; }
}
public bool up
{
get
{
return remains < 1.5;
_up =
spellid == 0
? !GetSpellOnCooldown(_name)
: !GetSpellOnCooldownId(spellid);
lastIteUp = iterationCounter;
return _up;
}
}
public double remains
{
get
{
_remains = spellid == 0
? GetSpellCooldown(_name).TotalSeconds
: GetSpellCooldownId(spellid).TotalSeconds;
lastIteRemains = iterationCounter;
return _remains;
}
}
public bool React
{
get { return up; }
}
}
}
public class SpellProxy : Proxy
{
private readonly Dictionary<int, SpellInternal> itemsById = new Dictionary<int, SpellInternal>();
private readonly Dictionary<string, SpellInternal> itemsByName = new Dictionary<string, SpellInternal>();
public SpellProxy(GetUnitDelegate del, SimcraftImpl simc)
: base(del, simc)
{
}
public SpellInternal this[String name]
{
get
{
if (!itemsByName.ContainsKey(name)) itemsByName.Add(name, new SpellInternal(name));
return itemsByName[name];
}
}
public SpellInternal this[int id]
{
get
{
if (!itemsById.ContainsKey(id)) itemsById.Add(id, new SpellInternal(id));
return itemsById[id];
}
}
public void Reset()
{
itemsByName.Clear();
itemsById.Clear();
}
public class SpellInternal : CacheInternal
{
private readonly bool _hasMe;
private readonly string _name;
private readonly int spellid;
private double _castime;
private double _channeltime;
private int _charges;
private double _rechargeTime;
private int lastIteCasttime = -1;
private int lastIteChanneltime = -1;
private int lastIteCharges = -1;
private int lastIteRecharge = -1;
public SpellInternal(string name)
{
_name = name;
_hasMe = SpellManager.HasSpell(name);
Logging.Write(_hasMe ? Colors.Green : Colors.Red, (_hasMe ? "Found " : "Missing ") + name);
}
public SpellInternal(int spellid)
{
this.spellid = spellid;
_hasMe = SpellManager.HasSpell(spellid);
}
public double Range
{
get
{
var spell = spellid == 0
? GetSpell(_name)
: GetSpell(spellid);
return spell.HasRange ? spell.MaxRange : Me.CombatReach+5;
}
}
public int Charges
{
get
{
if (!_hasMe) return 0;
if (lastIteCharges + iterationCache < iterationCounter || lastIteCharges > iterationCounter)
{
_charges = spellid == 0
? Lua.GetReturnVal<int>(
"currentCharges,_,_,_,_ = GetSpellCharges(\"" + _name + "\"); return currentCharges",
0)
: Lua.GetReturnVal<int>(
"currentCharges,_,_,_,_ = GetSpellCharges(" + spellid + "); return currentCharges",
0);
lastIteCharges = iterationCounter;
}
return _charges;
}
}
public double CastTime
{
get
{
if (!_hasMe) return 0;
if (lastIteCasttime + iterationCache < iterationCounter || lastIteCasttime > iterationCounter)
{
_castime = spellid == 0
? (double) GetSpell(_name).CastTime/1000
: (double) GetSpell(spellid).CastTime/1000;
lastIteCasttime = iterationCounter;
}
return _castime;
}
}
public double ChannelTime
{
get
{
if (!_hasMe) return 0;
if (lastIteChanneltime + iterationCache < iterationCounter ||
lastIteChanneltime > iterationCounter)
{
_channeltime = spellid == 0
? (double) GetSpell(_name).BaseDuration/1000
: (double) GetSpell(spellid).BaseDuration/1000;
lastIteChanneltime = iterationCounter;
}
return _channeltime;
}
}
public double RechargeTime
{
get
{
if (!_hasMe) return 0;
if (lastIteRecharge + iterationCache < iterationCounter || lastIteRecharge > iterationCounter)
{
_rechargeTime = spellid == 0
? Lua.GetReturnVal<double>(
"currentCharges, maxCharges, cooldownStart, cooldownDuration = GetSpellCharges(\"" +
_name +
"\"); cd = (cooldownDuration-(GetTime()-cooldownStart)); if (cd > cooldownDuration or cd < 0) then cd = 0; end return cd",
0)
: Lua.GetReturnVal<double>(
"currentCharges, maxCharges, cooldownStart, cooldownDuration = GetSpellCharges(\"" +
spellid +
"\"); cd = (cooldownDuration-(GetTime()-cooldownStart)); if (cd > cooldownDuration or cd < 0) then cd = 0; end return cd",
0);
lastIteRecharge = iterationCounter;
}
return _rechargeTime;
}
}
}
}
public class TargetProxy : Proxy
{
public HealthProxy health;
public TargetProxy(GetUnitDelegate del, SimcraftImpl simc)
: base(del, simc)
{
health = new HealthProxy(() => GetUnit(), simc);
}
public double time_to_die
{
get { return health.TimeToDie; }
}
public bool melee_range
{
get { return GetUnit().IsWithinMeleeRange; }
}
public bool facing
{
get { return Me.IsFacing(GetUnit()); }
}
public WoWPoint Location
{
get { return GetUnit().Location; }
}
}
public class DebuffProxy : Proxy
{
private readonly Dictionary<int, DebuffInternal> DebuffsById = new Dictionary<int, DebuffInternal>();
private readonly Dictionary<string, DebuffInternal> DebuffsByName = new Dictionary<string, DebuffInternal>();
public DebuffProxy(GetUnitDelegate del, SimcraftImpl simc)
: base(del, simc)
{
}
public DebuffInternal this[String name]
{
get
{
if (!DebuffsByName.ContainsKey(name)) DebuffsByName.Add(name, new DebuffInternal(name, this));
return DebuffsByName[name];
}
}
public DebuffInternal this[int id]
{
get
{
if (!DebuffsById.ContainsKey(id)) DebuffsById.Add(id, new DebuffInternal(id, this));
return DebuffsById[id];
}
}
public class DebuffInternal : CacheInternal
{
private readonly string _name;
private readonly DebuffProxy _owner;
private readonly int spellid;
public DebuffInternal(string name, DebuffProxy owner)
{
_name = name;
_owner = owner;
}
public DebuffInternal(int spellid, DebuffProxy owner)
{
this.spellid = spellid;
_owner = owner;
}
public bool down
{
get { return !Up; }
}
public bool Up
{
get
{
var guid = _owner.GetUnit().Guid;
if (!_cache.ContainsKey(guid)) _cache[guid] = new ProxyCacheEntry();
dynamic cach = _cache[guid];
if (cach.Up.Ite + iterationCache < iterationCounter || cach.Up.Ite > iterationCounter)
{
cach.Up.Value =
spellid == 0
? GetAuraUp(_owner.GetUnit(), _name, true)
: GetAuraUp(_owner.GetUnit(), spellid, true);
cach.Up.Ite = iterationCounter;
}
return cach.Up.Value;
}
}
public double remains
{
get
{
var guid = _owner.GetUnit().Guid;
if (!_cache.ContainsKey(guid)) _cache[guid] = new ProxyCacheEntry();
dynamic cach = _cache[guid];
if (cach.remains.Ite + iterationCache < iterationCounter || cach.remains.Ite > iterationCounter)
{
cach.remains.Value = spellid == 0
? GetAuraTimeLeft(_owner.GetUnit(), _name, true).TotalSeconds
: GetAuraTimeLeft(_owner.GetUnit(), spellid, true).TotalSeconds;
cach.remains.Ite = iterationCounter;
}
return cach.remains.Value;
}
}
public int Stack
{
get
{
var guid = _owner.GetUnit().Guid;
if (!_cache.ContainsKey(guid)) _cache[guid] = new ProxyCacheEntry();
dynamic cach = _cache[guid];
if (cach.stack.Ite + iterationCache < iterationCounter || cach.stack.Ite > iterationCounter)
{
cach.stack.Value = spellid == 0
? GetAuraStacks(_owner.GetUnit(), _name, true)
: GetAuraStacks(_owner.GetUnit(), spellid, true);
cach.stack.Ite = iterationCounter;
}
return cach.stack.Value;
}
}
public bool Ticking
{
get { return Up; }
}
}
}
public class TalentProxy : Proxy
{
private readonly Dictionary<String, Talent> _talents = new Dictionary<string, Talent>();
public TalentProxy(GetUnitDelegate del, SimcraftImpl simc)
: base(del, simc)
{
}
public Talent this[String name]
{
get
{
if (!_talents.ContainsKey(name)) _talents.Add(name, new Talent(name));
return _talents[name];
}
}
public void Reset()
{
_talents.Clear();
}
public class Talent
{
private readonly string _name;
private bool? _enabled;
public Talent(string name)
{
_name = name;
}
public bool enabled
{
get
{
if (_enabled == null) _enabled = StyxWoW.Me.GetLearnedTalents().Count(a => a.Name == _name) > 0;
return _enabled.Value;
}
}
}
}
/*public static class WoWUnit
{
{
Health = new HealthProxy(del, simc);
}
public HealthProxy Health;// = new HealthProxy(GetUnit, simc);
public int TimeToDie = 3600;
}*/
public abstract class Proxy
{
public delegate WoWUnit GetUnitDelegate();
protected GetUnitDelegate GetUnit;
protected int lastIte = 0;
protected SimcraftImpl simc;
public Proxy(GetUnitDelegate del, SimcraftImpl simc)
{
GetUnit = del;
this.simc = simc;
}
}
public abstract class ResourceProxy : Proxy
{
private double _crt;
private double _max;
private double _pct;
private int lastIteCrt = -1;
private int lastIteMax = -1;
private int lastItePct = -1;
public ResourceProxy(GetUnitDelegate del, SimcraftImpl simc) : base(del, simc)
{
}
public double time_to_max
{
get { return deficit/Regen; }
}
public double pct
{
get
{
if (lastItePct + iterationCache < iterationCounter || lastItePct > iterationCounter)
{
_pct = GetPercent;
lastItePct = iterationCounter;
}
return _pct;
}
}
public double Current
{
get
{
if (lastIteCrt + iterationCache < iterationCounter || lastIteCrt > iterationCounter)
{
_crt = GetCurrent;
lastIteCrt = iterationCounter;
}
return _crt;
}
}
public double Max
{
get
{
if (lastIteMax + iterationCache < iterationCounter || lastIteMax > iterationCounter)
{
_max = GetMax;
lastIteMax = iterationCounter;
}
return _max;
}
}
public abstract double GetPercent { get; }
public abstract int GetMax { get; }
public abstract int GetCurrent { get; }
public int deficit
{
get { return GetUnit() != null ? (int) (Max - Current) : 0; }
}
public double Regen { get; private set; }
public double Cast_Regen(double seconds)
{
return Regen*seconds;
}
public static bool operator <(ResourceProxy h1, double val)
{
return h1.GetUnit() != null && h1.Current < val;
}
public static bool operator >(ResourceProxy h1, double val)
{
return h1.GetUnit() != null && h1.Current > val;
}
public static bool operator <=(ResourceProxy h1, double val)
{
return h1.GetUnit() != null && h1.Current <= val;
}
public static bool operator >=(ResourceProxy h1, double val)
{
return h1.GetUnit() != null && h1.Current >= val;
}
public static bool operator !=(ResourceProxy h1, double val)
{
return h1.GetUnit() != null ? h1.Current != val : false;
}
public static bool operator ==(ResourceProxy h1, double val)
{
return h1.GetUnit() != null ? h1.Current == val : false;
}
public static double operator -(double val, ResourceProxy h1)
{
return h1.GetUnit() != null ? val - h1.Current : 0;
}
public static double operator -(ResourceProxy h1, double val)
{
return h1.GetUnit() != null ? h1.Current - val : 0;
}
public static double operator +(double val, ResourceProxy h1)
{
return h1.GetUnit() != null ? val + h1.Current : 0;
}
public static double operator +(ResourceProxy h1, double val)
{
return h1.GetUnit() != null ? val + h1.Current : 0;
}
public static double operator *(double val, ResourceProxy h1)
{
return h1.GetUnit() != null ? val*h1.Current : 0;
}
public static double operator *(ResourceProxy h1, double val)
{
return h1.GetUnit() != null ? val*h1.Current : 0;
}
public override bool Equals(object obj)
{
if (!(obj is ResourceProxy)) return false;
return ((ResourceProxy) obj).Current == Current;
}
public override int GetHashCode()
{
return base.GetHashCode();
}
public void Pulse()
{
Regen = Lua.GetReturnVal<double>(
"inactiveRegen, activeRegen = GetPowerRegen(); return activeRegen;", 0);
}
}
public class HealthProxy : ResourceProxy
{
public static int AVG_DPS = 22000;
public HealthProxy(GetUnitDelegate del, SimcraftImpl simc)
: base(del, simc)
{
}
public override double GetPercent
{
get { return GetUnit().HealthPercent; }
}
public override int GetCurrent
{
get { return GetUnit() != null ? (int) (GetUnit().CurrentHealth) : 0; }
}
public override int GetMax
{
get { return GetUnit() != null ? (int) (GetUnit().MaxHealth) : 0; }
}
public double TimeToDie
{
get
{
var g = (int) StyxWoW.Me.GroupInfo.GroupSize;
if (g > 0)
return GetCurrent/(StyxWoW.Me.GroupInfo.GroupSize*0.6*AVG_DPS);
return GetCurrent/(AVG_DPS);
}
}
}
public class ComboPointProxy : ResourceProxy
{
public ComboPointProxy(GetUnitDelegate del, SimcraftImpl simc)
: base(del, simc)
{
}
public override double GetPercent
{
get { return 0; }
}
public override int GetCurrent
{
get { return GetUnit() != null ? StyxWoW.Me.ComboPoints : 0; }
}
public override int GetMax
{
get { return 5; }
}
}
public class ChiProxy : ResourceProxy
{
public ChiProxy(GetUnitDelegate del, SimcraftImpl simc)
: base(del, simc)
{
}
public override int GetMax
{
get { return (int) GetUnit().MaxChi; }
}
public override int GetCurrent
{
get { return (int) GetUnit().CurrentChi; }
}
public override double GetPercent
{
get { return 0; }
}
}
public class EnergyProxy : ResourceProxy
{
public EnergyProxy(GetUnitDelegate del, SimcraftImpl simc)
: base(del, simc)
{
}
public override double GetPercent
{
get { return StyxWoW.Me.EnergyPercent; }
}
public override int GetMax
{
get { return GetUnit() != null ? (int) (GetUnit().MaxEnergy) : 0; }
}
public override int GetCurrent
{
get { return GetUnit() != null ? (int) (GetUnit().CurrentEnergy) : 0; }
}
}
public class FocusProxy : ResourceProxy
{
public FocusProxy(GetUnitDelegate del, SimcraftImpl simc)
: base(del, simc)
{
}
public override double GetPercent
{
get { return StyxWoW.Me.FocusPercent; }
}
public override int GetMax
{
get { return GetUnit() != null ? (int) (GetUnit().MaxFocus) : 0; }
}
public override int GetCurrent
{
get { return GetUnit() != null ? (int) (GetUnit().CurrentFocus) : 0; }
}
}
public class RageProxy : ResourceProxy
{
public RageProxy(GetUnitDelegate del, SimcraftImpl simc)