コード例 #1
0
        protected void BindControl(GuiStackControl control)
        {
            EntityStack stack = (EntityStack)control.Tag;

            control.Text    = stack.Count.ToString();
            control.Visible = stack.Count > 0;
        }
コード例 #2
0
        private static EntityModel SaturateBasicItemModel(
            Entity itemEntity,
            EntityData entityData,
            bool toLowercase)
        {
            EntityWorld     world       = itemEntity.EntityWorld;
            EntityDataCache entityDatas = WorldCache.GetCache(world).EntityDatas;
            EntityModel     entityModel = new EntityModel();

            // Get basic item details.
            if (toLowercase)
            {
                entityModel.Name = entityData.Name.ToLower();
            }
            else
            {
                entityModel.Name = entityData.Name;
            }
            entityModel.Id = itemEntity.UniqueId;
            // entityModel.Type = entityDatas.GetBasePrototype(itemEntity).Name;

            // Get quantity.
            EntityStack entityStack = itemEntity.GetComponent <EntityStack>();

            if (entityStack == null)
            {
                entityModel.Quantity = 1;
            }
            else
            {
                entityModel.Quantity = entityStack.Quantity;
            }

            return(entityModel);
        }
コード例 #3
0
        internal void SpawnStack(EntityStack stack)
        {
            PositionChunk positionChunk = PositionChunk.CreateFrom(stack.Position);
            Chunk         chunk         = GetChunk(positionChunk);

            chunk.AddEntity(stack);
        }
コード例 #4
0
ファイル: HeadUpDisplay.cs プロジェクト: 67-6f-64/HelloWorld
        private void DrawItem(int i)
        {
            float   scaleAdjust = i == player.SelectedSlotId ? 1.00f : 1f;
            Vector3 postAdjust  = i != player.SelectedSlotId ? new Vector3(0, 4, 0) : new Vector3();

            t.StartDrawingColoredQuads();
            Vector3 pos = new Vector3((i) * frameSize, 0, 0) + postAdjust;

            Camera.Instance.World = Matrix.Multiply(Camera.Instance.World, Matrix.Scaling(new Vector3(frameSize, frameSize, frameSize) * scaleAdjust));
            Camera.Instance.World = Matrix.Multiply(Camera.Instance.World, Matrix.Translation(pos));
            t.Draw(background);

            EntityStack stack = player.Inventory.Slots[i].Content;

            if (stack.IsEmpty)
            {
                return;
            }

            t.StartDrawingTiledQuadsWTF();
            pos += new Vector3(1 + (frameSize - itemSize) / 2f, -1 + (frameSize - itemSize) / 2f, 0);
            Camera.Instance.World = Matrix.Multiply(Camera.Instance.World, Matrix.Scaling(new Vector3(itemSize, itemSize, itemSize) * scaleAdjust));
            Camera.Instance.World = Matrix.Multiply(Camera.Instance.World, Matrix.Translation(pos));
            t.Draw(TileTextures.Instance.GetItemVertexBuffer(stack.Id));

            labels[i].Text     = stack.Count.ToString();
            labels[i].Position = pos;
            labels[i].Render();
        }
コード例 #5
0
        internal override void OnRender(float partialStep)
        {
            float itemSize = this.Size.X;

            t.StartDrawingTiledQuadsWTF();
            Camera.Instance.World = Matrix.Multiply(Camera.Instance.World, Matrix.Scaling(new Vector3(itemSize, itemSize, itemSize)));
            Camera.Instance.World = Matrix.Multiply(Camera.Instance.World, Matrix.Translation(new Vector3(GlobalLocation, 0)));
            EntityStack stack = (EntityStack)Tag;

            t.Draw(TileTextures.Instance.GetItemVertexBuffer(stack.Id));
        }
コード例 #6
0
ファイル: Block.cs プロジェクト: 67-6f-64/HelloWorld
 internal virtual void OnDestroy(PositionBlock pos)
 {
     int[] droppedIds = OnDroppedIds();
     if (droppedIds.Length > 0)
     {
         foreach (int id in droppedIds)
         {
             EntityStack stack = new EntityStack(id, 1);
             DropStack(stack, pos);
         }
     }
 }
コード例 #7
0
ファイル: Block.cs プロジェクト: 67-6f-64/HelloWorld
 protected void DropStack(EntityStack stack, Entities.PositionBlock pos)
 {
     if (stack.IsEmpty)
     {
         return;
     }
     stack.Position = new Vector3(pos.X + 0.5f, pos.Y + 0.5f, pos.Z + 0.5f);
     stack.Yaw      = (float)(MathLibrary.GlobalRandom.NextDouble() * Math.PI);
     stack.Pitch    = (float)(MathLibrary.GlobalRandom.NextDouble() * Math.PI);
     stack.Velocity = new Vector3(
         (float)0.05f * (float)(MathLibrary.GlobalRandom.NextDouble() * 2.0 - 1.0),
         (float)0.25f,
         (float)0.05f * (float)(MathLibrary.GlobalRandom.NextDouble() * 2.0 - 1.0));
     World.Instance.SpawnStack(stack);
 }
コード例 #8
0
        public EntityModel SaturateStackDetails()
        {
            EntityStack stack = this.entity.GetComponent <EntityStack>();

            if (stack == null)
            {
                this.Quantity    = 1;
                this.MaxQuantity = 1;
                return(this);
            }

            this.Quantity    = stack.Quantity;
            this.MaxQuantity = stack.MaxQuantity;

            return(this);
        }
コード例 #9
0
        public EntityStack CraftRecipe()
        {
            TestRecipe();
            EntityStack createdProduct = Product.Content;

            if (createdProduct.IsEmpty)
            {
                return(null);
            }

            // Craft it!
            Product.Content.Clear();
            for (int i = 0; i < Grid.Length; i++)
            {
                if (Grid[i].Content != null)
                {
                    Grid[i].Content.Remove(1);
                }
            }

            return(createdProduct);
        }
コード例 #10
0
        private Signal ScanSignalExpression()
        {
            /*
                This method is kind of a postfix machine, parsing
                infix expressions to postfix expressions (having
                regard to precedence) using the operator stack and
                evaluates the postfix term to an expression tree
                using the expression stack.
            */

            SignalStack expressionStack = new SignalStack(4, 4096);
            EntityStack operatorStack = new EntityStack(4, 4096);

            expressionStack.Push(ScanOperand());
            IEntity lastEntity, topEntity;

            while(true)
            {
                LexerToken ahead = tokenizer.LookaheadFistToken;
                if(!(ahead.IsType(TokenTypes.SymbolIdentifier) || ahead.IsType(TokenTypes.TextIdentifier)))
                    break;
                // TODO: Optimize using TryMethods...
                if(library.ContainsEntity(ahead.Text,InfixNotation.LeftAssociativeInnerOperator))
                    lastEntity = library.LookupEntity(ahead.Text, InfixNotation.LeftAssociativeInnerOperator, 2, 1, 0);
                else if(library.ContainsEntity(ahead.Text, InfixNotation.RightAssociativeInnerOperator))
                    lastEntity = library.LookupEntity(ahead.Text, InfixNotation.RightAssociativeInnerOperator, 2, 1, 0);
                else
                    break;
                tokenizer.Consume();

                while(operatorStack.Count > 0 && IsPrecedenceLeftFirst(operatorStack.Peek(), lastEntity))
                {
                    topEntity = operatorStack.Pop();
                    Signal swap = expressionStack.Pop();
                    Signal s = builder.Function(topEntity, expressionStack.Pop(), swap);
                    expressionStack.Push(s);
                }

                operatorStack.Push(lastEntity);
                expressionStack.Push(ScanOperand());
            }

            while(operatorStack.Count > 0)
            {
                topEntity = operatorStack.Pop();
                Signal swap = expressionStack.Pop();
                Signal s = builder.Function(topEntity, expressionStack.Pop(), swap);
                expressionStack.Push(s);
            }

            Signal ret = expressionStack.Pop();
            system.AddSignalTree(ret, false, false);
            return ret;
        }
コード例 #11
0
ファイル: Block.cs プロジェクト: samuto/HelloWorld
 internal virtual void OnDestroy(PositionBlock pos)
 {
     int[] droppedIds = OnDroppedIds();
     if (droppedIds.Length > 0)
     {
         foreach (int id in droppedIds)
         {
             EntityStack stack = new EntityStack(id, 1);
             DropStack(stack, pos);
         }
     }
 }
コード例 #12
0
ファイル: Block.cs プロジェクト: samuto/HelloWorld
 protected void DropStack(EntityStack stack, Entities.PositionBlock pos)
 {
     if (stack.IsEmpty)
         return;
     stack.Position = new Vector3(pos.X + 0.5f, pos.Y + 0.5f, pos.Z + 0.5f);
     stack.Yaw = (float)(MathLibrary.GlobalRandom.NextDouble() * Math.PI);
     stack.Pitch = (float)(MathLibrary.GlobalRandom.NextDouble() * Math.PI);
     stack.Velocity = new Vector3(
         (float)0.05f * (float)(MathLibrary.GlobalRandom.NextDouble() * 2.0 - 1.0),
         (float)0.25f,
         (float)0.05f * (float)(MathLibrary.GlobalRandom.NextDouble() * 2.0 - 1.0));
     World.Instance.SpawnStack(stack);
 }