From 65cd6aa2944074556571253fd6cf5ea487cbd25c Mon Sep 17 00:00:00 2001 From: Braedon Lewis Date: Wed, 27 Sep 2023 02:11:54 -0400 Subject: [PATCH] fix place undo --- Assets/Scripts/LevelEditor/Commands/Block.cs | 18 +++++------------- .../Scripts/LevelEditor/Timeline/Timeline.cs | 8 +------- 2 files changed, 6 insertions(+), 20 deletions(-) diff --git a/Assets/Scripts/LevelEditor/Commands/Block.cs b/Assets/Scripts/LevelEditor/Commands/Block.cs index e1c8eec2d..dfeb672ee 100644 --- a/Assets/Scripts/LevelEditor/Commands/Block.cs +++ b/Assets/Scripts/LevelEditor/Commands/Block.cs @@ -72,15 +72,15 @@ namespace HeavenStudio.Editor.Commands public class Place : ICommand { - private string placedEventJson; + private RiqEntity placedEntityData; private Guid placedEventID; // Redo times basically private int placeTimes = 0; - public Place(string placedEventJson, Guid placedEventID) + public Place(RiqEntity entity, Guid placedEventID) { - this.placedEventJson = placedEventJson; + this.placedEntityData = entity.DeepCopy(); this.placedEventID = placedEventID; } @@ -88,10 +88,7 @@ namespace HeavenStudio.Editor.Commands { if (placeTimes > 0) { - var entity = JsonConvert.DeserializeObject(placedEventJson, new JsonSerializerSettings() - { - TypeNameHandling = TypeNameHandling.None, - }); + var entity = placedEntityData.DeepCopy(); entity.guid = placedEventID; GameManager.instance.Beatmap.Entities.Add(entity); @@ -108,12 +105,7 @@ namespace HeavenStudio.Editor.Commands var createdEntity = GameManager.instance.Beatmap.Entities.Find(c => c.guid == placedEventID); if (createdEntity != null) { - placedEventJson = JsonConvert.SerializeObject(createdEntity, Formatting.None, new JsonSerializerSettings() - { - TypeNameHandling = TypeNameHandling.None, - NullValueHandling = NullValueHandling.Include, - ReferenceLoopHandling = ReferenceLoopHandling.Ignore, - }); + placedEntityData = createdEntity.DeepCopy(); var marker = TimelineBlockManager.Instance.EntityMarkers[createdEntity.guid]; diff --git a/Assets/Scripts/LevelEditor/Timeline/Timeline.cs b/Assets/Scripts/LevelEditor/Timeline/Timeline.cs index d959b1868..b682cc5b5 100644 --- a/Assets/Scripts/LevelEditor/Timeline/Timeline.cs +++ b/Assets/Scripts/LevelEditor/Timeline/Timeline.cs @@ -950,13 +950,7 @@ namespace HeavenStudio.Editor.Track eventObjs.Add(marker); - var entitySerialize = JsonConvert.SerializeObject(marker.entity, Formatting.None, new JsonSerializerSettings() - { - TypeNameHandling = TypeNameHandling.None, - NullValueHandling = NullValueHandling.Include, - ReferenceLoopHandling = ReferenceLoopHandling.Ignore, - }); - CommandManager.Instance.AddCommand(new Commands.Place(entitySerialize, marker.entity.guid)); + CommandManager.Instance.AddCommand(new Commands.Place(marker.entity, marker.entity.guid)); return marker; }