Starsector API
Loading...
Searching...
No Matches
HitArea.java
Go to the documentation of this file.
1package com.fs.starfarer.api.impl.campaign.eventide;
2
3public class HitArea implements Cloneable {
4 public float x, y, w, h;
5
6 protected HitArea clone() {
7 try {
8 HitArea copy = (HitArea) super.clone();
9 return copy;
10 } catch (CloneNotSupportedException e) {
11 throw new RuntimeException(e);
12 }
13 }
14
16 HitArea copy = new HitArea();
17 float sign = action.actor.facing;
18
19 copy.x = action.actor.loc.x + x * action.anim.scale * sign;
20 copy.y = action.actor.loc.y + y * action.anim.scale;
21 copy.h = h * action.anim.scale;
22 if (sign > 0) {
23 copy.w = w * action.anim.scale;
24 } else {
25 copy.x = action.actor.loc.x + x * action.anim.scale * sign - w * action.anim.scale;
26 copy.w = w * action.anim.scale;
27 }
28
29
30 return copy;
31
32 }
33
34 public boolean intersects(HitArea other) {
35 if (x > other.x + other.w) return false;
36 if (x + w < other.x) return false;
37 if (y > other.y + other.h) return false;
38 if (y + h < other.y) return false;
39 return true;
40 }
41}
HitArea getAdjustedForAction(AnimAction action)
Definition HitArea.java:15