/// <summary> /// Try to load the current dialog from the save file. /// </summary> private void LoadDialog() { if (GUID != null) { string key = GUID.ToString() + Keys.CURRENT_DIALOG; if (VSave.Get(StaticFolders.DIALOGS, key, out byte[] bytes))
//------------------------------------------------------------------------- // Condition API //------------------------------------------------------------------------- public override bool IsMet() { try { switch (this.Type) { case SupportedType.Integer: return(VSave.Get <int>(Folder, Key) == ExpectedInt); case SupportedType.Float: return(VSave.Get <float>(Folder, Key) == ExpectedFloat); case SupportedType.String: return(VSave.Get <string>(Folder, Key) == ExpectedString); case SupportedType.Boolean: return(VSave.Get <bool>(Folder, Key) == ExpectedBool); default: return(false); } } catch (Exception e) { Debug.LogWarning(e.Message); return(false); } }
//------------------------------------------------------------------------- // Unity API //------------------------------------------------------------------------- protected virtual void Awake() { key = string.IsNullOrEmpty(key) ? Name : key; if (!string.IsNullOrEmpty(key)) { if (VSave.Get(StaticFolders.PEOPLE, key, out bool collected) && collected) { base.OnCollected(); DisableComponents(); } } else { Debug.LogWarning("Lost person \"" + name + "\" is missing the name property!"); } behaviours = new List <Behaviour>(); renderers = new List <Renderer>(); foreach (Behaviour behavior in GetComponents <Behaviour>()) { if (behavior != this) { behaviours.Add(behavior); } } foreach (Renderer renderer in GetComponents <Renderer>()) { if (renderer != this) { renderers.Add(renderer); } } }
/// <summary> /// Retrieve the active status of a single game object. /// </summary> /// <param name="guid">the global ID of the game object to load.</param> private void RetrieveObject(GuidReference guid) { string key = guid.ToString() + Keys.ACTIVE; if (VSave.Get(StaticFolders.BEHAVIOR, key, out bool value)) { guid.gameObject.SetActive(value); } }
/// <summary> /// Retrieve whether or not each component on the object is enabled. /// </summary> public void Retrieve() { if (VSave.Get(StaticFolders.BEHAVIOR, keys, out List <bool> values)) { for (int i = 0; i < values.Count; i++) { ComponentsToTrack[i].enabled = values[i]; } } }
/// <summary> /// Load the previous animator state. /// </summary> private void RetrieveState() { string key = guid.ToString() + Keys.ANIM_STATE; string folder = StaticFolders.ANIMATION; var state = anim.GetCurrentAnimatorStateInfo(0); if (VSave.Get(folder, key, out int stateHashCode)) { anim.Play(stateHashCode); } }
//------------------------------------------------------------------------- // Storable API //------------------------------------------------------------------------- /// <summary> /// Retrieve state information. /// </summary> public void Retrieve() { string key = guid.ToString() + Keys.PARTICLES_ENABLED; if (VSave.Get(StaticFolders.ANIMATION, key, out bool value)) { if (value) { particles.Play(); } else { particles.Stop(); } } }
//------------------------------------------------------------------------- // Unity API //------------------------------------------------------------------------- private void Awake() { GuidComponent guidComponent = gameObject.GetComponent <GuidComponent>(); if (guidComponent != null) { guid = guidComponent.GetGuid().ToString(); if (VSave.Get <bool>(StaticFolders.DESTRUCTIBLE, guid + Keys.KEEP_DESTROYED)) { Destroy(this.gameObject, Delay); } } else { Debug.LogWarning("SelfDestructing object \"" + gameObject.name + "\" needs a GuidComponent!"); } }
public void Retrieve() { string folder = StaticFolders.BEHAVIOR; string key = guid.ToString() + Keys.SOLVED; if (VSave.Get(folder, key, out bool value)) { solved = value; // Resolve the puzzle if it's already been solved. if (solved) { foreach (PuzzleElement element in Elements) { if (element.Solvable) { element.Solve(); } } } } }
/// <summary> /// Load the previous state of an animation parameter /// </summary> /// <param name="param">The animation parameter to load.</param> private void RetrieveParameter(AnimatorControllerParameter param) { string key = guid.ToString() + "_" + param.name; string folder = StaticFolders.ANIMATION; // Set the value based on the parameter type. switch (param.type) { case AnimatorControllerParameterType.Int: { key += Keys.ANIM_INT; if (VSave.Get(folder, key, out int value)) { anim.SetInteger(param.name, value); } break; } case AnimatorControllerParameterType.Bool: { key += Keys.ANIM_BOOL; if (VSave.Get(folder, key, out bool value)) { anim.SetBool(param.name, value); } break; } case AnimatorControllerParameterType.Float: { key += Keys.ANIM_FLOAT; if (VSave.Get(folder, key, out float value)) { anim.SetFloat(param.name, value); } break; } default: return; // Triggers fire one off. They don't need to be stored. } }
public void Retrieve() { string folder = StaticFolders.ANIMATION; string key = guid.ToString() + Keys.POSITION; if (VSave.Get(folder, key, out float[] values))