Exemple #1
0
		public void TestPrivatePools()
		{
			SymbolPool p1 = new SymbolPool();
			SymbolPool p2 = new SymbolPool(3);
			SymbolPool p3 = new SymbolPool(0);
			Symbol a = GSymbol.Get("a");
			Symbol b = GSymbol.Get("b");
			Symbol c = GSymbol.Get("c");
			Symbol s1a = p1.Get("a");
			Symbol s1b = p1.Get("b");
			Symbol s1c = p1.Get("c");
			Symbol s2a = p2.Get("a");
			Symbol s3a = p3.Get("a");
			Symbol s3b = p3.Get("b");

			Assert.That(s1a.Id == 1 && p1.GetById(1) == s1a);
			Assert.That(s1b.Id == 2 && p1.GetById(2) == s1b);
			Assert.That(s1c.Id == 3 && p1.GetById(3) == s1c);
			Assert.That(s2a.Id == 3 && p2.GetById(3) == s2a);
			Assert.That(s3b.Id == 1 && p3.GetById(1) == s3b);
			Assert.That(s3a.Id == 0 && p3.GetById(0) == s3a);
			Assert.AreEqual(GSymbol.Empty, p1.GetById(0));
			Assert.AreEqual(s1c, p1.GetIfExists("c"));
			Assert.AreEqual(3, p1.TotalCount);
			Assert.AreEqual(null, p2.GetIfExists("c"));
			Assert.AreEqual(c, p2.GetGlobalOrCreateHere("c"));
			Assert.AreEqual(p2, p2.GetGlobalOrCreateHere("$!unique^&*").Pool);
		}
Exemple #2
0
        public void TestPrivatePools()
        {
            SymbolPool p1  = new SymbolPool();
            SymbolPool p2  = new SymbolPool(3);
            SymbolPool p3  = new SymbolPool(0);
            Symbol     a   = GSymbol.Get("a");
            Symbol     b   = GSymbol.Get("b");
            Symbol     c   = GSymbol.Get("c");
            Symbol     s1a = p1.Get("a");
            Symbol     s1b = p1.Get("b");
            Symbol     s1c = p1.Get("c");
            Symbol     s2a = p2.Get("a");
            Symbol     s3a = p3.Get("a");
            Symbol     s3b = p3.Get("b");

            Assert.That(s1a.Id == 1 && p1.GetById(1) == s1a);
            Assert.That(s1b.Id == 2 && p1.GetById(2) == s1b);
            Assert.That(s1c.Id == 3 && p1.GetById(3) == s1c);
            Assert.That(s2a.Id == 3 && p2.GetById(3) == s2a);
            Assert.That(s3b.Id == 1 && p3.GetById(1) == s3b);
            Assert.That(s3a.Id == 0 && p3.GetById(0) == s3a);
            Assert.AreEqual(GSymbol.Empty, p1.GetById(0));
            Assert.AreEqual(s1c, p1.GetIfExists("c"));
            Assert.AreEqual(3, p1.TotalCount);
            Assert.AreEqual(null, p2.GetIfExists("c"));
            //Assert.AreEqual(c, p2.GetGlobalOrCreateHere("c"));
            //Assert.AreEqual(p2, p2.GetGlobalOrCreateHere("$!unique^&*").Pool);
        }
Exemple #3
0
 /// <summary>
 /// Creates a new immutable header from the given node factory, symbol table and template table.
 /// </summary>
 /// <param name="nodeFactory"></param>
 /// <param name="symbolTable"></param>
 /// <param name="templateTable"></param>
 public ReaderState(LNodeFactory nodeFactory, IReadOnlyList <string> symbolTable, IReadOnlyList <NodeTemplate> templateTable)
 {
     this.NodeFactory   = nodeFactory;
     this.SymbolTable   = symbolTable;
     this.SymbolPool    = SymbolPool.@new();
     this.TemplateTable = templateTable;
 }
Exemple #4
0
        private void RecycleSymbolView(BaseObject p_baseObj)
        {
            SymbolView symbolView;

            if (!m_SymbolViews.TryGetValue(p_baseObj, out symbolView))
            {
                return;
            }
            SymbolPool symbolPool = null;

            if (p_baseObj is Monster)
            {
                symbolPool = m_SymbolMonsterPrefab;
            }
            else if (p_baseObj is InteractiveObject && ((InteractiveObject)p_baseObj).MinimapVisible)
            {
                switch (((InteractiveObject)p_baseObj).Type)
                {
                case EObjectType.DOOR:
                    symbolPool = m_SymbolDoorPrefab;
                    break;

                case EObjectType.ENTRANCE:
                    symbolPool = m_SymbolEntrancePrefab;
                    break;

                case EObjectType.TELEPORTER:
                    symbolPool = m_SymbolTeleportPrefab;
                    break;

                case EObjectType.NPC_CONTAINER:
                    symbolPool = m_SymbolNpcPrefab;
                    break;

                case EObjectType.TRAP:
                    symbolPool = m_SymbolTrapPrefab;
                    break;
                }
            }
            if (symbolPool == null)
            {
                return;
            }
            symbolView.InitializeView(null);
            symbolPool.Recycle(symbolView);
            m_SymbolViews.Remove(p_baseObj);
        }