public void ComponentStatePositionTest()
        {
            // Arrange
            var initialPos  = new EntityCoordinates(GridA.GridEntityId, (0, 0));
            var parent      = EntityManager.SpawnEntity("dummy", initialPos);
            var child       = EntityManager.SpawnEntity("dummy", initialPos);
            var parentTrans = parent.Transform;
            var childTrans  = child.Transform;

            var compState = new TransformComponent.TransformComponentState(new Vector2(5, 5), new Angle(0), GridB.GridEntityId);

            parentTrans.HandleComponentState(compState, null);

            compState = new TransformComponent.TransformComponentState(new Vector2(6, 6), new Angle(0), GridB.GridEntityId);
            childTrans.HandleComponentState(compState, null);
            // World pos should be 6, 6 now.

            // Act
            var oldWpos = childTrans.WorldPosition;

            compState = new TransformComponent.TransformComponentState(new Vector2(1, 1), new Angle(0), parent.Uid);
            childTrans.HandleComponentState(compState, null);
            var newWpos = childTrans.WorldPosition;

            // Assert
            Assert.That(newWpos, Is.EqualTo(oldWpos));
        }
        public void ComponentStatePositionTest()
        {
            // Arrange
            var parent      = EntityManager.SpawnEntity("dummy");
            var child       = EntityManager.SpawnEntity("dummy");
            var parentTrans = parent.GetComponent <ITransformComponent>();
            var childTrans  = child.GetComponent <ITransformComponent>();

            var compState = new TransformComponent.TransformComponentState(new Vector2(5, 5), GridB.Index, new Angle(0), EntityUid.Invalid);

            parentTrans.HandleComponentState(compState);

            compState = new TransformComponent.TransformComponentState(new Vector2(6, 6), GridB.Index, new Angle(0), EntityUid.Invalid);
            childTrans.HandleComponentState(compState);
            // World pos should be 6, 6 now.

            // Act
            var oldWpos = childTrans.WorldPosition;

            compState = new TransformComponent.TransformComponentState(new Vector2(1, 1), GridB.Index, new Angle(0), parent.Uid);
            childTrans.HandleComponentState(compState);
            var newWpos = childTrans.WorldPosition;

            // Assert
            Assert.That(newWpos, Is.EqualTo(oldWpos));
        }
        public void WorldRotationTest()
        {
            // Arrange
            var initalPos = new EntityCoordinates(GridA.GridEntityId, (0, 0));
            var node1     = EntityManager.SpawnEntity("dummy", initalPos);
            var node2     = EntityManager.SpawnEntity("dummy", initalPos);
            var node3     = EntityManager.SpawnEntity("dummy", initalPos);

            node1.Name = "node1_dummy";
            node2.Name = "node2_dummy";
            node3.Name = "node3_dummy";

            var node1Trans = node1.Transform;
            var node2Trans = node2.Transform;
            var node3Trans = node3.Transform;

            var compState = new TransformComponent.TransformComponentState(new Vector2(6, 6), Angle.FromDegrees(135), GridB.GridEntityId);

            node1Trans.HandleComponentState(compState, null);
            compState = new TransformComponent.TransformComponentState(new Vector2(1, 1), Angle.FromDegrees(45), node1.Uid);
            node2Trans.HandleComponentState(compState, null);
            compState = new TransformComponent.TransformComponentState(new Vector2(0, 0), Angle.FromDegrees(45), node2.Uid);
            node3Trans.HandleComponentState(compState, null);

            // Act
            var result = node3Trans.WorldRotation;

            // Assert (135 + 45 + 45 = 225)
            Assert.That(result, new ApproxEqualityConstraint(Angle.FromDegrees(225)));
        }
        public void WorldRotationTest()
        {
            // Arrange
            var node1 = EntityManager.SpawnEntity("dummy");
            var node2 = EntityManager.SpawnEntity("dummy");
            var node3 = EntityManager.SpawnEntity("dummy");

            node1.Name = "node1_dummy";
            node2.Name = "node2_dummy";
            node3.Name = "node3_dummy";

            var node1Trans = node1.GetComponent <ITransformComponent>();
            var node2Trans = node2.GetComponent <ITransformComponent>();
            var node3Trans = node3.GetComponent <ITransformComponent>();

            var compState = new TransformComponent.TransformComponentState(new Vector2(6, 6), GridB.Index, Angle.FromDegrees(135), EntityUid.Invalid);

            node1Trans.HandleComponentState(compState);
            compState = new TransformComponent.TransformComponentState(new Vector2(1, 1), GridB.Index, Angle.FromDegrees(45), node1.Uid);
            node2Trans.HandleComponentState(compState);
            compState = new TransformComponent.TransformComponentState(new Vector2(0, 0), GridB.Index, Angle.FromDegrees(45), node2.Uid);
            node3Trans.HandleComponentState(compState);

            // Act
            var result = node3Trans.WorldRotation;

            // Assert (135 + 45 + 45 = 225)
            Assert.That(result, new ApproxEqualityConstraint(Angle.FromDegrees(225)));
        }