private void LoadSingleBlockPrefab(string name, BlockTypes type)
 {
     BlockDefinitions.Add(type, new BlockDefinition(
                              name,
                              type,
                              Resources.Load(PrefabsFolderPath + name) as GameObject
                              ));
 }
Example #2
0
        public void Initialize(string seed)
        {
            TimeCreated = Extensions.GetUnixTimestamp();
            UUID        = Guid.NewGuid().ToByteArray();

            BlockDefinitions = new BlockDefinitions();
            NPCs             = new List <Entity>();

            Seed.Seeds[0].Generate(this, CoreBlock.Grass, CoreBlock.Dirt);
            SeedName = seed;
        }
Example #3
0
        /// <summary>
        /// Generates a compatible block data array for network use
        /// </summary>
        public byte[] Serialize(bool customBlocks, bool blockDefinitions)
        {
            if (customBlocks && blockDefinitions)
            {
                return((byte[])Blocks.Clone());
            }

            ByteBuffer buffer = new ByteBuffer(4 + Blocks.Length);

            buffer.WriteInt(Blocks.Length);
            for (int i = 0; i < Blocks.Length; i++)
            {
                buffer.WriteByte(BlockDefinitions.GetFallback(Blocks[i], customBlocks, blockDefinitions));
            }

            return(buffer.Data);
        }