コード例 #1
0
    public override void Load(DataReader reader, bool singleFrameLoad = false)
    {
        if (_isBusy)
        {
            return;
        }

        Debug.Log("Loading world objects...");

        //! Start loading
        int saveVersion = reader.Version;

        //! if the version is too new, don't load
        if (saveVersion > SAVE_VERSION)
        {
            Debug.LogError("Save file is from the future, cannot be read");
            return;
        }

        int count = saveVersion <= 0 ? -saveVersion : reader.ReadInt();

        if (singleFrameLoad)
        {
            for (int i = 0; i < count; ++i)
            {
                int         worldObjectId = saveVersion > 0 ? reader.ReadInt() : 0;
                int         materialId    = saveVersion > 0 ? reader.ReadInt() : 0;
                WorldObject wO            = wOFactory.MakeWorldObject(worldObjectId, materialId);
                wO.Load(reader);
            }

            Debug.Log("World Objects load completed");
        }
        else
        {
            StartCoroutine(LoadObjectsInternal(reader, count, saveVersion));
        }
    }