private void RemoveFromFunctions(YarnSpinner yarnSpinner) { if (yarnSpinner.IsNull()) { return; } foreach (var function in registerFunctions) { switch (function.type) { case Component.RegisterFunction.Type.Function: { if (function.function.IsNull()) { break; } yarnSpinner.dialogeRunner.RemoveFunction(function.name); yarnSpinner.RemoveEditorRegisteredFunctions(function.name); break; } case Component.RegisterFunction.Type.ReturningFunction: { if (function.returnfunction.IsNull()) { break; } yarnSpinner.dialogeRunner.RemoveFunction(function.name); yarnSpinner.RemoveEditorRegisteredFunctions(function.name); break; } case Component.RegisterFunction.Type.Commmand: { if (function.command.IsNull()) { break; } yarnSpinner.dialogeRunner.RemoveCommandHandler(function.name); yarnSpinner.RemoveEditorRegisteredCommand(function.name); break; } case Component.RegisterFunction.Type.BlockingCommand: { if (function.blockingCommand.IsNull()) { break; } yarnSpinner.dialogeRunner.RemoveCommandHandler(function.name); yarnSpinner.RemoveEditorRegisteredCommand(function.name); break; } } } }
private void AddToYarnFunctions(YarnSpinner yarnSpinner) { if (yarnSpinner.IsNull()) { return; } foreach (var function in registerFunctions) { switch (function.type) { case Component.RegisterFunction.Type.Function: { if (function.function.IsNull()) { break; } yarnSpinner.dialogeRunner.AddFunction(function.name, function.paramCount, (values) => { function.function.Invoke(values.ToObjects()); }); yarnSpinner.AddEditorRegisteredFunctions(0, function.name, function.paramCount); break; } case Component.RegisterFunction.Type.ReturningFunction: { if (function.returnfunction.IsNull()) { break; } yarnSpinner.dialogeRunner.AddFunction(function.name, function.paramCount, (values) => { return(function.returnfunction.Invoke(values.ToObjects())); }); yarnSpinner.AddEditorRegisteredFunctions(1, function.name, function.paramCount); break; } case Component.RegisterFunction.Type.Commmand: { if (function.command.IsNull()) { break; } yarnSpinner.dialogeRunner.AddCommandHandler(function.name, function.command.Invoke); yarnSpinner.AddEditorRegisteredCommand(0, function.name); break; } case Component.RegisterFunction.Type.BlockingCommand: { if (function.blockingCommand.IsNull()) { break; } yarnSpinner.dialogeRunner.AddCommandHandler(function.name, function.blockingCommand.Invoke); yarnSpinner.AddEditorRegisteredCommand(1, function.name); break; } } } }