-
Notifications
You must be signed in to change notification settings - Fork 0
/
World.cs
59 lines (49 loc) · 1.28 KB
/
World.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
using System;
using System.Collections.Generic;
using System.Reflection;
using SFML.Graphics;
namespace Tiler
{
public struct WorldProps
{
public float AtmosFriction;
public bool IsSolid;
}
public static class World
{
internal static readonly Dictionary<string, Type> ValidSpawnableEntityTypes = new Dictionary<string, Type>();
public static Map Map;
public static List<Entity> Entities = new List<Entity>();
static World()
{
foreach (var type in Assembly.GetAssembly(typeof(Entity)).GetTypes())
{
if (type.IsClass && !type.IsAbstract && type.IsSubclassOf(typeof(Entity)))
{
if (Attribute.GetCustomAttribute(type, typeof(SpawnableAttribute)) is null)
continue;
if ((Attribute.GetCustomAttribute(type, typeof(SpawnableAttribute)) as SpawnableAttribute).Spawnable == false)
continue;
if (type.Assembly == Assembly.GetExecutingAssembly())
{
ValidSpawnableEntityTypes.Add(type.Name, type);
}
else
{
ValidSpawnableEntityTypes.Add(type.FullName, type);
}
}
}
}
public static void Draw(Window target)
{
if (!(Map is null))
target.Draw(Map);
foreach (var entity in Entities)
{
//target.Draw(entity);
entity.Draw(target.RenderWindow, RenderStates.Default);
}
}
}
}