示例#1
0
        internal bool AddUpdate(int index, BlockID block, PhysicsArgs data, bool overRide = false)
        {
            try {
                int x = index % Width;
                int y = (index / Width) / Length;
                int z = (index / Width) % Length;
                if (x >= Width || y >= Height || z >= Length)
                {
                    return(false);
                }

                if (overRide)
                {
                    // Is the Ext flag just an indicator for the block update?
                    if (data.ExtBlock != 0 && (data.Raw & PhysicsArgs.TypeMask) == 0)
                    {
                        data.Raw &= ~PhysicsArgs.ExtBits;
                    }
                    AddCheck(index, true, data); //Dont need to check physics here....AddCheck will do that
                    Blockchange((ushort)x, (ushort)y, (ushort)z, block, true, data);
                    return(true);
                }

                if (listUpdateExists.TrySetOn(x, y, z))
                {
                }
                else if (block == Block.Sand || block == Block.Gravel)
                {
                    RemoveUpdatesAtPos(index);
                }
                else
                {
                    return(false);
                }

                if ((byte)block != block)
                {
                    data.Data = Block.Obsidian;
                }
                else
                {
                    data.Data = (byte)block;
                }
                Update update; update.Index = index; update.data = data;
                ListUpdate.Add(update);

                if (!physThreadStarted && physics > 0)
                {
                    StartPhysics();
                }
                return(true);
            } catch {
                //s.Log("Warning-PhysicsUpdate");
                //ListUpdate.Add(new Update(b, (byte)type));    //Lousy back up plan
                return(false);
            }
        }
示例#2
0
        internal bool AddUpdate(int b, byte type, bool overRide, PhysicsArgs data)
        {
            try {
                int x = b % Width;
                int y = (b / Width) / Length;
                int z = (b / Width) % Length;
                if (x >= Width || y >= Height || z >= Length)
                {
                    return(false);
                }

                if (overRide)
                {
                    ExtBlock block;
                    block.BlockID = type;
                    block.ExtID   = 0;

                    // Is the Ext flag just an indicator for the block update?
                    if (data.ExtBlock && (data.Raw & PhysicsArgs.TypeMask) == 0)
                    {
                        block.ExtID   = block.BlockID;
                        block.BlockID = Block.custom_block;
                        data.ExtBlock = false;
                    }
                    AddCheck(b, true, data); //Dont need to check physics here....AddCheck will do that
                    Blockchange((ushort)x, (ushort)y, (ushort)z, block, true, data);
                    return(true);
                }

                if (!listUpdateExists.Get(x, y, z))
                {
                    listUpdateExists.Set(x, y, z, true);
                }
                else if (type == Block.Sand || type == Block.Gravel)
                {
                    RemoveUpdatesAtPos(b);
                }
                else
                {
                    return(false);
                }
                ListUpdate.Add(new Update(b, (byte)type, data));

                if (!physThreadStarted && physics > 0)
                {
                    StartPhysics();
                }
                return(true);
            } catch {
                //s.Log("Warning-PhysicsUpdate");
                //ListUpdate.Add(new Update(b, (byte)type));    //Lousy back up plan
                return(false);
            }
        }
示例#3
0
        internal bool AddUpdate(int b, int type, bool overRide, PhysicsArgs data)
        {
            try {
                int x = b % Width;
                int y = (b / Width) / Length;
                int z = (b / Width) % Length;
                if (x >= Width || y >= Height || z >= Length)
                {
                    return(false);
                }

                if (overRide)
                {
                    AddCheck(b, true, data); //Dont need to check physics here....AddCheck will do that
                    Blockchange((ushort)x, (ushort)y, (ushort)z, (byte)type, true, data);
                    return(true);
                }

                if (!listUpdateExists.Get(x, y, z))
                {
                    listUpdateExists.Set(x, y, z, true);
                }
                else if (type == Block.sand || type == Block.gravel)
                {
                    RemoveUpdatesAtPos(b);
                }
                else
                {
                    return(false);
                }

                ListUpdate.Add(new Update(b, (byte)type, data));
                if (!physicssate && physics > 0)
                {
                    StartPhysics();
                }
                return(true);
            } catch {
                //s.Log("Warning-PhysicsUpdate");
                //ListUpdate.Add(new Update(b, (byte)type));    //Lousy back up plan
                return(false);
            }
        }
示例#4
0
 private void AddUpdate(int b, int type)
 {
     try
     {
         if (!ListUpdate.Exists(Update => Update.b == b))  //Checks to see if block is already due for an update
         {
             ListUpdate.Add(new Update(b, (byte)type));
         }
         else
         {
             if (type == 12 || type == 13)   //Sand and gravel overide
             {
                 ListUpdate.RemoveAll(Update => Update.b == b);
                 ListUpdate.Add(new Update(b, (byte)type));
             }
         }
     }
     catch
     {
         //s.Log("Warning-PhysicsUpdate");
         //ListUpdate.Add(new Update(b, (byte)type));    //Lousy back up plan
     }
 }