|
25 | 25 | import com.bladecoder.engine.model.World;
|
26 | 26 | import com.bladecoder.engine.util.ActionUtils;
|
27 | 27 | import com.bladecoder.engine.util.EngineLogger;
|
| 28 | +import com.bladecoder.engine.util.PolygonUtils; |
28 | 29 |
|
29 | 30 | @ActionDescription(name = "IfActorAttr", value = "Execute the actions inside the If/EndIf if the attribute has the specified value.")
|
30 | 31 | public class IfAttrAction extends AbstractIfAction {
|
@@ -58,14 +59,13 @@ public boolean run(VerbRunner cb) {
|
58 | 59 | Scene s = actor.getScene(w);
|
59 | 60 |
|
60 | 61 | final String actorId = actor.getActorId();
|
61 |
| - if (actorId == null) { |
62 |
| - // if called inside a scene verb and no actor is specified, return |
63 |
| - EngineLogger.error(getClass() + ": No actor specified"); |
| 62 | + BaseActor a = s.getActor(actorId, true); |
| 63 | + |
| 64 | + if (a == null) { |
| 65 | + EngineLogger.error(getClass() + "- No not found: " + actorId); |
64 | 66 | return false;
|
65 | 67 | }
|
66 | 68 |
|
67 |
| - BaseActor a = s.getActor(actorId, true); |
68 |
| - |
69 | 69 | if (attr.equals(ActorAttribute.STATE) && a instanceof InteractiveActor) {
|
70 | 70 | InteractiveActor ia = (InteractiveActor) a;
|
71 | 71 | if (!ActionUtils.compareNullStr(value, ia.getState())) {
|
@@ -153,12 +153,13 @@ public boolean run(VerbRunner cb) {
|
153 | 153 | }
|
154 | 154 | } else if (attr.equals(ActorAttribute.INSIDE)) {
|
155 | 155 | BaseActor insideActor = w.getCurrentScene().getActor(value, false);
|
156 |
| - boolean inside = false; |
157 | 156 |
|
158 |
| - if (a != null && insideActor != null) |
159 |
| - inside = insideActor.getBBox().contains(a.getX(), a.getY()); |
160 |
| - else |
| 157 | + if (insideActor == null) { |
161 | 158 | EngineLogger.debug("Actor for inside test not found: " + value);
|
| 159 | + return false; |
| 160 | + } |
| 161 | + |
| 162 | + boolean inside = PolygonUtils.isPointInside(insideActor.getBBox(), a.getX(), a.getY(), true); |
162 | 163 |
|
163 | 164 | if (!inside) {
|
164 | 165 | gotoElse(cb);
|
|
0 commit comments