/// <summary>
        /// Generates a snapshot of the world
        /// </summary>
        private SaveData CreateRuntimeSaveData()
        {
            var entities = generator.SpawnedEntities;
            var saveList = new EntitySaveData[entities.Length];

            for (var i = 0; i < entities.Length; ++i)
            {
                var entity    = entities[i];
                var transform = entity.Transform;

                var saveData = new EntitySaveData {
                    id       = entity.AssetId.ToUInt(),
                    uniqueId = entity.UniqueId,
                    scale    = new Vector3Double(transform.localScale),
                    position = new Vector3Double(transform.position),
                    rotation = new QuaternionDouble(transform.rotation),
                    script   = entity.Script
                };
                saveList[i] = saveData;
            }

            var save = settingsData.CreateCopy();

            save.playerPosition = new Vector3Double(Player.Instance.position.ToVector3());
            save.entities       = saveList;

            SaveExtensions.SetStringValue(ref save, "game-manager-script", engine.Script.code);

            return(save);
        }
        /// <summary>
        /// Commits the initial world values into a new world save
        /// </summary>
        public void CommitWorldCreation()
        {
            var uniqueId    = EntityUtilities.GetUniqueId();
            var name        = nameField.text;
            var description = descriptionField.text;
            var save        = saveManager[uniqueId, JsonSaveType.File];

            SaveExtensions.SetStringValue(ref save, "world-name", name);
            SaveExtensions.SetStringValue(ref save, "world-description", description);
            SaveExtensions.SetStringValue(ref save, "world-id", uniqueId);

            saveManager[uniqueId, JsonSaveType.File] = save;
            saveManager.SaveWorld(uniqueId, JsonSaveType.File);

            // Broadcast the world creation to other scripts
            eventTable?.Invoke <string> ("OnWorldCreate", uniqueId);

            Close();
        }
 /// <summary>
 /// Delegate called when the day-night cycle settings change
 /// </summary>
 private void HandleDaySettingsChangeEvent(float time, float scale, bool cycle)
 {
     SaveExtensions.SetNumberValue(ref settingsData, "day-time", time);
     SaveExtensions.SetNumberValue(ref settingsData, "time-scale", scale);
     SaveExtensions.SetBoolValue(ref settingsData, "day-night-cycle", cycle);
 }
 /// <summary>
 /// Delegate called when the world name changes
 /// </summary>
 /// <param name="name">The new name</param>
 private void HandleWorldNameChange(string name)
 {
     SaveExtensions.SetStringValue(ref settingsData, "world-name", name);
 }
 /// <summary>
 /// Delegate called when the world description changes
 /// </summary>
 /// <param name="description">The new description</param>
 private void HandleWorldDescriptionChange(string description)
 {
     SaveExtensions.SetStringValue(ref settingsData, "world-description", description);
 }