This repository has been archived by the owner on Nov 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathTerrariaUtils.cs
45 lines (38 loc) · 1.7 KB
/
TerrariaUtils.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
using System;
using System.Collections;
using System.Collections.Generic;
using DPoint = System.Drawing.Point;
namespace Terraria.Plugins.Common {
public static partial class TerrariaUtils {
public static int BlockType_Min = 0;
public static int BlockType_Max = Main.maxTileSets - 1;
public static int WallType_Min = 0;
public static int WallType_Max = Main.maxWallTypes - 1;
public static int ItemType_Min = -48;
public static int ItemType_Max = Main.maxItemTypes - 1;
public static int NpcType_Min = -65;
public static int NpcType_Max = Main.maxNPCTypes - 1;
public const int DefaultTextureTileSize = 18;
public const int TileSize = 16;
public static TerrariaTiles Tiles { get; private set; }
public static TerrariaItems Items { get; private set; }
public static TerrariaNpcs Npcs { get; private set; }
public static TerrariaProjectiles Projectiles { get; private set; }
public static InvasionType InvasionType => (Common.InvasionType)Main.invasionType;
static TerrariaUtils() {
TerrariaUtils.Tiles = new TerrariaTiles();
TerrariaUtils.Items = new TerrariaItems();
TerrariaUtils.Npcs = new TerrariaNpcs();
TerrariaUtils.Projectiles = new TerrariaProjectiles();
}
public static IEnumerable<int> EnumeratePlayerIndexesAroundPoint(DPoint location, float radius) {
for (int i = 0; i < Main.player.Length; i++) {
Player player = Main.player[i];
if (player == null || !player.active)
continue;
if (Math.Sqrt(Math.Pow(player.position.X - location.X, 2) + Math.Pow(player.position.Y - location.Y, 2)) <= radius)
yield return i;
}
}
}
}