示例#1
0
        internal void WriteTo(
            BinaryWriter writer,
            AssetNameCollection assetNames,
            ushort minimumVersionThatHasInternalName,
            ushort minimumVersionThatHasEnabledFlag,
            Action derivedWriteTo = null)
        {
            WriteAssetTo(writer, () =>
            {
                writer.Write((uint)(object)ContentType);

                if (Version >= minimumVersionThatHasInternalName)
                {
                    InternalName.WriteTo(writer, assetNames);
                }

                writer.Write((uint)Arguments.Length);

                foreach (var argument in Arguments)
                {
                    argument.WriteTo(writer);
                }

                if (Version >= minimumVersionThatHasEnabledFlag)
                {
                    writer.WriteBooleanUInt32(Enabled);
                }

                derivedWriteTo?.Invoke();
            });
        }
示例#2
0
        private static ScbFile ParseScbData(BinaryReader reader)
        {
            var assetNames = AssetNameCollection.Parse(reader);

            var result = new ScbFile();

            var context = new MapParseContext(assetNames);

            context.PushAsset(nameof(ScbFile), reader.BaseStream.Length);

            Asset.ParseAssets(reader, context, assetName =>
            {
                switch (assetName)
                {
                case ScriptImportSize.AssetName:
                    result.ScriptImportSize = ScriptImportSize.Parse(reader, context);
                    break;

                case PlayerScriptsList.AssetName:
                    result.PlayerScripts = PlayerScriptsList.Parse(reader, context);
                    break;

                case NamedCameras.AssetName:
                    result.NamedCameras = NamedCameras.Parse(reader, context);
                    break;

                case CameraAnimationList.AssetName:
                    result.CameraAnimationList = CameraAnimationList.Parse(reader, context);
                    break;

                case ScriptsPlayers.AssetName:
                    result.ScriptsPlayers = ScriptsPlayers.Parse(reader, context);
                    break;

                case ObjectsList.AssetName:
                    result.ObjectsList = ObjectsList.Parse(reader, context);
                    break;

                case PolygonTriggers.AssetName:
                    result.PolygonTriggers = PolygonTriggers.Parse(reader, context);
                    break;

                case ScriptTeams.AssetName:
                    result.Teams = ScriptTeams.Parse(reader, context);
                    break;

                case WaypointsList.AssetName:
                    result.WaypointsList = WaypointsList.Parse(reader, context);
                    break;

                default:
                    throw new InvalidDataException($"Unknown asset name: {assetName}");
                }
            });

            context.PopAsset();

            return(result);
        }
示例#3
0
 internal void WriteTo(BinaryWriter writer, AssetNameCollection assetNames)
 {
     writer.WriteUInt16PrefixedAsciiString(Name);
     if (Properties != null)
     {
         Properties.WriteTo(writer, assetNames);
     }
 }
示例#4
0
 internal void WriteTo(BinaryWriter writer, AssetNameCollection assetNames)
 {
     WriteAssetTo(writer, () =>
     {
         writer.Write(Unknown1);
         writer.Write(Unknown2);
     });
 }
示例#5
0
 internal void WriteTo(BinaryWriter writer, AssetNameCollection assetNames)
 {
     WriteAssetTo(writer, () =>
     {
         foreach (var team in Teams)
         {
             team.WriteTo(writer, assetNames);
         }
     });
 }
示例#6
0
 internal void WriteTo(BinaryWriter writer, AssetNameCollection assetNames)
 {
     WriteAssetTo(writer, () =>
     {
         foreach (var condition in Conditions)
         {
             writer.Write(assetNames.GetOrCreateAssetIndex(ScriptCondition.AssetName));
             condition.WriteTo(writer, assetNames);
         }
     });
 }
示例#7
0
 internal void WriteTo(BinaryWriter writer, AssetNameCollection assetNames)
 {
     WriteTo(
         writer,
         assetNames,
         MinimumVersionThatHasInternalName,
         MinimumVersionThatHasEnabledFlag,
         () =>
     {
         if (Version >= MinimumVersionThatHasEnabledFlag)
         {
             writer.WriteBooleanUInt32(IsInverted);
         }
     });
 }
示例#8
0
        private void WriteMapDataTo(BinaryWriter writer)
        {
            var assetNames = new AssetNameCollection();

            // Do a first pass just to collect the asset names.
            var tempWriter = BinaryWriter.Null;

            WriteMapDataTo(tempWriter, assetNames);

            // Now write out the asset names to the real writer.
            assetNames.WriteTo(writer);

            // And write out the data to the real writer.
            WriteMapDataTo(writer, assetNames);
        }
示例#9
0
        private void WriteMapDataTo(BinaryWriter writer, AssetNameCollection assetNames)
        {
            if (ScriptImportSize != null)
            {
                writer.Write(assetNames.GetOrCreateAssetIndex(ScriptImportSize.AssetName));
                ScriptImportSize.WriteTo(writer, assetNames);
            }

            writer.Write(assetNames.GetOrCreateAssetIndex(PlayerScriptsList.AssetName));
            PlayerScripts.WriteTo(writer, assetNames);

            if (NamedCameras != null)
            {
                writer.Write(assetNames.GetOrCreateAssetIndex(NamedCameras.AssetName));
                NamedCameras.WriteTo(writer);
            }

            if (CameraAnimationList != null)
            {
                writer.Write(assetNames.GetOrCreateAssetIndex(CameraAnimationList.AssetName));
                CameraAnimationList.WriteTo(writer);
            }

            writer.Write(assetNames.GetOrCreateAssetIndex(ScriptsPlayers.AssetName));
            ScriptsPlayers.WriteTo(writer, assetNames);

            writer.Write(assetNames.GetOrCreateAssetIndex(ObjectsList.AssetName));
            ObjectsList.WriteTo(writer, assetNames);

            if (PolygonTriggers != null)
            {
                writer.Write(assetNames.GetOrCreateAssetIndex(PolygonTriggers.AssetName));
                PolygonTriggers.WriteTo(writer);
            }

            if (TriggerAreas != null)
            {
                writer.Write(assetNames.GetOrCreateAssetIndex(TriggerAreas.AssetName));
                TriggerAreas.WriteTo(writer);
            }

            writer.Write(assetNames.GetOrCreateAssetIndex(ScriptTeams.AssetName));
            Teams.WriteTo(writer, assetNames);

            writer.Write(assetNames.GetOrCreateAssetIndex(WaypointsList.AssetName));
            WaypointsList.WriteTo(writer);
        }
示例#10
0
        internal void WriteTo(BinaryWriter writer, AssetNameCollection assetNames)
        {
            WriteAssetTo(writer, () =>
            {
                if (Version > 1)
                {
                    writer.WriteBooleanUInt32(HasPlayerProperties);
                }

                writer.Write((uint)Players.Length);

                foreach (var player in Players)
                {
                    player.WriteTo(writer, assetNames);
                }
            });
        }
示例#11
0
        internal void WriteTo(BinaryWriter writer, AssetNameCollection assetNames)
        {
            WriteAssetTo(writer, () =>
            {
                foreach (var script in Scripts)
                {
                    writer.Write(assetNames.GetOrCreateAssetIndex(Script.AssetName));
                    script.WriteTo(writer, assetNames);
                }

                foreach (var scriptGroup in ScriptGroups)
                {
                    writer.Write(assetNames.GetOrCreateAssetIndex(ScriptGroup.AssetName));
                    scriptGroup.WriteTo(writer, assetNames);
                }
            });
        }
示例#12
0
        private void WriteMapDataTo(BinaryWriter writer, AssetNameCollection assetNames)
        {
            writer.Write(assetNames.GetOrCreateAssetIndex(PlayerScriptsList.AssetName));
            PlayerScripts.WriteTo(writer, assetNames);

            writer.Write(assetNames.GetOrCreateAssetIndex(ScriptsPlayers.AssetName));
            Players.WriteTo(writer);

            writer.Write(assetNames.GetOrCreateAssetIndex(ObjectsList.AssetName));
            ObjectsList.WriteTo(writer, assetNames);

            writer.Write(assetNames.GetOrCreateAssetIndex(PolygonTriggers.AssetName));
            PolygonTriggers.WriteTo(writer);

            writer.Write(assetNames.GetOrCreateAssetIndex(ScriptTeams.AssetName));
            Teams.WriteTo(writer, assetNames);

            writer.Write(assetNames.GetOrCreateAssetIndex(WaypointsList.AssetName));
            WaypointsList.WriteTo(writer);
        }
示例#13
0
        internal void WriteTo(BinaryWriter writer, AssetNameCollection assetNames)
        {
            WriteAssetTo(writer, () =>
            {
                writer.WriteUInt16PrefixedAsciiString(Name);
                writer.Write(IsActive);
                writer.Write(IsSubroutine);

                foreach (var scriptGroup in Groups)
                {
                    writer.Write(assetNames.GetOrCreateAssetIndex(ScriptGroup.AssetName));
                    scriptGroup.WriteTo(writer, assetNames);
                }

                foreach (var script in Scripts)
                {
                    writer.Write(assetNames.GetOrCreateAssetIndex(Script.AssetName));
                    script.WriteTo(writer, assetNames);
                }
            });
        }
示例#14
0
        internal void WriteTo(BinaryWriter writer, AssetNameCollection assetNames)
        {
            WriteAssetTo(writer, () =>
            {
                writer.WriteUInt16PrefixedAsciiString(Name);

                writer.WriteUInt16PrefixedAsciiString(Comment);
                writer.WriteUInt16PrefixedAsciiString(ConditionsComment);
                writer.WriteUInt16PrefixedAsciiString(ActionsComment);

                writer.Write(IsActive);
                writer.Write(DeactivateUponSuccess);

                writer.Write(ActiveInEasy);
                writer.Write(ActiveInMedium);
                writer.Write(ActiveInHard);

                writer.Write(IsSubroutine);

                if (Version >= 2)
                {
                    writer.Write(EvaluationInterval);

                    if (Version == 5)
                    {
                        writer.Write(UsesEvaluationIntervalType);
                        writer.Write((uint) EvaluationIntervalType);
                    }
                }

                if (Version >= 3)
                {
                    writer.Write(ActionsFireSequentially);
                    writer.Write(LoopActions);
                    writer.Write(LoopCount);
                    writer.Write((byte) SequentialTargetType);
                    writer.WriteUInt16PrefixedAsciiString(SequentialTargetName);
                }

                if (Version >= 4)
                {
                    writer.WriteUInt16PrefixedAsciiString(Unknown);
                }

                if (Version >= 6)
                {
                    writer.Write(Unknown2);
                    writer.Write(Unknown3);
                }

                foreach (var orCondition in OrConditions)
                {
                    writer.Write(assetNames.GetOrCreateAssetIndex(ScriptOrCondition.AssetName));
                    orCondition.WriteTo(writer, assetNames);
                }

                foreach (var scriptAction in ActionsIfTrue)
                {
                    writer.Write(assetNames.GetOrCreateAssetIndex(ScriptAction.AssetNameTrue));
                    scriptAction.WriteTo(writer, assetNames);
                }

                foreach (var scriptAction in ActionsIfFalse)
                {
                    writer.Write(assetNames.GetOrCreateAssetIndex(ScriptAction.AssetNameFalse));
                    scriptAction.WriteTo(writer, assetNames);
                }
            });
        }
示例#15
0
 internal void WriteTo(BinaryWriter writer, AssetNameCollection assetNames)
 {
     WriteTo(writer, assetNames, MinimumVersionThatHasInternalName, MinimumVersionThatHasEnabledFlag);
 }