Exemple #1
0
 public FunctionReference(
     int objectReferenceId,
     string methodName,
     Ink.Runtime.Story.VariableObserver observer)
 {
     this.objectReferenceId = objectReferenceId;
     this.methodName        = methodName;
     this.observer          = observer;
 }
Exemple #2
0
    public override void _Ready()
    {
        this.observer = (String varName, object varValue) => {
            if (this.observedVariables.Contains(varName))
            {
                this.EmitSignal(this.ObservedVariableSignalName(varName), varName, this.marshallVariableValue(varValue));
            }
        };

        if (this.AutoLoadStory)
        {
            this.LoadStory();
        }
    }
Exemple #3
0
    public override void _Ready()
    {
        observer = (string varName, object varValue) => {
            if (observedVariables.Contains(varName))
            {
                EmitSignal(ObservedVariableSignalName(varName), varName, MarshallVariableValue(varValue));
            }
        };

        if (AutoLoadStory)
        {
            LoadStory();
        }
    }
Exemple #4
0
    public override void _Ready()
    {
        shouldMarshallVariables = ProjectSettings.HasSetting("ink/marshall_state_variables");

        observer = (String varName, object varValue) => {
            if (observedVariables.Contains(varName))
            {
                EmitSignal(ObservedVariableSignalName(varName), varName, marshallVariableValue(varValue));
            }
        };

        if (AutoLoadStory)
        {
            LoadStory();
        }
    }
Exemple #5
0
    public void observe_variable(string variable_name, Godot.Object gd_object, string method_name)
    {
        if (story == null)
        {
            PushNullStoryError();
            return;
        }

        try
        {
            var instanceId = (int)gd_object.Call("get_instance_id");
            var funcRef    = GD.FuncRef(gd_object, method_name);

            Ink.Runtime.Story.VariableObserver lambda = (string variableName, object value) => {
                funcRef.CallFuncv(new Godot.Collections.Array()
                {
                    variableName, value
                });
            };

            var functionReference = new FunctionReference(instanceId, method_name, lambda);

            if (observers.TryGetValue(variable_name, out List <FunctionReference> referenceList))
            {
                referenceList.Append(functionReference);
            }
            else
            {
                observers[variable_name] = new List <FunctionReference> ()
                {
                    functionReference
                };
            }

            story.ObserveVariable(variable_name, lambda);
        }
        catch (Exception e)
        {
            HandleException(e);
        }
    }