Пример #1
0
        /// <summary>
        ///     Invoked when a script wants to set the value of an indexed member of this object.
        /// </summary>
        /// <param name="thread">Script thread that invoked this function.</param>
        /// <param name="variable">Symbol describing the member that it wants set.</param>
        /// <param name="value">Value it wants the member to be set to.</param>
        /// <param name="index">Index of member to it wants set.</param>
        /// <returns>True if successfull or false if not.</returns>
        public override bool GetMember(ScriptThread thread, VariableSymbol variable, RuntimeValue indexer)
        {
            if (_nativeObject is ScriptedEntityNode)
            {
                // Check the script process is valid.
                ScriptProcess process = ((ScriptedEntityNode)_nativeObject).ScriptProcess;
                if (process == null) return false;

                // See if we can get the symbol they are after.
                VariableSymbol processSymbol = process.GetSymbol(variable.Identifier, SymbolType.Variable) as VariableSymbol;
                if (processSymbol == null)
                    return false;

                // Grab the variable runtime value. (This can probably be optimized).
                RuntimeValue runtimeValue = process[0].GetRuntimeValueGlobal(processSymbol.Identifier);

                // Check its public.
                if (processSymbol.AccessModifier != SymbolAccessModifier.Public)
                    return false;

                // Check data types are correct.
                if (variable.DataType.DataType != processSymbol.DataType.DataType || processSymbol.DataType.IsArray != true)
                    return false;

                // Grab the arrays variable.
                RuntimeValue indexValue = process[0].GetRuntimeValueArrayElement(runtimeValue.MemoryIndex, indexer.IntegerLiteral);

                // Copy value into calling thread.
                RuntimeValue copiedValue = thread.CopyValueFromThread(indexValue, thread, process[0]);

                // Set the return register to our newly copied value.
                thread.Registers[(int)Register.Return] = copiedValue;

                // Return.
                return true;
            }
            else if (_nativeObject is EntityNode)
            {

            }
            else if (_nativeObject is EmitterNode)
            {

            }
            else if (_nativeObject is TilemapSegmentNode)
            {

            }
            else if ((_nativeObject as SceneNode) != null)
            {

            }

            return false;
        }