public override IRestorableComponent saveComponent(GameObject gameObject, IComponentAssigner assigner, GamePersistence.SaveType saveType) { setSaveData(saveType); AutomatedScriptTransfer.TransferScriptsSaving(this, savedDictionary, saveType); return(CreatedSaveableMonoBehaviour); }
protected override void saveComponent(Transform component, GamePersistence.SaveType saveType) { localPosition = new Serializable3DVector(component.localPosition); position = new Serializable3DVector(component.position); rotation = new Serializable3DVector(component.eulerAngles); scale = new Serializable3DVector(component.localScale); }
public override IRestorableComponent saveComponent(GameObject gameObject, IComponentAssigner assigner, GamePersistence.SaveType saveType) { saveComponentValues(gameObject, assigner, saveType); AutomatedScriptTransfer.transferComponentSaving (this, CreatedSaveableComponent.DataContainer); return(CreatedSaveableComponent); }
/// <summary> /// saves all script values by calling the "saveComponent" method for all saveableComponents. /// Also calls this method rekursivly for its children /// </summary> /// <param name="saveState"></param> public void SaveAllBehaviours(GamePersistence.SaveType saveState) { foreach (ISaveableComponent b in saveableComponents) { b.saveComponent(gameObject, this, saveState); } foreach (ISaveableGameObject children in childrenWithPath.getValues()) { children.SaveAllBehaviours(saveState); } ResetAssigner(); }
protected override void saveComponent(BoxCollider component, GamePersistence.SaveType saveType) { base.saveComponent(component, saveType); center = new Serializable3DVector(component.center); size = new Serializable3DVector(component.size); }
public override void saveComponentValues(GameObject gameObject, IComponentAssigner assigner, GamePersistence.SaveType saveType) { Component = assigner.getComponent <T>(); saveComponent(Component, saveType); }
protected abstract void saveComponent(T component, GamePersistence.SaveType saveType);
protected override void saveComponent(SphereCollider component, GamePersistence.SaveType saveType) { base.saveComponent(component, saveType); }
/// <summary> /// will iterate the list of registered inGameISaveableGameObject and have them create a /// SaveableObject which are saved within this list or referenced by other SaveableObjects. /// However this function just stores the data temporary and does not write it into the scene file! /// "DirtyData" is set to true, so this scene will be saved to fíle upon next game save. /// </summary> /// <param name="saveState"></param> public void SaveScene(GamePersistence.SaveType saveState) { List <ISaveableGameObject> empty = new List <ISaveableGameObject>(); SaveScene(saveState, empty); }
/// <summary> /// will iterate the list of registered inGameISaveableGameObject and have them create a /// SaveableObject which are saved within this list or referenced by other SaveableObjects. /// However this function just stores the data temporary and does not write it into the scene file! /// "DirtyData" is set to true, so this scene will be saved to fíle upon next game save. /// </summary> /// <param name="saveState"></param> /// <param name="ignoreForSave">hand any gameobject over that shall not be saved. /// instead their theirs trees of restoreableGameobejcts are returned /// usefull to take gameobject to the next scene</param> /// <returns>this functions returns the saved version of the unsaved objects, since its very /// likely that they shall be transfered to another scene</returns> public List <IRestorableGameObject> SaveScene(GamePersistence.SaveType saveState, List <ISaveableGameObject> ignoreForSave) { List <IRestorableGameObject> result = new List <IRestorableGameObject>(); ///clear current list, and fill it with current objects RestoreableObjectTree.clear(); HirachyTree <ISaveableGameObject> saveableObjectTree = new HirachyTree <ISaveableGameObject>(); Stack <int> currentHirachy; ///reset the hirachy tree before saving again foreach (ISaveableGameObject gameObject in AllInGameObjects) { gameObject.ResetChildNodes(); } ///set parent and children of all objects ///also adds all objects with no saveable parent to root list foreach (ISaveableGameObject gameObject in AllInGameObjects) { ///if the objects should not be saved in the current scene they ///are just ignored for now. since the objects dont use this tree to find ///their parent, the hirachy of the non saved objects are not lost if (!ignoreForSave.Contains(gameObject)) { if (!gameObject.findAndSetParent(out currentHirachy)) { saveableObjectTree.add(gameObject, currentHirachy); } } } ///all the gameObjects with no saveableParent are returning their saveable object, ///which are added to the list. childrens are recursivly added aswell foreach (ITreeNode <ISaveableGameObject> gameObject in saveableObjectTree.getAllNodesWithValues()) { RestoreableObjectTree.add (gameObject.Value.SaveObjectAndPrepareScripts(), gameObject.getFullTreePath()); } ///even though the object is not saved in this scene the restoreable objects are ///still created and returned as result so they can be used in other scenes foreach (ISaveableGameObject gameObject in ignoreForSave) { result.Add(gameObject.SaveObjectAndPrepareScripts()); } IList <ISaveableGameObject> savedObjects = saveableObjectTree.getValues(); ///after all object with their scripts were initiated the scripts values are saved foreach (ISaveableGameObject gameObject in savedObjects) { gameObject.SaveAllBehaviours(saveState); } ///all not saved objects are saved aswell. however their restoreable references ///will not be associated with the current scene. Instead they are returned ///so they can be used in other scenes foreach (ISaveableGameObject gameObject in ignoreForSave) { gameObject.SaveAllBehaviours(saveState); } ///deleting all children for next save saveableObjectTree.clear(); ///since the scene is saved, it needs to be stored to file on the ///next game save DirtyData = true; return(result); }
/// <summary> /// calls "saveScene" for the current scene /// </summary> /// <param name="saveType"></param> public void saveCurrentScene(GamePersistence.SaveType saveType) { currentScene.SaveScene(saveType); }
protected override void saveComponent(T component, GamePersistence.SaveType saveType) { isTrigger = component.isTrigger; isEnabled = component.enabled; }
protected override void saveComponent(Rigidbody component, GamePersistence.SaveType saveType) { isKinematic = component.isKinematic; vel = new Serializable3DVector(component.velocity); angVel = new Serializable3DVector(component.angularVelocity); }
public sealed override void setSaveData(GamePersistence.SaveType saveType) { IsEnabled = enabled; setDataBeforeSaving(saveType); }
protected virtual void setDataBeforeSaving(GamePersistence.SaveType saveType) { }
public abstract void setSaveData(GamePersistence.SaveType saveType);
protected override void saveComponent(MeshRenderer component, GamePersistence.SaveType saveType) { isEnabled = component.enabled; }
public static void TransferStaticScriptsSaving(Type t, Dictionary <string, object> target, GamePersistence.SaveType transferState) { Type savedAttribute = typeof(SaveAttribute); foreach (FieldInfo f in getFieldsFromType(t, typeof(object), false)) { if (f.IsStatic && f.IsDefined(savedAttribute, true)) { SaveAttribute currentSaveAttribute = (SaveAttribute) (f.GetCustomAttributes(savedAttribute, false)[0]); if ((transferState == GamePersistence.SaveType.Game && currentSaveAttribute.saveForScene) || (transferState == GamePersistence.SaveType.Scene && currentSaveAttribute.saveForGame)) { object value = GetTransformedValue(f.GetValue(null)); target.Add(f.Name, value); } } } }
public abstract void saveComponentValues(GameObject gameObject, IComponentAssigner assigner, GamePersistence.SaveType saveType);
/// <summary> /// calls "saveScene" for the current scene /// </summary> /// <param name="saveType"></param> public List <IRestorableGameObject> saveCurrentScene( GamePersistence.SaveType saveType, List <ISaveableGameObject> ignoreForSave) { return(currentScene.SaveScene(saveType, ignoreForSave)); }
public abstract IRestorableComponent saveComponent(GameObject gameObject, IComponentAssigner assigner, GamePersistence.SaveType saveType);