Ejemplo n.º 1
0
        public void Write(BinaryWriter writer)
        {
            bool recipeNotNull = recipe != null;

            writer.Write(recipeNotNull);
            if (recipeNotNull)
            {
                recipe.Write(writer);
            }

            writer.Write(craftingTimeLeft.Get());
            writer.Write(multiplier.Get());
            writer.Write(isCrafting.Get());

            bool repairItemNotNull = repairItem != null;

            writer.Write(repairItemNotNull);
            if (repairItemNotNull)
            {
                repairItem.Write(writer);
                writer.Write(amountToRepair.Get());
            }

            writer.Write(quality.Get());
            writer.Write(startingEntityId.Get());
        }
        internal void Write(BinaryWriter writer)
        {
            writer.Write(SaveVersionConstants.ENTITY_CREATION_DATA);
            writer.Write(entityClass.Get());
            writer.Write(id.Get());
            writer.Write(lifetime.Get());
            writer.Write(pos.x.Get());

            writer.Write(pos.y.Get());
            writer.Write(pos.z.Get());
            writer.Write(rot.x.Get());
            writer.Write(rot.y.Get());
            writer.Write(rot.z.Get());
            writer.Write(onGround.Get());

            bodyDamage.Write(writer);

            writer.Write(stats != null);
            if (stats != null)
            {
                stats.Write(writer);
            }

            writer.Write(deathTime.Get());

            writer.Write(lootContainer != null);
            if (lootContainer != null)
            {
                writer.Write((int)lootContainer.GetTileEntityType());
                lootContainer.Write(writer);
            }

            writer.Write(homePosition.x.Get());
            writer.Write(homePosition.y.Get());
            writer.Write(homePosition.z.Get());
            writer.Write(homeRange.Get());
            writer.Write((byte)spawnerSource);

            if (entityClass.Get() == Utils.GetMonoHash("item"))
            {
                writer.Write(belongsPlayerId.Get());
                itemStack.Write(writer);
                writer.Write((sbyte)0);
            }

            else if (entityClass.Get() == Utils.GetMonoHash("fallingBlock"))
            {
                writer.Write(blockValue.Get());
            }

            else if (entityClass.Get() == Utils.GetMonoHash("fallingTree"))
            {
                writer.Write(blockPosition.x.Get());
                writer.Write(blockPosition.y.Get());
                writer.Write(blockPosition.z.Get());

                writer.Write(fallTreeDir.x.Get());
                writer.Write(fallTreeDir.y.Get());
                writer.Write(fallTreeDir.z.Get());
            }

            else if ((entityClass.Get() == Utils.GetMonoHash("playerMale")) || (entityClass.Get() == Utils.GetMonoHash("playerFemale")))
            {
                holdingItem.Write(writer);
                writer.Write((byte)teamNumber.Get());
                writer.Write(entityName.Get());
                writer.Write(skinTexture.Get());
                writer.Write(playerProfile != null);
                if (playerProfile != null)
                {
                    playerProfile.Write(writer);
                }
            }

            int num = (int)entityData.Length;

            writer.Write((ushort)num);
            if (num > 0)
            {
                writer.Write(entityData.ToArray());
            }

            writer.Write(traderData != null);
            if (traderData != null)
            {
                writer.Write((int)traderData.GetTileEntityType());
                traderData.Write(writer);
            }
        }
Ejemplo n.º 3
0
        public void Write(BinaryWriter writer)
        {
            writer.Write(entityCreationDataVersion.Get());
            writer.Write(entityClass.Get());
            writer.Write(id.Get());
            writer.Write(lifetime.Get());
            writer.Write(pos.x.Get());

            writer.Write(pos.y.Get());
            writer.Write(pos.z.Get());
            writer.Write(rot.x.Get());
            writer.Write(rot.y.Get());
            writer.Write(rot.z.Get());
            writer.Write(onGround.Get());

            bodyDamage.Write(writer);
            writer.Write(stats != null);

            if (stats != null)
            {
                stats.Write(writer);
            }

            writer.Write((short)deathTime.Get());

            writer.Write(lootContainer != null);
            if (lootContainer != null)
            {
                writer.Write(type.Get());
                lootContainer.Write(writer);
            }

            writer.Write(homePosition.x.Get());
            writer.Write(homePosition.y.Get());
            writer.Write(homePosition.z.Get());
            writer.Write((short)unknownD.Get());
            writer.Write((byte)spawnerSource);

            if (entityClass.Get() == Utils.GetMonoHash("item"))
            {
                writer.Write(belongsPlayerId.Get());
                itemStack.Write(writer);
                writer.Write((sbyte)0);
            }

            else if (entityClass.Get() == Utils.GetMonoHash("fallingBlock"))
            {
                writer.Write(blockValueRawData.Get());
            }

            else if (entityClass.Get() == Utils.GetMonoHash("fallingTree"))
            {
                writer.Write(blockPosition.x.Get());
                writer.Write(blockPosition.y.Get());
                writer.Write(blockPosition.z.Get());

                writer.Write(fallTreeDir.x.Get());
                writer.Write(fallTreeDir.y.Get());
                writer.Write(fallTreeDir.z.Get());
            }

            else if ((entityClass.Get() == Utils.GetMonoHash("playerMale")) || (entityClass.Get() == Utils.GetMonoHash("playerFemale")))
            {
                holdingItem.Write(writer);
                writer.Write((byte)teamNumber.Get());
                writer.Write(entityName.Get());
                writer.Write(skinTexture.Get());
                writer.Write(playerProfile != null);
                if (playerProfile != null)
                {
                    playerProfile.Write(writer);
                }
            }

            int num = (int)entityData.Length;

            writer.Write((ushort)num);
            if (num > 0)
            {
                writer.Write(entityData.ToArray());
            }

            writer.Write(isTraderEntity.Get());
        }
Ejemplo n.º 4
0
 public void Write(BinaryWriter writer)
 {
     itemValue.Write(writer);
     writer.Write(count.Get());
 }