public static Rock CreateNew(Layer layer, float x = 0, float y = 0) { Rock instance = null; instance = new Rock(mContentManagerName ?? FlatRedBall.Screens.ScreenManager.CurrentScreen.ContentManagerName, false); instance.AddToManagers(layer); instance.X = x; instance.Y = y; foreach (var list in ListsToAddTo) { if (SortAxis == FlatRedBall.Math.Axis.X && list is PositionedObjectList <Rock> ) { var index = (list as PositionedObjectList <Rock>).GetFirstAfter(x, Axis.X, 0, list.Count); list.Insert(index, instance); } else if (SortAxis == FlatRedBall.Math.Axis.Y && list is PositionedObjectList <Rock> ) { var index = (list as PositionedObjectList <Rock>).GetFirstAfter(y, Axis.Y, 0, list.Count); list.Insert(index, instance); } else { // Sort Z not supported list.Add(instance); } } if (EntitySpawned != null) { EntitySpawned(instance); } return(instance); }