public static void Split(this ObjectInstance obj, int number = 1) { var count = obj.Count; if (count <= number || number == 0) { return; } ObjectInstance rest = obj.Clone(); --obj.ObjectIndex.Count; rest.Count = obj.Count - number; obj.Count = number; if (obj.CarriedBy != null) { obj.CarriedBy.Carrying.ToList().Add(rest); rest.CarriedBy = obj.CarriedBy; rest.InRoom = null; rest.InObject = null; } else if (obj.InRoom != null) { obj.InRoom.Contents.Add(rest); rest.CarriedBy = null; rest.InRoom = obj.InRoom; rest.InObject = null; } else if (obj.InObject != null) { obj.InObject.Contents.Add(rest); rest.InObject = obj.InObject; rest.InRoom = null; rest.CarriedBy = null; } }