make copying use deep copies lol

This commit is contained in:
minenice55 2022-07-04 13:09:23 -04:00
parent fb39a7c5fe
commit e2956f7c29
2 changed files with 31 additions and 25 deletions

View file

@ -54,6 +54,12 @@ namespace HeavenStudio
return this.MemberwiseClone();
}
public Entity DeepCopy()
{
//lol the AI generated this
return JsonConvert.DeserializeObject<Entity>(JsonConvert.SerializeObject(this));
}
public object this[string propertyName]
{
get

View file

@ -572,12 +572,6 @@ namespace HeavenStudio.Editor.Track
GameManager.instance.SortEventsList();
tempEntity = en;
}
else
{
GameManager.instance.Beatmap.entities.Add(entity);
GameManager.instance.SortEventsList();
}
// default param value
var game = EventCaller.instance.GetMinigame(eventName.Split(0));
@ -603,6 +597,12 @@ namespace HeavenStudio.Editor.Track
}
}
}
else
{
GameManager.instance.Beatmap.entities.Add(entity);
GameManager.instance.SortEventsList();
}
}
eventObjs.Add(eventObj);
@ -613,7 +613,7 @@ namespace HeavenStudio.Editor.Track
public TimelineEventObj CopyEventObject(Beatmap.Entity e)
{
Beatmap.Entity clone = (Beatmap.Entity) e.Clone();
Beatmap.Entity clone = e.DeepCopy();
TimelineEventObj dup = AddEventObject(clone.datamodel, false, new Vector3(clone.beat, -clone.track * Timeline.instance.LayerHeight()), clone, true, RandomID());
return dup;