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(); }); }
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); }
internal void WriteTo(BinaryWriter writer, AssetNameCollection assetNames) { writer.WriteUInt16PrefixedAsciiString(Name); if (Properties != null) { Properties.WriteTo(writer, assetNames); } }
internal void WriteTo(BinaryWriter writer, AssetNameCollection assetNames) { WriteAssetTo(writer, () => { writer.Write(Unknown1); writer.Write(Unknown2); }); }
internal void WriteTo(BinaryWriter writer, AssetNameCollection assetNames) { WriteAssetTo(writer, () => { foreach (var team in Teams) { team.WriteTo(writer, assetNames); } }); }
internal void WriteTo(BinaryWriter writer, AssetNameCollection assetNames) { WriteAssetTo(writer, () => { foreach (var condition in Conditions) { writer.Write(assetNames.GetOrCreateAssetIndex(ScriptCondition.AssetName)); condition.WriteTo(writer, assetNames); } }); }
internal void WriteTo(BinaryWriter writer, AssetNameCollection assetNames) { WriteTo( writer, assetNames, MinimumVersionThatHasInternalName, MinimumVersionThatHasEnabledFlag, () => { if (Version >= MinimumVersionThatHasEnabledFlag) { writer.WriteBooleanUInt32(IsInverted); } }); }
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); }
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); }
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); } }); }
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); } }); }
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); }
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); } }); }
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); } }); }
internal void WriteTo(BinaryWriter writer, AssetNameCollection assetNames) { WriteTo(writer, assetNames, MinimumVersionThatHasInternalName, MinimumVersionThatHasEnabledFlag); }