示例#1
0
 public ModifierContext(MyEntity e, InterningBag <EquiModifierBaseDefinition> modifiers)
 {
     _a            = e;
     _b            = null;
     OriginalModel = e?.Definition?.Get <MyModelComponentDefinition>()?.Model;
     Modifiers     = modifiers;
 }
示例#2
0
 public ModifierContext(MyGridDataComponent data, MyBlock block, InterningBag <EquiModifierBaseDefinition> modifiers)
 {
     _a            = data;
     _b            = block;
     OriginalModel = GetOriginalBlockModel(data, block);
     Modifiers     = modifiers;
 }
        public void Test()
        {
            var a = InterningBag <MyDefinitionId> .Empty.With(_ids[0]).With(_ids[1]);

            var b = InterningBag <MyDefinitionId> .Empty.With(_ids[1]).With(_ids[0]);

            var c = InterningBag <MyDefinitionId> .Of(_ids[0], _ids[1]);

            Assert.True(ReferenceEquals(InterningBag <MyDefinitionId> .Of(), InterningBag <MyDefinitionId> .Empty));
            Assert.True(ReferenceEquals(a, b));
            Assert.True(ReferenceEquals(a, c));
            Assert.True(ReferenceEquals(a.Without(_ids[0]), b.Without(_ids[0])));
            Assert.True(ReferenceEquals(a.Without(_ids[1]), b.Without(_ids[1])));
            Assert.True(ReferenceEquals(a.Without(_ids[0]), c.Without(_ids[0])));
            Assert.True(ReferenceEquals(a.Without(_ids[1]), c.Without(_ids[1])));

            Assert.True(a.Contains(_ids[0]));
            Assert.False(a.Contains(_ids[2]));

            Assert.False(a.Without(_ids[0]).Contains(_ids[0]));

            Assert.True(ReferenceEquals(a, a.With(_ids[0])));
            Assert.True(ReferenceEquals(a, a.Without(_ids[2])));
            Assert.True(ReferenceEquals(a.Without(_ids[0]).Without(_ids[1]), InterningBag <MyDefinitionId> .Empty));
            Assert.True(ReferenceEquals(a.Without(_ids[0]).Without(_ids[2]), InterningBag <MyDefinitionId> .Of(_ids[1])));

            var copied = InterningBag <MyDefinitionId> .Of(a.ToArray());

            Assert.True(ReferenceEquals(copied, a));
        }