Exemplo n.º 1
0
    void Awake()
    {
        CurrentState = new SimCapiString("");
        CurrentState.expose("State.Current", true, false);
        CurrentState.setChangeDelegate(
            delegate(string value, ChangedBy changedBy)
        {
            // Internal updates
            if (changedBy == ChangedBy.SIM)
            {
                return;
            }
            CurrentState.setValue(value);
            this.Current = value;
        }
            );

        // Intialize prior state list. Individual items are added at run-time.
        savedStates = new List <SimCapiString>();
    }
Exemplo n.º 2
0
    /// <summary>
    /// Saves the current state to a save slot.
    /// </summary>
    public void Save()
    {
        string state = Current;

        // Ignore save is state has not changed from last save.
        if (state == GetLastSave())
        {
            return;
        }

        SimCapiString capi = new SimCapiString("");

        capi.expose("State.History." + NextId, false, false);
        capi.setValue(state);
        savedStates.Add(capi);
        NextId++;

        // Remove oldest state (except original) if more prior states exist then the PRIOR_STATE_LIMIT.
        if (savedStates.Count > SAVE_STATE_LIMIT)
        {
            savedStates[1].unexpose();
            savedStates.RemoveAt(1);
        }
    }