Example #1
0
    public override void Deserialize(BinaryReader R)
    {
        base.Deserialize(R);
        int version = R.ReadInt32();

        if (version == 4 || version == 5)
        {
            mBackgroundColor.r = R.ReadSingle();
            mBackgroundColor.g = R.ReadSingle();
            mBackgroundColor.b = R.ReadSingle();

            for (int iX = 0; iX < 100; ++iX)
            {
                for (int iY = 0; iY < 100; ++iY)
                {
                    Color32 tileCol;
                    tileCol.r = R.ReadByte();
                    tileCol.g = R.ReadByte();
                    tileCol.b = R.ReadByte();
                    tileCol.a = 255;

                    mTileColors[iX, iY] = tileCol;

                    mWallX[iX, iY] = R.ReadInt32();
                    mWallZ[iX, iY] = R.ReadInt32();
                }
            }
        }

        if (version == 5)
        {
            mObjects.Clear();
            int metaCount = R.ReadInt32();
            for (int i = 0; i < metaCount; ++i)
            {
                CLevelMetaObject meta = new CLevelMetaObject();
                mObjects.Add(meta);

                meta.mID             = R.ReadInt32();
                meta.mType           = (CLevelMetaObject.EType)R.ReadInt32();
                meta.mSubtype        = R.ReadInt32();
                meta.mOwner          = R.ReadInt32();
                meta.mIdentifier     = R.ReadString();
                meta.mData           = R.ReadInt32();
                meta.mPositionA      = CUtility.ReadVec3(R);
                meta.mPositionB      = CUtility.ReadVec3(R);
                meta.mRotation       = R.ReadInt32();
                meta.mOrientation    = CUtility.ReadVec3(R);
                meta.mExtraIntData   = R.ReadInt32();
                meta.mExtraFloatData = R.ReadSingle();
                meta.mExtraBoolData  = R.ReadBoolean();
                meta.mColor          = CUtility.ReadColor(R);
            }
        }
    }
Example #2
0
    public override void Deserialize(BinaryReader R)
    {
        base.Deserialize(R);
        int version = R.ReadInt32();

        mVersion = version;

        if (version == 11)
        {
            mItemType     = (EItemType)R.ReadInt32();
            mFriendlyName = R.ReadString();
            mFlavourText  = R.ReadString();
            mWidth        = R.ReadInt32();
            mLength       = R.ReadInt32();

            mTiles = new STile[mWidth * 2, mLength * 2];
            for (int iX = 0; iX < mWidth * 2; ++iX)
            {
                for (int iY = 0; iY < mLength * 2; ++iY)
                {
                    mTiles[iX, iY].mSolid = R.ReadBoolean();
                }
            }

            mDurability   = R.ReadInt32();
            mCost         = R.ReadInt32();
            mValue        = R.ReadSingle();
            mStress       = R.ReadSingle();
            mAreaOfEffect = R.ReadSingle();
            mSheetsInMax  = R.ReadInt32();
            mSheetsOutMax = R.ReadInt32();

            string modelName = R.ReadString();
            if (modelName != "")
            {
                mPMAsset = CGame.AssetManager.GetAsset <CModelAsset>(modelName);
            }

            mPMPosition = CUtility.ReadVec3(R);
            mPMRotation = CUtility.ReadVec3(R);

            modelName = R.ReadString();
            if (modelName != "")
            {
                mSMAsset = CGame.AssetManager.GetAsset <CModelAsset>(modelName);
            }

            mSMPosition = CUtility.ReadVec3(R);
            mSMRotation = CUtility.ReadVec3(R);

            int usageSlotCount = R.ReadInt32();
            mUsageSlots.Clear();
            for (int i = 0; i < usageSlotCount; ++i)
            {
                CUsageSlot s = new CUsageSlot();
                s.mEntryPosition = CUtility.ReadVec3(R);
                s.mEntryRotation = CUtility.ReadVec3(R);
                s.mEntrySize     = CUtility.ReadVec3(R);
                s.mUsePosition   = CUtility.ReadVec3(R);
                s.mUseRotation   = CUtility.ReadVec3(R);
                mUsageSlots.Add(s);
            }

            // Desk
            mPaperInPosition  = CUtility.ReadVec3(R);
            mPaperInRotation  = CUtility.ReadVec3(R);
            mPaperOutPosition = CUtility.ReadVec3(R);
            mPaperOutRotation = CUtility.ReadVec3(R);

            // Icon
            mIconCameraPostion = CUtility.ReadVec3(R);
            mIconViewDirection = (EViewDirection)R.ReadInt32();
        }
        else
        {
            Debug.LogError("Can't load item asset '" + mName + "' with version " + version);
        }
    }