TModLoader v1.4.4.9
TModLoader source code documentation
Loading...
Searching...
No Matches

◆ TryGoingThroughPortals()

static void Terraria.GameContent.PortalHelper.TryGoingThroughPortals ( Entity ent)
inlinestatic

Definition at line 124 of file PortalHelper.cs.

125 {
126 //IL_000f: Unknown result type (might be due to invalid IL or missing references)
127 //IL_00d0: Unknown result type (might be due to invalid IL or missing references)
128 //IL_00e8: Unknown result type (might be due to invalid IL or missing references)
129 //IL_00ee: Unknown result type (might be due to invalid IL or missing references)
130 //IL_00f3: Unknown result type (might be due to invalid IL or missing references)
131 //IL_00f9: Unknown result type (might be due to invalid IL or missing references)
132 //IL_00fe: Unknown result type (might be due to invalid IL or missing references)
133 //IL_0100: Unknown result type (might be due to invalid IL or missing references)
134 //IL_012c: Unknown result type (might be due to invalid IL or missing references)
135 //IL_0133: Unknown result type (might be due to invalid IL or missing references)
136 //IL_0140: Unknown result type (might be due to invalid IL or missing references)
137 //IL_0147: Unknown result type (might be due to invalid IL or missing references)
138 //IL_0159: Unknown result type (might be due to invalid IL or missing references)
139 //IL_0164: Unknown result type (might be due to invalid IL or missing references)
140 //IL_0169: Unknown result type (might be due to invalid IL or missing references)
141 //IL_0170: Unknown result type (might be due to invalid IL or missing references)
142 //IL_0175: Unknown result type (might be due to invalid IL or missing references)
143 //IL_017a: Unknown result type (might be due to invalid IL or missing references)
144 //IL_017c: Unknown result type (might be due to invalid IL or missing references)
145 //IL_0186: Unknown result type (might be due to invalid IL or missing references)
146 //IL_018b: Unknown result type (might be due to invalid IL or missing references)
147 //IL_018d: Unknown result type (might be due to invalid IL or missing references)
148 //IL_018f: Unknown result type (might be due to invalid IL or missing references)
149 //IL_0191: Unknown result type (might be due to invalid IL or missing references)
150 //IL_0196: Unknown result type (might be due to invalid IL or missing references)
151 //IL_019d: Unknown result type (might be due to invalid IL or missing references)
152 //IL_01a2: Unknown result type (might be due to invalid IL or missing references)
153 //IL_01ae: Unknown result type (might be due to invalid IL or missing references)
154 //IL_01b3: Unknown result type (might be due to invalid IL or missing references)
155 //IL_01bd: Unknown result type (might be due to invalid IL or missing references)
156 //IL_01c2: Unknown result type (might be due to invalid IL or missing references)
157 //IL_01c4: Unknown result type (might be due to invalid IL or missing references)
158 //IL_01c6: Unknown result type (might be due to invalid IL or missing references)
159 //IL_01c8: Unknown result type (might be due to invalid IL or missing references)
160 //IL_01cd: Unknown result type (might be due to invalid IL or missing references)
161 //IL_01d4: Unknown result type (might be due to invalid IL or missing references)
162 //IL_01d9: Unknown result type (might be due to invalid IL or missing references)
163 //IL_01e5: Unknown result type (might be due to invalid IL or missing references)
164 //IL_01ef: Unknown result type (might be due to invalid IL or missing references)
165 //IL_01f4: Unknown result type (might be due to invalid IL or missing references)
166 //IL_01f6: Unknown result type (might be due to invalid IL or missing references)
167 //IL_01f8: Unknown result type (might be due to invalid IL or missing references)
168 //IL_01fa: Unknown result type (might be due to invalid IL or missing references)
169 //IL_01ff: Unknown result type (might be due to invalid IL or missing references)
170 //IL_0206: Unknown result type (might be due to invalid IL or missing references)
171 //IL_020b: Unknown result type (might be due to invalid IL or missing references)
172 //IL_0217: Unknown result type (might be due to invalid IL or missing references)
173 //IL_021c: Unknown result type (might be due to invalid IL or missing references)
174 //IL_0226: Unknown result type (might be due to invalid IL or missing references)
175 //IL_022b: Unknown result type (might be due to invalid IL or missing references)
176 //IL_022d: Unknown result type (might be due to invalid IL or missing references)
177 //IL_022f: Unknown result type (might be due to invalid IL or missing references)
178 //IL_0231: Unknown result type (might be due to invalid IL or missing references)
179 //IL_0236: Unknown result type (might be due to invalid IL or missing references)
180 //IL_023d: Unknown result type (might be due to invalid IL or missing references)
181 //IL_0242: Unknown result type (might be due to invalid IL or missing references)
182 //IL_0263: Unknown result type (might be due to invalid IL or missing references)
183 //IL_0268: Unknown result type (might be due to invalid IL or missing references)
184 //IL_0284: Unknown result type (might be due to invalid IL or missing references)
185 //IL_028b: Unknown result type (might be due to invalid IL or missing references)
186 //IL_0290: Unknown result type (might be due to invalid IL or missing references)
187 //IL_02c8: Unknown result type (might be due to invalid IL or missing references)
188 //IL_02cd: Unknown result type (might be due to invalid IL or missing references)
189 //IL_02d2: Unknown result type (might be due to invalid IL or missing references)
190 //IL_02d4: Unknown result type (might be due to invalid IL or missing references)
191 //IL_02b1: Unknown result type (might be due to invalid IL or missing references)
192 //IL_02b8: Unknown result type (might be due to invalid IL or missing references)
193 //IL_02bd: Unknown result type (might be due to invalid IL or missing references)
194 //IL_02eb: Unknown result type (might be due to invalid IL or missing references)
195 //IL_02f7: Unknown result type (might be due to invalid IL or missing references)
196 //IL_02fc: Unknown result type (might be due to invalid IL or missing references)
197 //IL_02dd: Unknown result type (might be due to invalid IL or missing references)
198 //IL_02df: Unknown result type (might be due to invalid IL or missing references)
199 //IL_02ff: Unknown result type (might be due to invalid IL or missing references)
200 //IL_030c: Unknown result type (might be due to invalid IL or missing references)
201 //IL_0311: Unknown result type (might be due to invalid IL or missing references)
202 //IL_039c: Unknown result type (might be due to invalid IL or missing references)
203 //IL_041f: Unknown result type (might be due to invalid IL or missing references)
204 //IL_03ba: Unknown result type (might be due to invalid IL or missing references)
205 //IL_03c1: Unknown result type (might be due to invalid IL or missing references)
206 //IL_043d: Unknown result type (might be due to invalid IL or missing references)
207 //IL_0444: Unknown result type (might be due to invalid IL or missing references)
208 if (!anyPortalAtAll)
209 {
210 return;
211 }
212 float collisionPoint = 0f;
213 _ = ent.velocity;
214 int width = ent.width;
215 int height = ent.height;
216 int num = 1;
217 if (ent is Player)
218 {
219 num = (int)((Player)ent).gravDir;
220 }
221 for (int i = 0; i < FoundPortals.GetLength(0); i++)
222 {
223 if (FoundPortals[i, 0] == -1 || FoundPortals[i, 1] == -1 || (ent is Player && (i >= PortalCooldownForPlayers.Length || PortalCooldownForPlayers[i] > 0)) || (ent is NPC && (i >= PortalCooldownForNPCs.Length || PortalCooldownForNPCs[i] > 0)))
224 {
225 continue;
226 }
227 for (int j = 0; j < 2; j++)
228 {
229 Projectile projectile = Main.projectile[FoundPortals[i, j]];
230 GetPortalEdges(projectile.Center, projectile.ai[0], out var start, out var end);
231 if (!Collision.CheckAABBvLineCollision(ent.position + ent.velocity, ent.Size, start, end, 2f, ref collisionPoint))
232 {
233 continue;
234 }
235 Projectile projectile2 = Main.projectile[FoundPortals[i, 1 - j]];
236 float num2 = ent.Hitbox.Distance(projectile.Center);
237 int bonusX;
238 int bonusY;
239 Vector2 vector = GetPortalOutingPoint(ent.Size, projectile2.Center, projectile2.ai[0], out bonusX, out bonusY) + Vector2.Normalize(new Vector2((float)bonusX, (float)bonusY)) * num2;
240 Vector2 vector2 = Vector2.UnitX * 16f;
241 if (Collision.TileCollision(vector - vector2, vector2, width, height, fallThrough: true, fall2: true, num) != vector2)
242 {
243 continue;
244 }
245 vector2 = -Vector2.UnitX * 16f;
246 if (Collision.TileCollision(vector - vector2, vector2, width, height, fallThrough: true, fall2: true, num) != vector2)
247 {
248 continue;
249 }
250 vector2 = Vector2.UnitY * 16f;
251 if (Collision.TileCollision(vector - vector2, vector2, width, height, fallThrough: true, fall2: true, num) != vector2)
252 {
253 continue;
254 }
255 vector2 = -Vector2.UnitY * 16f;
256 if (Collision.TileCollision(vector - vector2, vector2, width, height, fallThrough: true, fall2: true, num) != vector2)
257 {
258 continue;
259 }
260 float num3 = 0.1f;
261 if (bonusY == -num)
262 {
263 num3 = 0.1f;
264 }
265 if (ent.velocity == Vector2.Zero)
266 {
267 ent.velocity = (projectile.ai[0] - (float)Math.PI / 2f).ToRotationVector2() * num3;
268 }
269 if (((Vector2)(ref ent.velocity)).Length() < num3)
270 {
271 ((Vector2)(ref ent.velocity)).Normalize();
272 ent.velocity *= num3;
273 }
274 Vector2 vector3 = Vector2.Normalize(new Vector2((float)bonusX, (float)bonusY));
275 if (vector3.HasNaNs() || vector3 == Vector2.Zero)
276 {
277 vector3 = Vector2.UnitX * (float)ent.direction;
278 }
279 ent.velocity = vector3 * ((Vector2)(ref ent.velocity)).Length();
280 if ((bonusY == -num && Math.Sign(ent.velocity.Y) != -num) || Math.Abs(ent.velocity.Y) < 0.1f)
281 {
282 ent.velocity.Y = (float)(-num) * 0.1f;
283 }
284 int num4 = (int)((float)(projectile2.owner * 2) + projectile2.ai[1]);
285 int lastPortalColorIndex = num4 + ((num4 % 2 == 0) ? 1 : (-1));
286 if (ent is Player)
287 {
288 Player player = (Player)ent;
289 player.lastPortalColorIndex = lastPortalColorIndex;
290 player.Teleport(vector, 4, num4);
291 if (Main.netMode == 1)
292 {
293 NetMessage.SendData(96, -1, -1, null, player.whoAmI, vector.X, vector.Y, num4);
294 NetMessage.SendData(13, -1, -1, null, player.whoAmI);
295 }
297 }
298 else if (ent is NPC)
299 {
300 NPC nPC = (NPC)ent;
301 nPC.lastPortalColorIndex = lastPortalColorIndex;
302 nPC.Teleport(vector, 4, num4);
303 if (Main.netMode == 2)
304 {
305 NetMessage.SendData(100, -1, -1, null, nPC.whoAmI, vector.X, vector.Y, num4);
306 NetMessage.SendData(23, -1, -1, null, nPC.whoAmI);
307 }
309 if (bonusY == -1 && ent.velocity.Y > -3f)
310 {
311 ent.velocity.Y = -3f;
312 }
313 }
314 return;
315 }
316 }
317 }
static Vector2 GetPortalOutingPoint(Vector2 objectSize, Vector2 portalPosition, float portalAngle, out int bonusX, out int bonusY)
static void GetPortalEdges(Vector2 position, float angle, out Vector2 start, out Vector2 end)

References Terraria.Projectile.ai, Terraria.GameContent.PortalHelper.anyPortalAtAll, Terraria.Entity.Center, Terraria.Collision.CheckAABBvLineCollision(), Terraria.GameContent.PortalHelper.FoundPortals, Terraria.GameContent.PortalHelper.GetPortalEdges(), Terraria.GameContent.PortalHelper.GetPortalOutingPoint(), Terraria.Main.netMode, Terraria.GameContent.PortalHelper.PortalCooldownForNPCs, Terraria.GameContent.PortalHelper.PortalCooldownForPlayers, Terraria.Main.projectile, Terraria.NetMessage.SendData(), Terraria.Player.Teleport(), Terraria.Collision.TileCollision(), and Terraria.Entity.whoAmI.

Referenced by Terraria.NPC.TryPortalJumping(), and Terraria.Player.TryPortalJumping().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: