Esempio n. 1
0
 /// <summary>
 /// Applies element information and prepares scripts
 /// </summary>
 internal void ApplyElementData(ElementData data)
 {
     elementData     = data;
     gameObject.name = data.name;
     Id = EntityUtilities.GetUniqueId();
     entityObj.SetId(Id);
     entityObj.SetAssetId(data.id.ToHexString());
 }
        /// <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();
        }
Esempio n. 3
0
        /// <summary>
        /// Spawns a placeholder entity with the given name
        /// </summary>
        private Entity SpawnEmptyEntity(string name)
        {
            var go = new GameObject(name);

            var entity = go.AddComponent <EntityGameObject> ();

            entity.ScriptManager = scriptManager;
            entity.ApplyElementData(
                new ElementData {
                name = name,
                id   = 0
            },
                EntityUtilities.GetUniqueId()
                );

            spawnedEntities.Add(entity);

            return(entity.Entity);
        }