Beispiel #1
0
        public override void Parse(AssetIdentifier identifier, AssetsFileReader reader, ResourceAssets resourceAssets)
        {
            MonobehaviourAsset monobehaviour = new MonobehaviourAsset();

            monobehaviour.GameObjectIdentifier = new AssetIdentifier((uint)reader.ReadInt32(), (ulong)reader.ReadInt64());
            monobehaviour.Enabled = reader.ReadInt32(); // unknown but assume this is what it is
            monobehaviour.MonoscriptIdentifier = new AssetIdentifier((uint)reader.ReadInt32(), (ulong)reader.ReadInt64());
            monobehaviour.Name = reader.ReadCountStringInt32();

            // Hack - If we have not yet loaded monoscripts then we are currently processing unit monobehaviours
            // that we do not care about.  Monoscripts should be fully loaded before we actually parse anything
            // we do care about in resource.assets.  If this becomes a problem later, we can do two passes and
            // load monobeahviours in the second pass.
            if (!MonoscriptAssetParser.MonoscriptsByAssetId.ContainsKey(monobehaviour.MonoscriptIdentifier))
            {
                return;
            }

            MonoscriptAsset monoscript = MonoscriptAssetParser.MonoscriptsByAssetId[monobehaviour.MonoscriptIdentifier];

            monobehaviour.MonoscriptName = monoscript.Name;

            MonobehaviourParser monoResourceParser;

            if (monobehaviourParsersByMonoscriptName.TryGetValue(monoscript.Name, out monoResourceParser))
            {
                monoResourceParser.Parse(identifier, monobehaviour.GameObjectIdentifier, reader, resourceAssets);
            }

            MonobehavioursByAssetId.Add(identifier, monobehaviour);
        }
        public override void Parse(AssetIdentifier identifier, AssetsFileReader reader, ResourceAssets resourceAssets, Dictionary <int, string> relativeFileIdToPath)
        {
            MonobehaviourAsset monobehaviour = new MonobehaviourAsset();
            int fileId = reader.ReadInt32();

            monobehaviour.GameObjectIdentifier = new AssetIdentifier(relativeFileIdToPath[fileId], reader.ReadInt64());
            monobehaviour.Enabled = reader.ReadBoolean();
            reader.Align();
            monobehaviour.MonoscriptIdentifier = new AssetIdentifier(relativeFileIdToPath[reader.ReadInt32()], reader.ReadInt64());
            monobehaviour.Name = reader.ReadCountStringInt32();

            // Hack - If we have not yet loaded monoscripts then we are currently processing unit monobehaviours
            // that we do not care about.  Monoscripts should be fully loaded before we actually parse anything
            // we do care about in resource.assets.  If this becomes a problem later, we can do two passes and
            // load monobeahviours in the second pass.
            if (!MonoscriptAssetParser.MonoscriptsByAssetId.ContainsKey(monobehaviour.MonoscriptIdentifier))
            {
                return;
            }

            MonoscriptAsset monoscript = MonoscriptAssetParser.MonoscriptsByAssetId[monobehaviour.MonoscriptIdentifier];

            monobehaviour.MonoscriptName = monoscript.Name;


            if (monobehaviourParsersByMonoscriptName.TryGetValue(monoscript.Name, out MonobehaviourParser monoResourceParser))
            {
                monoResourceParser.Parse(identifier, monobehaviour.GameObjectIdentifier, reader, resourceAssets, relativeFileIdToPath);
            }

            MonobehavioursByAssetId.Add(identifier, monobehaviour);
        }