public static void TestRemoveEntity() { Entity e1 = EnvironmentManager.AddEntity(); Assert.True(e1.EntityExists()); Assert.True(e1.RemoveEntity()); Assert.False(e1.RemoveEntity()); Assert.False(e1.EntityExists()); }
public static void TestRemoveComponent() { Entity e1 = EnvironmentManager.AddEntity(); Assert.True(e1.EntityExists()); TestComponent t = e1.AddComponent <TestComponent>(); Assert.AreSame(e1.GetComponent <TestComponent>(), t); e1.RemoveComponent <TestComponent>(); Assert.Null(e1.GetComponent <TestComponent>()); }
public static void TestAddEntity() { Entity e1 = EnvironmentManager.AddEntity(); Assert.True(EnvironmentManager.EntityExists(e1)); Assert.True(e1.EntityExists()); Assert.AreEqual(e1, (Entity)1); Entity e2 = EnvironmentManager.AddEntity(); Assert.True(EnvironmentManager.EntityExists(e2)); Assert.True(e2.EntityExists()); Assert.AreNotEqual(e1, e2); }
public static void TestGenerationIndexes() { Entity e1 = EnvironmentManager.AddEntity(); Assert.True(e1.EntityExists()); TestComponent t = e1.AddComponent <TestComponent>(); Assert.AreEqual(e1.GetComponent <TestComponent>(), t); Assert.True(e1.RemoveEntity()); Assert.False(e1.RemoveEntity()); Assert.False(e1.EntityExists()); Entity e2 = EnvironmentManager.AddEntity(); Assert.True(e2.EntityExists()); Assert.AreEqual(e1 >> 16, e2 >> 16); Assert.AreNotEqual(e1 & 65535, e2 & 65535); Assert.Null(e2.GetComponent <TestComponent>()); }
public override void Setup() { if (Instance == null) { Instance = this; } if (cameraEntity == null) { cameraEntity = EnvironmentManager.AddEntity(); if (cameraEntity == null) { throw new System.Exception(); } cameraEntity.Value.AddComponent <Camera>(); var trans = cameraEntity.Value.AddComponent <Transform>(); cameraTransform = trans ?? throw new System.Exception(); cameraTransform.PositionValidator = (Vector3D position) => { if (position.Y < MinHeight) { position = new Vector3D(position.X, MinHeight, position.Z); } return(position); }; cameraTransform.Position = StartPosition; cameraTransform.LookAt(new Vector3D()); } // Bind controls for free roam InputManager.AssignDigitalInput("camera_forward", new Digital("w")); InputManager.AssignDigitalInput("camera_left", new Digital("a")); InputManager.AssignDigitalInput("camera_backward", new Digital("s")); InputManager.AssignDigitalInput("camera_right", new Digital("d")); InputManager.AssignDigitalInput("camera_up", new Digital("space")); InputManager.AssignDigitalInput("camera_down", new Digital("left shift")); InputManager.AssignDigitalInput("camera_boost", new Digital("left ctrl")); // Bind controls for orbit InputManager.AssignDigitalInput("camera_drag", new Digital("mouse 0 non-ui")); // TODO put control settings in preference manager InputManager.AssignAxis("ZoomCamera", new Analog("Mouse ScrollWheel")); InputManager.AssignAxis("Mouse X", new Analog("Mouse X")); InputManager.AssignAxis("Mouse Y", new Analog("Mouse Y")); }
public static void TestBadEntity() { Entity e1 = 1; Assert.False(e1.EntityExists()); Assert.False(e1.RemoveEntity()); Assert.Null(e1.GetComponent <TestComponent>()); TestComponent t = e1.AddComponent <TestComponent>(); Assert.Null(e1.GetComponent <TestComponent>()); EnvironmentManager.AddEntity(); Entity e2 = 2; Assert.False(e2.EntityExists()); Assert.False(e2.RemoveEntity()); Assert.Null(e2.GetComponent <TestComponent>()); e2.AddComponent <TestComponent>(); Assert.Null(e2.GetComponent <TestComponent>()); }
public static void TestMultiComponents() { Entity e1 = EnvironmentManager.AddEntity(); Assert.True(e1.EntityExists()); Entity e2 = EnvironmentManager.AddEntity(); Assert.True(e2.EntityExists()); TestComponent t = e2.AddComponent <TestComponent>(); //EnvironmentManager.SetComponent(e2,t) AnotherTestComponent at = e2.AddComponent <AnotherTestComponent>(); Assert.Null(e1.GetComponent(typeof(TestComponent))); Assert.Null(e1.GetComponent(typeof(AnotherTestComponent))); Assert.Null(e1.GetComponent <TestComponent>()); Assert.Null(e1.GetComponent <AnotherTestComponent>()); Assert.AreSame(e2.GetComponent(typeof(TestComponent)), t); Assert.AreSame(e2.GetComponent(typeof(AnotherTestComponent)), at); Assert.AreSame(e2.GetComponent <TestComponent>(), t); Assert.AreSame(e2.GetComponent <AnotherTestComponent>(), at); TestComponent t2 = e2.AddComponent <TestComponent>(); Assert.AreSame(e2.GetComponent <TestComponent>(), t2); }