mirror of
https://github.com/RHeavenStudioPlus/HeavenStudioPlus.git
synced 2024-11-12 20:55:08 +00:00
make copying use deep copies lol
This commit is contained in:
parent
0edd2d005b
commit
13ca36d95e
2 changed files with 31 additions and 25 deletions
|
@ -54,6 +54,12 @@ namespace HeavenStudio
|
||||||
return this.MemberwiseClone();
|
return this.MemberwiseClone();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Entity DeepCopy()
|
||||||
|
{
|
||||||
|
//lol the AI generated this
|
||||||
|
return JsonConvert.DeserializeObject<Entity>(JsonConvert.SerializeObject(this));
|
||||||
|
}
|
||||||
|
|
||||||
public object this[string propertyName]
|
public object this[string propertyName]
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
|
|
@ -572,36 +572,36 @@ namespace HeavenStudio.Editor.Track
|
||||||
GameManager.instance.SortEventsList();
|
GameManager.instance.SortEventsList();
|
||||||
|
|
||||||
tempEntity = en;
|
tempEntity = en;
|
||||||
|
|
||||||
|
// default param value
|
||||||
|
var game = EventCaller.instance.GetMinigame(eventName.Split(0));
|
||||||
|
var ep = EventCaller.instance.GetGameAction(game, eventName.Split(1)).parameters;
|
||||||
|
|
||||||
|
if (ep != null)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < ep.Count; i++)
|
||||||
|
{
|
||||||
|
object returnVal = ep[i].parameter;
|
||||||
|
|
||||||
|
var propertyType = returnVal.GetType();
|
||||||
|
if (propertyType == typeof(EntityTypes.Integer))
|
||||||
|
{
|
||||||
|
returnVal = ((EntityTypes.Integer)ep[i].parameter).val;
|
||||||
|
}
|
||||||
|
else if (propertyType == typeof(EntityTypes.Float))
|
||||||
|
{
|
||||||
|
returnVal = ((EntityTypes.Float)ep[i].parameter).val;
|
||||||
|
}
|
||||||
|
|
||||||
|
tempEntity[ep[i].propertyName] = returnVal;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GameManager.instance.Beatmap.entities.Add(entity);
|
GameManager.instance.Beatmap.entities.Add(entity);
|
||||||
GameManager.instance.SortEventsList();
|
GameManager.instance.SortEventsList();
|
||||||
}
|
}
|
||||||
|
|
||||||
// default param value
|
|
||||||
var game = EventCaller.instance.GetMinigame(eventName.Split(0));
|
|
||||||
var ep = EventCaller.instance.GetGameAction(game, eventName.Split(1)).parameters;
|
|
||||||
|
|
||||||
if (ep != null)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < ep.Count; i++)
|
|
||||||
{
|
|
||||||
object returnVal = ep[i].parameter;
|
|
||||||
|
|
||||||
var propertyType = returnVal.GetType();
|
|
||||||
if (propertyType == typeof(EntityTypes.Integer))
|
|
||||||
{
|
|
||||||
returnVal = ((EntityTypes.Integer)ep[i].parameter).val;
|
|
||||||
}
|
|
||||||
else if (propertyType == typeof(EntityTypes.Float))
|
|
||||||
{
|
|
||||||
returnVal = ((EntityTypes.Float)ep[i].parameter).val;
|
|
||||||
}
|
|
||||||
|
|
||||||
tempEntity[ep[i].propertyName] = returnVal;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
eventObjs.Add(eventObj);
|
eventObjs.Add(eventObj);
|
||||||
|
@ -613,7 +613,7 @@ namespace HeavenStudio.Editor.Track
|
||||||
|
|
||||||
public TimelineEventObj CopyEventObject(Beatmap.Entity e)
|
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());
|
TimelineEventObj dup = AddEventObject(clone.datamodel, false, new Vector3(clone.beat, -clone.track * Timeline.instance.LayerHeight()), clone, true, RandomID());
|
||||||
|
|
||||||
return dup;
|
return dup;
|
||||||
|
|
Loading…
Reference in a new issue