1 package cz.cuni.amis.pogamut.udk.bot;
2
3 import java.io.Serializable;
4 import java.lang.reflect.Field;
5 import java.lang.reflect.Method;
6
7 import cz.cuni.amis.pogamut.udk.communication.messages.gbinfomessages.ConfigChange;
8 import cz.cuni.amis.pogamut.unreal.bot.IUnrealBot;
9
10
11
12
13
14 public interface IUDKBot extends IUnrealBot {
15
16 public static enum BoolBotParam implements Serializable {
17
18
19 AUTO_PICKUP_OFF,
20 INVULNERABLE,
21 SHOW_DEBUG,
22 AUTO_TRACE,
23 DRAW_TRACE_LINES,
24 MANUAL_SPAWN,
25 SHOW_FOCAL_POINT,
26 SYNCHRONOUS_OFF;
27 String propertyName = null;
28
29
30
31
32
33 public String getPropName() {
34 if (propertyName == null) {
35 String name = name();
36 boolean upperFlag = true;
37
38 StringBuilder builder = new StringBuilder();
39 for (int i = 0; i < name.length(); i++) {
40 char ch = name.charAt(i);
41 if (ch == '_') {
42 upperFlag = true;
43 continue;
44 }
45 if (!upperFlag) {
46 ch = Character.toLowerCase(ch);
47 } else {
48 upperFlag = false;
49 }
50
51 builder.append(ch);
52 }
53 propertyName = builder.toString();
54 }
55 return propertyName;
56 }
57
58 public void set(Object conf, boolean value) throws Exception {
59 Method m = conf.getClass().getMethod("set" + getPropName(), Boolean.TYPE);
60 m.invoke(conf, value);
61 }
62
63 public void setField(Object conf, boolean value) throws Exception {
64 Field f = conf.getClass().getDeclaredField(getPropName());
65 f.setAccessible(true);
66 f.set(conf, value);
67 }
68
69 public boolean get(ConfigChange conf) throws Exception {
70 Method m = conf.getClass().getMethod("is" + getPropName());
71 return (Boolean) m.invoke(conf, new Object[0]);
72 }
73 }
74
75
76
77
78
79
80 public void setBoolConfigure(BoolBotParam param, boolean value);
81
82
83
84
85
86
87 public boolean getBoolConfigure(BoolBotParam param);
88 }