示例#1
0
        public Currency(JSONProxy.Item item) : base(item)
        {
            this.Type = ProxyMapper.GetOrbType(item);
            this.ChaosValue = CurrencyHandler.GetChaosValue(this.Type);
            this.StackInfo = ProxyMapper.GetStackInfo(item.Properties);

            this.UniqueIDHash = base.getHash();
        }
        public MultiStacksFlexi(int numOfStacks, int defaultCapacity)
        {
            info = new StackInfo[numOfStacks];
            for (int i = 0; i < numOfStacks; i++) {
                info[i] = new StackInfo(i * defaultCapacity, defaultCapacity);
            }

            values = new int[numOfStacks * defaultCapacity];
        }
示例#3
0
 // Push the current scope.
 public void PushScope()
 {
     stack = new StackInfo(stack);
 }
			// Construct a new scope boundary block.
			public StackInfo(StackInfo next)
					{
						this.type = StackInfoType.None;
						this.value = null;
						this.next = next;
					}
		// Pop the current scope.
		public bool PopScope()
				{
					// exit if there's no stack information to be popped
					if(stack == null) { return false; }

					// find the bottom of the stack, or the next scope boundary
					while(stack != null && stack.type != StackInfoType.None)
					{
						stack = stack.next;
					}

					// pop the scope boundary block and return
					if(stack != null) { stack = stack.next; }
					return true;
				}
		// Get or set the value for a given type.
		public Object this[StackInfoType type]
				{
					get
					{
						// search for the given type
						StackInfo info = stack;
						while(info != null)
						{
							if(info.type == type)
							{
								return info.value;
							}
							info = info.next;
						}
						return null;
					}
					set
					{
						// check for the given type in the current scope
						StackInfo info = stack;
						while(info != null && info.type != StackInfoType.None)
						{
							if(info.type == type)
							{
								// update the value and return
								info.value = value;
								return;
							}
							info = info.next;
						}

						// add a new information block to the current scope
						stack = new StackInfo(type, value, stack);
					}
				}
示例#7
0
 public StackableItem(JSONProxy.Item item) : base(item)
 {
     StackInfo = ProxyMapper.GetStackInfo(item.Properties);
 }
示例#8
0
        /**
         * What is this?
         *
         * Partial implementation of a 2D Clipmap.
         *
         * Beware that my implementation uses a quadtree for 1:2 lod size ratios. This makes the implementation
         * simpler but does differ from the implementations in literature.
         *
         * Additionally literature proposes that there be a invalid zone where data is preloaded. In our case
         * that zone is of size 0.
         *
         * Other than that we have what I jugde some pretty efficient and compact code, the results seem
         * quite agreeable.
         *
         */
        public unsafe void Update(Vector3D localPosition)
        {
            double updateRange = localPosition.Z * 0.1;

            updateRange *= updateRange;

            // Avoid updating unnecessarily when not moving
            if (Vector3D.DistanceSquared(LastPosition, localPosition) < updateRange)
            {
                return;
            }

            LastPosition = localPosition;

            //Local space in plane position
            Vector2D pos = new Vector2D(localPosition.X, localPosition.Y);

            // Prepare per lod queries, since we do depth first this can save up some work.
            for (int lod = m_splits; lod >= 0; --lod)
            {
                m_queryBounds[lod] = new BoundingBox2D(pos - m_lodSizes[lod], pos + m_lodSizes[lod]);
                m_keepBounds[lod]  = new BoundingBox2D(pos - m_keepLodSizes[lod], pos + m_keepLodSizes[lod]);
            }

            // Treat the root specially
            if (localPosition.Z > m_keepLodSizes[m_splits])
            {
                if (Child(m_root, 0) != NullNode)
                {
                    CollapseRoot();
                }
                goto cleanup;
            }

            m_nodesToScanNext.Push(new StackInfo(m_root, Vector2D.Zero, m_size / 2, m_splits));

            // While we have interesting nodes to scan we analyze them.
            fixed(BoundingBox2D *childBounds = m_nodeBoundsTmp)
            fixed(BoundingBox2D * keepBounds  = m_keepBounds)
            fixed(BoundingBox2D * queryBounds = m_queryBounds)
            while (m_nodesToScanNext.Count != 0)
            {
                // Current node to work
                StackInfo current = m_nodesToScanNext.Pop();

                // quick local shorthands
                double size2    = current.Size / 2;
                int    childLod = current.Lod - 1;

                // Mask for the expected status changes for each child
                int collapseMask = 0;

                for (int childIndex = 0; childIndex < 4; ++childIndex)
                {
                    // Calculate bounds for each child
                    childBounds[childIndex].Min = current.Center + My2DClipmapHelpers.CoordsFromIndex[childIndex] * current.Size - current.Size;
                    childBounds[childIndex].Max = current.Center + My2DClipmapHelpers.CoordsFromIndex[childIndex] * current.Size;

                    // Store if the child is interesting
                    if (childBounds[childIndex].Intersects(ref queryBounds[childLod]) &&
                        localPosition.Z <= queryBounds[childLod].Height)
                    {
                        collapseMask |= 1 << childIndex;
                    }
                }

                // If some child is expected to be split we need to ensure that we have at least leaf children.
                if (Child(current.Node, 0) == NullNode)
                {
                    var handler = m_nodeHandlers[current.Node];

                    // Prepare children for splitting
                    IMy2DClipmapNodeHandler[] childHandlers = m_tmpNodeHandlerList;
                    fixed(Node *nodes = m_nodes)
                    for (int childIndex = 0; childIndex < 4; ++childIndex)
                    {
                        var chHandler = m_leafHandlers.Allocate();

                        m_leafHandlers[chHandler] = new THandler();

                        childHandlers[childIndex] = m_leafHandlers[chHandler];
                        nodes[current.Node].Children[childIndex] = ~chHandler;
                    }

                    handler.Split(childBounds, ref childHandlers);

                    handler.Close();
                }

                // Skip investigating past LOD 1
                if (current.Lod == 1)
                {
                    continue;
                }

                // Check children, queue if interesting
                // Interesting means it either is supposed to have content or it has content but is not supposed to.
                for (int childIndex = 0; childIndex < 4; ++childIndex)
                {
                    int chNode = Child(current.Node, childIndex);

                    // If child is interesting we introduce a new node
                    if ((collapseMask & (1 << childIndex)) != 0)
                    {
                        Debug.Assert(chNode != NullNode);

                        // If node is leaf
                        if (chNode < 0)
                        {
                            var handler = m_leafHandlers[~chNode];
                            m_leafHandlers.Free(~chNode);

                            // Allocate new concrete node
                            chNode = AllocNode();
                            m_nodeHandlers[chNode] = handler;

                            fixed(Node *nodes = m_nodes)
                            {
                                Node *child = nodes + chNode;

                                child->Lod = childLod;
                                nodes[current.Node].Children[childIndex] = chNode;
                            }
                        }
                    }
                    // Lazy close to avoid sweetspot
                    else if (chNode >= 0 &&
                             !(childBounds[childIndex].Intersects(ref keepBounds[childLod]) &&
                               localPosition.Z <= keepBounds[childLod].Height))
                    {
                        // If the subtree is utterly uninteresting we clean it up
                        Debug.Assert(chNode != NullNode);

                        fixed(Node *nodes = m_nodes)
                        CollapseSubtree(current.Node, childIndex, nodes);
                    }

                    // Investigate subtrees for nodes to clean and/or spawn
                    if (chNode >= 0)
                    {
                        m_nodesToScanNext.Push(new StackInfo(
                                                   chNode,
                                                   current.Center + My2DClipmapHelpers.CoordsFromIndex[childIndex] * current.Size - size2,
                                                   size2,
                                                   childLod
                                                   ));
                    }
                }
            }

cleanup:
            foreach (var node in m_nodesToDealloc)
            {
                Debug.Assert(node != 0);
                FreeNode(node);
            }

            m_nodesToDealloc.Clear();
        }
示例#9
0
        public override StackSourceFrameIndex GetFrameIndex(StackSourceCallStackIndex callStackIndex)
        {
            StackInfo stackInfo = GetStackInfo(callStackIndex);

            return(stackInfo.FrameIndex);
        }
示例#10
0
 private StackInfo(StackInfo <object> copy)
 {
     this.stack = copy;
 }
示例#11
0
 public StackInfo(int depth, int capacity)
 {
     this.stack = new StackInfo <object> (depth, capacity);
 }
示例#12
0
 public Currency(JSONProxy.Item item) : base(item)
 {
     this.Type       = ProxyMapper.GetOrbType(item);
     this.ChaosValue = CurrencyHandler.GetChaosValue(this.Type);
     this.StackInfo  = ProxyMapper.GetStackInfo(item.Properties);
 }
示例#13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SwitchToStackRequestParams"/> class.
 /// </summary>
 /// <param name="stackInfo">The stack witch contains the level to switch to.</param>
 /// <param name="stackLevel">The stack level to switch to.</param>
 public SwitchToStackRequestParams(StackInfo stackInfo, StackLevel stackLevel)
 {
     this.StackInfo  = stackInfo;
     this.StackLevel = stackLevel;
 }
示例#14
0
 // Construct a new scope boundary block.
 public StackInfo(StackInfo next)
 {
     this.type  = StackInfoType.None;
     this.value = null;
     this.next  = next;
 }
示例#15
0
 // Construct a new stack information block.
 public StackInfo(StackInfoType type, Object value, StackInfo next)
 {
     this.type  = type;
     this.value = value;
     this.next  = next;
 }
示例#16
0
        public override StackSourceCallStackIndex GetCallerIndex(StackSourceCallStackIndex callStackIndex)
        {
            StackInfo stackInfo = GetStackInfo(callStackIndex);

            return(stackInfo.CallerIndex);
        }
示例#17
0
        public int LastCapacityIndex(int stackNum)
        {
            StackInfo stack = info[stackNum];

            return(AdjustIndex(stack.start + stack.capacity - 1));
        }
示例#18
0
 /// <summary>
 /// Initializes a new instance of the <see cref="StackedRequestParams"/> class.
 /// </summary>
 /// <param name="stackInfo">The stack witch contains the level to switch to.</param>
 /// <param name="stackLevel">The stack level to switch to.</param>
 public StackedRequestParams(StackInfo stackInfo, StackLevel stackLevel)
 {
     this.StackInfo  = stackInfo;
     this.StackLevel = stackLevel;
 }
示例#19
0
        public int LastElementIndex(int stackNum)
        {
            StackInfo stack = info[stackNum];

            return(AdjustIndex(stack.start + stack.size - 1));
        }
示例#20
0
 internal void SetStackInfo(StackInfo info)
 {
     this.m_StackInfo = info;
 }
示例#21
0
        public bool IsFull(int stackNum)
        {
            StackInfo stack = info[stackNum];

            return(stack.size == stack.capacity);
        }
		// Constructor.
		public StackManager(Object baseURI, Object xmlLang, Object xmlSpace)
				{
					// Set the top-level scope values.
					stack = new StackInfo(StackInfoType.BaseURI, baseURI, null);
					stack = new StackInfo(StackInfoType.XmlLang, xmlLang, stack);
					stack = new StackInfo(StackInfoType.XmlSpace, xmlSpace, stack);
				}
示例#23
0
        public bool IsEmpty(int stackNum)
        {
            StackInfo stack = info[stackNum];

            return(stack.size == 0);
        }
		// Push the current scope.
		public void PushScope()
				{
					stack = new StackInfo(stack);
				}
示例#25
0
        // Get Top elemtn from stack
        public int Peek(int stackNum)
        {
            StackInfo stack = info[stackNum];

            return(values[LastElementIndex(stackNum)]);
        }
			// Construct a new stack information block.
			public StackInfo(StackInfoType type, Object value, StackInfo next)
					{
						this.type = type;
						this.value = value;
						this.next = next;
					}
示例#27
0
 public CodeObject(string breviary, int line)
 {
     StackInfo = new StackInfo(breviary, line);
 }
示例#28
0
 /// <summary>
 /// Clears the stack info.
 /// </summary>
 /// <param name="stack">The stack.</param>
 private static void ClearStackInfo(StackInfo stack)
 {
     stack.Session.Dispose();
     stack.TopUnitOfWork = null;
     stack.TopUnitOfWork = null;
     stack.Session = null;
 }
示例#29
0
 public StackInfo(StackInfo <T> that)
 {
     this.depth = that.depth;
     this.stack = (T[])that.stack.Clone();
 }