Example #1
0
        public void Object_Expression_GetHashCode()
        {
            var entity = new Entity(Guid.NewGuid(), DateTime.Now.ToString());

            entity.CalcHash(e => e.Id, e => e.Code).Should().Be(entity.GetHashCode());
            entity.CalcHash().Should().Be(entity.GetHashCode());

            entity.CalcHash(e => e.Id).Should().Not.Be.EqualTo(entity.GetHashCode());
            entity.CalcHash(e => e.Code, e => e.Id).Should().Not.Be.EqualTo(entity.GetHashCode());
        }
        private Entity FindNoPath(Entity node, string name)
        {
            var mgr = EntityManager;

            Assert.IsTrue(mgr.HasComponent <Parent>(node));

            var hash = (uint)name.GetHashCode();

            hash ^= (uint)node.GetHashCode();
            hash %= sFindCacheSize;

            Entity eI = findCache[hash];

            if (eI != Entity.Null && mgr.Exists(eI) && mgr.HasComponent <Parent>(eI) && mgr.HasComponent <EntityName>(eI))
            {
                var tx = mgr.GetComponentData <Parent>(eI);
                if (tx.Value == node && mgr.GetBufferAsString <EntityName>(eI) == name)
                {
                    return(eI);
                }
            }
            Entity result = Entity.Null;

            Entities.ForEach((Entity e, ref Parent xformNode, DynamicBuffer <EntityName> ename) => {
                if (xformNode.Value == node)
                {
                    if (mgr.GetBufferAsString <EntityName>(e) == name)
                    {
                        result = e;
                    }
                }
            });
            findCache[hash] = result;
            return(result);
        }
 public override int GetHashCode()
 {
     unchecked
     {
         return(((Entity != null ? Entity.GetHashCode() : 0) * 397) ^ (Field != null ? Field.GetHashCode() : 0));
     }
 }
Example #4
0
 public override int GetHashCode()
 {
     return(HashCode.Initial
            .CombineHashCode(_eventMetadata.GetHashCode())
            .CombineHashCode(_host.GetHashCode())
            .CombineHashCodeOrDefault(Venues));
 }
Example #5
0
 public override int GetHashCode()
 {
     unchecked
     {
         return((_country.GetHashCode() * 397) ^ _goodIndex);
     }
 }
Example #6
0
 public override int GetHashCode()
 {
     unchecked
     {
         return((From.GetHashCode() * 397) ^ To.GetHashCode());
     }
 }
 public override int GetHashCode()
 {
     unchecked
     {
         return((Prev.GetHashCode() * 397) ^ Next.GetHashCode());
     }
 }
Example #8
0
        public override int GetHashCode()
        {
            var result = Entity != null?Entity.GetHashCode() : 0;

            result = 31 * result + (Data != null ? Data.GetHashCode() : 0);
            return(result);
        }
Example #9
0
 public override int GetHashCode()
 {
     unchecked
     {
         return((HalfEdge.GetHashCode() * 397) ^ Entity.GetHashCode());
     }
 }
Example #10
0
 public override int GetHashCode()
 {
     unchecked
     {
         return(((Entity != null ? Entity.GetHashCode() : 0) * 397) ^ (int)State);
     }
 }
Example #11
0
 public override int GetHashCode()
 {
     unchecked
     {
         return((BulletPrefab.GetHashCode() * 397) ^ (SmokePrefab != null ? SmokePrefab.GetHashCode() : 0));
     }
 }
Example #12
0
 public override int GetHashCode()
 {
     unchecked
     {
         return((StartNode.GetHashCode() * 397) ^ EndNode.GetHashCode());
     }
 }
Example #13
0
    public void EntitiesHaveTheSameHashCodeIfEqual()
    {
        EntityType character = new EntityType("CHARACTER");
        Entity     e1        = new Entity(character, "John");
        Entity     e2        = new Entity(character, "John");

        Assert.True(e1.GetHashCode() == e2.GetHashCode());
    }
Example #14
0
    static int GetHashCode(IntPtr L)
    {
        LuaScriptMgr.CheckArgsCount(L, 1);
        Entity obj = LuaScriptMgr.GetNetObject <Entity>(L, 1);
        int    o   = obj.GetHashCode();

        LuaScriptMgr.Push(L, o);
        return(1);
    }
Example #15
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = (Entity != null ? Entity.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Id != null ? Id.GetHashCode() : 0);
         return(hashCode);
     }
 }
Example #16
0
        public override int GetHashCode()
        {
            var hashCode = 1207886411;

            hashCode = hashCode * -1521134295 + base.GetHashCode();
            hashCode = hashCode * -1521134295 + TargetMethodId.GetHashCode();
            hashCode = hashCode * -1521134295 + TargetEntity.GetHashCode();
            return(hashCode);
        }
Example #17
0
        public void CreatePlayerEntity(string entityName, ref GameObject gameObject)
        {
            Entity entity = ECSLocate.ECS.CreateEntity(entityName, ref gameObject);

            playerEntity = entity;
            playerGo     = gameObject;

            playerWorkData = ECSLayerLocate.Info.GetEntityWorkData(entity.GetHashCode());
        }
Example #18
0
        private void RecursivelyRender(Entity en)
        {
            ImGui.PushID(en.GetHashCode());

            ImGuiTreeNodeFlags nodeFlags = ImGuiTreeNodeFlags.OpenOnArrow;

            if (SelectedEntity == en)
            {
                nodeFlags |= ImGuiTreeNodeFlags.Selected;
            }

            if (!en.Active)
            {
                ImGui.PushStyleColor(ImGuiCol.Text, new System.Numerics.Vector4(0.4f, 0.4f, 0.4f, 1f));
            }

            bool nodeOpen = ImGui.TreeNodeEx(en.Name, nodeFlags);

            if (ImGui.IsItemClicked())
            {
                SelectedEntity = en;
            }

            //new entity delete menu
            if (ImGui.BeginPopupContextItem("Entity Popup"))
            {
                if (ImGui.MenuItem("New Entity"))
                {
                    _ = new Entity("New Entity", parent: en);
                }

                if (ImGui.MenuItem("Delete"))
                {
                    en.Destroy();
                }

                ImGui.EndPopup();
            }

            if (nodeOpen)
            {
                for (int i = 0; i < en.Children.Count; i++)
                {
                    RecursivelyRender(en.Children[i]);
                }

                ImGui.TreePop();
            }

            if (!en.Active)
            {
                ImGui.PopStyleColor();
            }

            ImGui.PopID();
        }
Example #19
0
        public override int GetHashCode()
        {
            int hash = 17;

            hash = hash * 31 + Target.GetHashCode();
            hash = hash * 31 + Trait.GetHashCode();
            hash = hash * 31 + ValueString.GetHashCode();
            hash = hash * 31 + IsNegative.GetHashCode();
            return(hash);
        }
Example #20
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = Entity.GetHashCode();
         hashCode = (hashCode * 397) ^ EntityId.GetHashCode();
         hashCode = (hashCode * 397) ^ (Metadata != null ? Metadata.GetHashCode() : 0);
         return(hashCode);
     }
 }
        /// <summary>
        /// Serves as a hash function for a particular type.
        /// </summary>
        /// <returns>
        /// A hash code for the current <see cref="SchemaSemantics"/>.
        /// </returns>
        public override int GetHashCode()
        {
            int result = Prefix.GetHashCode() ^ Entity.GetHashCode();

            if (Vocab != null)
            {
                result ^= Vocab.GetHashCode();
            }
            return(result);
        }
Example #22
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = (int)Type;
         hashCode = (hashCode * 397) ^ (Entity != null ? Entity.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Component != null ? Component.GetHashCode() : 0);
         return(hashCode);
     }
 }
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = PrimaryEntity.GetHashCode();
         hashCode = (hashCode * 397) ^ (AdditionalEntities != null ? AdditionalEntities.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (EntityManager != default ? EntityManager.GetHashCode() : 0);
         return(hashCode);
     }
 }
Example #24
0
        public void CalculateDifferentHashCode_IfInstancesHaveDifferentId()
        {
            var entityFirst  = new Entity <int>(1);
            var entitySecond = new Entity <int>(2);

            var hashCodeFirst  = entityFirst.GetHashCode();
            var hashCodeSecond = entitySecond.GetHashCode();

            Assert.NotEqual(hashCodeFirst, hashCodeSecond);
        }
Example #25
0
        public void CalculateSameHashCode_IfInstancesHaveIdenticalId()
        {
            var entityFirst  = new Entity <int>(1);
            var entitySecond = new Entity <int>(1);

            var hashCodeFirst  = entityFirst.GetHashCode();
            var hashCodeSecond = entitySecond.GetHashCode();

            Assert.Equal(hashCodeFirst, hashCodeSecond);
        }
Example #26
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = (Entity != null ? Entity.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ Index;
         hashCode = (hashCode * 397) ^ (OldComponent != null ? OldComponent.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (NewComponent != null ? NewComponent.GetHashCode() : 0);
         return(hashCode);
     }
 }
Example #27
0
 public override int GetHashCode()
 {
     unchecked
     {
         int result = (entity1 != null ? entity1.GetHashCode() : 0);
         result = (result * 397) ^ (entity2 != null ? entity2.GetHashCode() : 0);
         result = (result * 397) ^ (end2Name != null ? end2Name.GetHashCode() : 0);
         result = (result * 397) ^ (end1Name != null ? end1Name.GetHashCode() : 0);
         return(result);
     }
 }
Example #28
0
        public void Created_typed_entity_should_be_equal_to_Entity_with_same_Id()
        {
            // given
            _mappings.Setup(m => m.MappingFor(typeof(IPerson))).Returns(new EntityMapping(typeof(IPerson)));
            var entity = _entityContext.Load <IPerson>(new EntityId("http://magi/people/Tomasz"));
            var typed  = new Entity(new EntityId("http://magi/people/Tomasz"));

            // then
            Assert.AreEqual(entity, typed);
            Assert.AreEqual(entity.GetHashCode(), typed.GetHashCode());
            _mappings.Verify(m => m.MappingFor(typeof(IPerson)), Times.Once);
        }
 public override int GetHashCode() =>
 unchecked ((int)math.hash(new int4x2(
                               new int4(
                                   IgnoreTriggers ? 1 : 0,
                                   IgnoreStatic ? 1 : 0,
                                   PreviousEntity.GetHashCode(),
                                   CurrentEntity.GetHashCode()),
                               new int4(
                                   HoverMaterial != null ? HoverMaterial.GetHashCode() : 0,
                                   OriginalMaterial != null ? OriginalMaterial.GetHashCode() : 0,
                                   0, 0))
                           ));
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = AuthoringComponentId;
         hashCode = (hashCode * 397) ^ ConvertedAuthoringComponentIndex;
         hashCode = (hashCode * 397) ^ BodyEntity.GetHashCode();
         hashCode = (hashCode * 397) ^ ShapeEntity.GetHashCode();
         hashCode = (hashCode * 397) ^ BodyFromShape.GetHashCode();
         hashCode = (hashCode * 397) ^ Hash.GetHashCode();
         return(hashCode);
     }
 }
 /// <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_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();
        }
        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();
        }
        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);
        }
Example #35
0
		public void SimpleExpressionWithNewInstance()
		{
			var a = new Entity() { Id = 2, Name = "2" };
			var restriction = Restrictions.Eq("A", a);
			Assert.AreEqual(@"A = Entity@" + a.GetHashCode() + "(hash)", restriction.ToString());
		}