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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80 |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using System.IO;
using System.Reflection;
namespace Brains.Framework
{
/// <summary>
/// Represents the main AI Engine.
/// Create an instance of this class and call update every frame to stimulate the world
/// </summary>
public class AIEngine
{
private World _world;
internal List<Assembly> Assemblies = new List<Assembly>();
/// <summary>
/// The main game world
/// </summary>
public World World { get { return _world; } }
/// <summary>
/// Default Constructor
/// </summary>
public AIEngine()
{
}
/// <summary>
/// The main engine update method
/// </summary>
/// <param name="gameTime">The GameTime elapsed since the last update</param>
/// <remarks>Call this every frame</remarks>
public void Update(GameTime gameTime)
{
World.Update(gameTime);
}
/// <summary>
/// Creates an empty world
/// </summary>
public void CreateWorld()
{
_world = new World();
_world.Engine = this;
}
/// <summary>
/// Sets the world to the specified world
/// </summary>
/// <param name="world">The world to set as the active world</param>
/// <remarks>Can be used when extending the World class</remarks>
public void CreateWorld(World world)
{
_world = world;
_world.Engine = this;
}
/// <summary>
/// Loads an assembly ready for use with loading from file.
/// </summary>
/// <param name="path">The full file path of the assembly</param>
/// <remarks>Will automatically load the engine assembly if not already loaded</remarks>
public void LoadAssembly(string path)
{
if (Assemblies.Count == 0)
{
Assemblies.Add(typeof(AIEngine).Assembly);// Assembly.LoadFrom(typeof(AIEngine).Assembly.Location));
}
//Cache all the assemblies
Assemblies.Add(Assembly.LoadFrom(path));
}
}
} |