Esempio n. 1
0
        // Make variable from saved data
        public bool MatchSignature(SmoothSaveDataSource dataSource, bool logMismatch = false)
        {
            // Check data
            if (dataSource == null)
            {
                throw new ArgumentNullException("dataSource", "Cannot match signature of null data source");
            }

            // Check each property
            string errorMessage = null;

            if (FsmVariableType != dataSource.FsmVariableType)
            {
                errorMessage = "Variable type mismatch";
            }
            else if (Key != dataSource.Key)
            {
                errorMessage = "Key mismatch";
            }
            else if (FsmVariableName != dataSource.FsmVariableName)
            {
                errorMessage = "Variable name mismatch";
            }
            else if (IsArray != dataSource.IsArray)
            {
                errorMessage = "Array mismatch";
            }
            else if (IsGlobal != dataSource.IsGlobal)
            {
                errorMessage = "Global mismatch";
            }
            else if (SceneName != dataSource.SceneName)
            {
                errorMessage = "Scene name mismatch";
            }
            else if (OwnerName != dataSource.OwnerName)
            {
                errorMessage = "Owner name mismatch";
            }
            else if (FsmName != dataSource.FsmName)
            {
                errorMessage = "FSM name mismatch";
            }

            // Test mismatch
            if (errorMessage != null)
            {
                if (logMismatch)
                {
                    Debug.LogWarning(errorMessage);
                }
                return(false);
            }

            // It's a match!
            return(true);
        }
Esempio n. 2
0
        // Set data source
        public void SetFsmVariable(SmoothSaveDataSource dataSource)
        {
            // Check data source
            if (dataSource == null)
            {
                throw new ArgumentNullException("dataSource", "Cannot set FSM variable from null data source");
            }
            if (FsmVariableType != dataSource.FsmVariableType)
            {
                throw new ArgumentException("Cannot set FSM variable from data source of different type. Old type: " + FsmVariableType + ", New Type: " + dataSource.FsmVariableType);
            }

            // Get FSM variable
            var fsmVariable = dataSource.GetFsmVariable();

            if (fsmVariable == null)
            {
                throw new ArgumentNullException("dataSource.GetFsmVariable()", "Cannot set FSM variable from data source with null FSM variable");
            }
            _fsmVariable = fsmVariable;
        }