/// <summary>
 /// Adds the given entity into the list of entities, and adjusts the player location if a player object is added
 /// </summary>
 public void AddEntity(Entity.Entity e)
 {
     e.currentWorld = world;
     Console.WriteLine("Added Entity: " + e.GetType().FullName + " (#" + e.GetHashCode() + ")");
     if (e is Player) {
         if (playerLoc == -1) {
             playerLoc = 0;
             entities.Insert(0, e);
         } else {
             entities[playerLoc] = e;
         }
     } else {
         if (e is NPC)
             civilianCount++;
         // entities.Add(e);
         entitiesToAdd.Add(e);
     }
 }
        public void Two_entities_with_the_same_Id_should_equal_each_other()
        {
            var first = new Entity{Id = 99};
            var second = new Entity { Id = 99 };

            first.Equals(second).ShouldBeTrue();
            second.Equals(first).ShouldBeTrue();

            Equals(first, second).ShouldBeTrue();
            Equals(second, first).ShouldBeTrue();

            first.GetHashCode().ShouldEqual(second.GetHashCode());

            (first == second).ShouldBeTrue();
            (second == first).ShouldBeTrue();

            (first != second).ShouldBeFalse();
            (second != first).ShouldBeFalse();
        }
        public void Two_entities_with_different_Ids_should_not_equal_each_other()
        {
            var first = new Entity { Id = 66 };
            var second = new Entity { Id = 77 };

            first.Equals(second).ShouldBeFalse();
            second.Equals(first).ShouldBeFalse();

            Equals(first, second).ShouldBeFalse();
            Equals(second, first).ShouldBeFalse();

            first.GetHashCode().ShouldNotEqual(second.GetHashCode());

            (first == second).ShouldBeFalse();
            (second == first).ShouldBeFalse();

            (first != second).ShouldBeTrue();
            (second != first).ShouldBeTrue();
        }
Example #4
0
		public void SimpleExpressionWithNewInstance()
		{
			var a = new Entity() { Id = 2, Name = "2" };
			var restriction = Restrictions.Eq("A", a);
			Assert.AreEqual(@"A = [email protected]" + a.GetHashCode() + "(hash)", restriction.ToString());
		}
        private void RenderPartGlow(Entity root, Entity partEntity, ref Matrix parentMatrix)
        {
            var partComponent = partEntity.GetComponent<IShipPartComponent>();
            var glow = partEntity.GetComponent<PartGlowComponent>();
            Vector3 offset = new Vector3(
                (_randomFloats[0] * 6) % partComponent.GetHashCode() - 3,
                (_randomFloats[1] * 6) % partEntity.GetHashCode() - 3,
                0
                );
            var xform = partEntity.GetComponent<Transform>();
            var sprite = partEntity.GetComponent<SpriteComponent>();
            var color = glow.Color;
            color.A = 0;

            Matrix matrix = xform.Matrix * Matrix.CreateTranslation(offset) *  parentMatrix;
            _batch.Draw(sprite, ref matrix, color);
        }