Starsector API
Loading...
Searching...
No Matches
CampaignEventTarget.java
Go to the documentation of this file.
1package com.fs.starfarer.api.campaign.events;
2
3import org.lwjgl.util.vector.Vector2f;
4
5import com.fs.starfarer.api.campaign.FactionAPI;
6import com.fs.starfarer.api.campaign.LocationAPI;
7import com.fs.starfarer.api.campaign.SectorEntityToken;
8import com.fs.starfarer.api.campaign.econ.MarketAPI;
9
10public class CampaignEventTarget {
11
12 private Object custom;
13 private LocationAPI location;
14 private SectorEntityToken entity;
15 private Object extra;
16
24 public CampaignEventTarget(Object custom) {
25 this.custom = custom;
26 }
27
28 public CampaignEventTarget(MarketAPI market) {
29 this(market.getPrimaryEntity());
30 }
31
33 this.location = entity.getContainingLocation();
34 this.entity = entity;
35 }
36
38 this.location = location;
39 }
40
41 public MarketAPI getMarket() {
42 if (entity != null) return entity.getMarket();
43 return null;
44 }
45
46 public Vector2f getLocationInHyperspace() {
47 boolean inHyper = location.isHyperspace();
48 Vector2f locInHyper = inHyper && entity != null ? entity.getLocation() : location.getLocation();
49 return locInHyper;
50 }
51
52
54 return location;
55 }
56
57 public void setLocation(LocationAPI location) {
58 this.location = location;
59 }
60
62 return entity;
63 }
64
65 public void setEntity(SectorEntityToken entity) {
66 this.entity = entity;
67 }
68
69 public Object getCustom() {
70 return custom;
71 }
72
73 public void setCustom(Object custom) {
74 this.custom = custom;
75 }
76
77
78 public Object getExtra() {
79 return extra;
80 }
81
82 public void setExtra(Object extra) {
83 this.extra = extra;
84 }
85
86 // @Override
87// public int hashCode() {
88// final int prime = 31;
89// int result = 1;
90// result = prime * result + ((entity == null) ? 0 : entity.hashCode());
91// result = prime * result
92// + ((location == null) ? 0 : location.hashCode());
93// return result;
94// }
95//
96//
97// @Override
98// public boolean equals(Object obj) {
99// if (this == obj)
100// return true;
101// if (obj == null)
102// return false;
103// if (getClass() != obj.getClass())
104// return false;
105// CampaignEventTarget other = (CampaignEventTarget) obj;
106// if (entity == null) {
107// if (other.entity != null)
108// return false;
109// } else if (entity != other.entity)
110// return false;
111// if (location == null) {
112// if (other.location != null)
113// return false;
114// } else if (location != other.location)
115// return false;
116// return true;
117// }
118 @Override
119 public int hashCode() {
120 final int prime = 31;
121 int result = 1;
122 if (custom != null) {
123 result = prime * result + ((custom == null) ? 0 : custom.hashCode());
124 } else {
125 result = prime * result + ((entity == null) ? 0 : entity.hashCode());
126 result = prime * result + ((location == null) ? 0 : location.hashCode());
127 result = prime * result + ((extra == null) ? 0 : extra.hashCode());
128
129 }
130 return result;
131 }
132
133 @Override
134 public boolean equals(Object obj) {
135 if (this == obj)
136 return true;
137 if (obj == null)
138 return false;
139 if (getClass() != obj.getClass())
140 return false;
142 if (custom != null && custom.equals(other.custom)) {
143 return true;
144 }
145
146 if (custom == null) {
147 if (other.custom != null)
148 return false;
149 } else if (!custom.equals(other.custom))
150 return false;
151 if (entity == null) {
152 if (other.entity != null)
153 return false;
154 } else if (entity != other.entity)
155 return false;
156 if (location == null) {
157 if (other.location != null)
158 return false;
159 } else if (location != other.location)
160 return false;
161 if (extra == null) {
162 if (other.extra != null)
163 return false;
164 } else if (!extra.equals(other.extra))
165 return false;
166 return true;
167 }
168
169
170
172 if (entity != null) {
173 return entity.getFaction();
174 }
175 return null;
176 }
177}