├── .editorconfig ├── .gitattributes ├── .gitignore ├── CHANGELOG.md ├── CHANGELOG.md.meta ├── Compiler.meta ├── Compiler ├── Compiler.Expression.cs ├── Compiler.Expression.cs.meta ├── Compiler.cs ├── Compiler.cs.meta ├── Exodrifter.Rumor.Compiler.asmdef ├── Exodrifter.Rumor.Compiler.asmdef.meta ├── RumorCompiler.cs ├── RumorCompiler.cs.meta ├── RumorParserState.cs ├── RumorParserState.cs.meta ├── Tests.meta └── Tests │ ├── AddChoice.cs │ ├── AddChoice.cs.meta │ ├── AppendDialog.cs │ ├── AppendDialog.cs.meta │ ├── Arithmetic.cs │ ├── Arithmetic.cs.meta │ ├── BindingAction.cs │ ├── BindingAction.cs.meta │ ├── Call.cs │ ├── Call.cs.meta │ ├── Choose.cs │ ├── Choose.cs.meta │ ├── Clear.cs │ ├── Clear.cs.meta │ ├── Comparison.cs │ ├── Comparison.cs.meta │ ├── Exodrifter.Rumor.Compiler.Tests.asmdef │ ├── Exodrifter.Rumor.Compiler.Tests.asmdef.meta │ ├── Identifier.cs │ ├── Identifier.cs.meta │ ├── If.cs │ ├── If.cs.meta │ ├── Jump.cs │ ├── Jump.cs.meta │ ├── Logic.cs │ ├── Logic.cs.meta │ ├── Pause.cs │ ├── Pause.cs.meta │ ├── Return.cs │ ├── Return.cs.meta │ ├── Script.cs │ ├── Script.cs.meta │ ├── SetDialog.cs │ ├── SetDialog.cs.meta │ ├── SetVariable.cs │ ├── SetVariable.cs.meta │ ├── Wait.cs │ └── Wait.cs.meta ├── Editor.meta ├── Editor ├── Exodrifter.Rumor.Editor.asmdef ├── Exodrifter.Rumor.Editor.asmdef.meta ├── RumorImporter.cs └── RumorImporter.cs.meta ├── Engine.meta ├── Engine ├── Binding.meta ├── Binding │ ├── Binding.cs │ ├── Binding.cs.meta │ ├── BindingHint.cs │ ├── BindingHint.cs.meta │ ├── BindingType.cs │ ├── BindingType.cs.meta │ ├── BindingUtil.cs │ └── BindingUtil.cs.meta ├── Exception.meta ├── Exception │ ├── FunctionTypeException.cs │ ├── FunctionTypeException.cs.meta │ ├── UndefinedVariableException.cs │ ├── UndefinedVariableException.cs.meta │ ├── VariableTypeException.cs │ └── VariableTypeException.cs.meta ├── Exodrifter.Rumor.Engine.asmdef ├── Exodrifter.Rumor.Engine.asmdef.meta ├── Expression.meta ├── Expression │ ├── AddExpression.cs │ ├── AddExpression.cs.meta │ ├── AndExpression.cs │ ├── AndExpression.cs.meta │ ├── BooleanBinding.cs │ ├── BooleanBinding.cs.meta │ ├── BooleanFunction.cs │ ├── BooleanFunction.cs.meta │ ├── BooleanLiteral.cs │ ├── BooleanLiteral.cs.meta │ ├── BooleanVariable.cs │ ├── BooleanVariable.cs.meta │ ├── ConcatExpression.cs │ ├── ConcatExpression.cs.meta │ ├── DivideExpression.cs │ ├── DivideExpression.cs.meta │ ├── Expression.cs │ ├── Expression.cs.meta │ ├── FunctionExpression.cs │ ├── FunctionExpression.cs.meta │ ├── GreaterThanExpression.cs │ ├── GreaterThanExpression.cs.meta │ ├── GreaterThanOrEqualExpression.cs │ ├── GreaterThanOrEqualExpression.cs.meta │ ├── IsExpression.cs │ ├── IsExpression.cs.meta │ ├── IsNotExpression.cs │ ├── IsNotExpression.cs.meta │ ├── LessThanExpression.cs │ ├── LessThanExpression.cs.meta │ ├── LessThanOrEqualExpression.cs │ ├── LessThanOrEqualExpression.cs.meta │ ├── LiteralExpression.cs │ ├── LiteralExpression.cs.meta │ ├── MultiplyExpression.cs │ ├── MultiplyExpression.cs.meta │ ├── NotExpression.cs │ ├── NotExpression.cs.meta │ ├── NumberBinding.cs │ ├── NumberBinding.cs.meta │ ├── NumberFunction.cs │ ├── NumberFunction.cs.meta │ ├── NumberLiteral.cs │ ├── NumberLiteral.cs.meta │ ├── NumberVariable.cs │ ├── NumberVariable.cs.meta │ ├── OrExpression.cs │ ├── OrExpression.cs.meta │ ├── StringBinding.cs │ ├── StringBinding.cs.meta │ ├── StringFunction.cs │ ├── StringFunction.cs.meta │ ├── StringLiteral.cs │ ├── StringLiteral.cs.meta │ ├── StringVariable.cs │ ├── StringVariable.cs.meta │ ├── SubstitutionExpression.cs │ ├── SubstitutionExpression.cs.meta │ ├── SubtractExpression.cs │ ├── SubtractExpression.cs.meta │ ├── ToStringExpression.cs │ ├── ToStringExpression.cs.meta │ ├── VariableExpression.cs │ ├── VariableExpression.cs.meta │ ├── XorExpression.cs │ └── XorExpression.cs.meta ├── Nodes.meta ├── Nodes │ ├── AddChoiceNode.cs │ ├── AddChoiceNode.cs.meta │ ├── AppendDialogNode.cs │ ├── AppendDialogNode.cs.meta │ ├── BindingActionNode.cs │ ├── BindingActionNode.cs.meta │ ├── CallNode.cs │ ├── CallNode.cs.meta │ ├── ChooseNode.cs │ ├── ChooseNode.cs.meta │ ├── ClearNode.cs │ ├── ClearNode.cs.meta │ ├── ControlNode.cs │ ├── ControlNode.cs.meta │ ├── DialogNode.cs │ ├── DialogNode.cs.meta │ ├── JumpNode.cs │ ├── JumpNode.cs.meta │ ├── Node.cs │ ├── Node.cs.meta │ ├── PauseNode.cs │ ├── PauseNode.cs.meta │ ├── ReturnNode.cs │ ├── ReturnNode.cs.meta │ ├── SetDialogNode.cs │ ├── SetDialogNode.cs.meta │ ├── SetVariableNode.cs │ ├── SetVariableNode.cs.meta │ ├── WaitNode.cs │ └── WaitNode.cs.meta ├── Rumor.cs ├── Rumor.cs.meta ├── RumorBindings.cs ├── RumorBindings.cs.meta ├── RumorScope.cs ├── RumorScope.cs.meta ├── RumorState.cs ├── RumorState.cs.meta ├── SerializationInfoExtensions.cs ├── SerializationInfoExtensions.cs.meta ├── StackFrame.cs ├── StackFrame.cs.meta ├── Tests.meta ├── Tests │ ├── AppendExecution.cs │ ├── AppendExecution.cs.meta │ ├── AutoAdvanceExecution.cs │ ├── AutoAdvanceExecution.cs.meta │ ├── CallExecution.cs │ ├── CallExecution.cs.meta │ ├── ChoiceExecution.cs │ ├── ChoiceExecution.cs.meta │ ├── ChooseExecution.cs │ ├── ChooseExecution.cs.meta │ ├── ClearExecution.cs │ ├── ClearExecution.cs.meta │ ├── Exodrifter.Rumor.Engine.Tests.asmdef │ ├── Exodrifter.Rumor.Engine.Tests.asmdef.meta │ ├── ExpressionSerialization.cs │ ├── ExpressionSerialization.cs.meta │ ├── JumpExecution.cs │ ├── JumpExecution.cs.meta │ ├── NodeSerialization.cs │ ├── NodeSerialization.cs.meta │ ├── PauseExecution.cs │ ├── PauseExecution.cs.meta │ ├── ReturnExecution.cs │ ├── ReturnExecution.cs.meta │ ├── SayExecution.cs │ ├── SayExecution.cs.meta │ ├── SerializationUtil.cs │ ├── SerializationUtil.cs.meta │ ├── WaitExecution.cs │ └── WaitExecution.cs.meta ├── Types.meta ├── Types │ ├── ClearType.cs │ ├── ClearType.cs.meta │ ├── MoveType.cs │ └── MoveType.cs.meta ├── Util.cs ├── Util.cs.meta ├── Value.meta ├── Value │ ├── BooleanValue.cs │ ├── BooleanValue.cs.meta │ ├── NumberValue.cs │ ├── NumberValue.cs.meta │ ├── StringValue.cs │ ├── StringValue.cs.meta │ ├── Value.cs │ ├── Value.cs.meta │ ├── ValueType.cs │ └── ValueType.cs.meta ├── Yield.cs └── Yield.cs.meta ├── LICENSE.md ├── LICENSE.md.meta ├── Parser.meta ├── Parser ├── Exception.meta ├── Exception │ ├── ExpectedException.cs │ ├── ExpectedException.cs.meta │ ├── FormatException.cs │ ├── FormatException.cs.meta │ ├── MultipleParserException.cs │ ├── MultipleParserException.cs.meta │ ├── ParserException.cs │ ├── ParserException.cs.meta │ ├── ReasonException.cs │ └── ReasonException.cs.meta ├── Exodrifter.Rumor.Parser.asmdef ├── Exodrifter.Rumor.Parser.asmdef.meta ├── Parse.Block.cs ├── Parse.Block.cs.meta ├── Parse.Char.cs ├── Parse.Char.cs.meta ├── Parse.Combinator.cs ├── Parse.Combinator.cs.meta ├── Parse.Double.cs ├── Parse.Double.cs.meta ├── Parse.Indented.cs ├── Parse.Indented.cs.meta ├── Parse.String.cs ├── Parse.String.cs.meta ├── Parse.Surround.cs ├── Parse.Surround.cs.meta ├── Parse.cs ├── Parse.cs.meta ├── Tests.meta ├── Tests │ ├── Block.cs │ ├── Block.cs.meta │ ├── Chain.cs │ ├── Chain.cs.meta │ ├── Char.cs │ ├── Char.cs.meta │ ├── Exodrifter.Rumor.Parser.Tests.asmdef │ ├── Exodrifter.Rumor.Parser.Tests.asmdef.meta │ ├── Many.cs │ ├── Many.cs.meta │ ├── Maybe.cs │ ├── Maybe.cs.meta │ ├── Or.cs │ ├── Or.cs.meta │ ├── Simple.cs │ ├── Simple.cs.meta │ ├── Surround.cs │ ├── Surround.cs.meta │ ├── SurroundBlock.cs │ ├── SurroundBlock.cs.meta │ ├── Then.cs │ ├── Then.cs.meta │ ├── Until.cs │ └── Until.cs.meta ├── Types.meta └── Types │ ├── Maybe.cs │ ├── Maybe.cs.meta │ ├── Parser.cs │ ├── Parser.cs.meta │ ├── ParserState.cs │ ├── ParserState.cs.meta │ ├── ParserUserState.cs │ ├── ParserUserState.cs.meta │ ├── Transaction.cs │ ├── Transaction.cs.meta │ ├── Unit.cs │ └── Unit.cs.meta ├── README.md ├── README.md.meta ├── Tests.meta ├── Tests ├── Exodrifter.Rumor.Tests.asmdef ├── Exodrifter.Rumor.Tests.asmdef.meta ├── Smoke.cs └── Smoke.cs.meta ├── package.json └── package.json.meta /.editorconfig: -------------------------------------------------------------------------------- 1 | root=true 2 | 3 | [*] 4 | indent_style=tab 5 | indent_size=4 6 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | #Disable diffs on meta files 2 | *.meta -diff linguist-generated -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /CHANGELOG.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f000c7cb37a359941a3e3a7da6dc602f 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Compiler.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5c3b946f09e9bed44836398e253297fe 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Compiler/Compiler.Expression.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2f8fce0abbc48bc42b2b5e1c8c68e415 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Compiler/Compiler.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 07e4aee567eb068439974d7d8e89d898 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Compiler/Exodrifter.Rumor.Compiler.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Exodrifter.Rumor.Compiler", 3 | "rootNamespace": "", 4 | "references": [ 5 | "GUID:3b1021c3659174e4d8475c19a9c62fd5", 6 | "GUID:99f7064735b3e3144b8444c435c2d6d4" 7 | ], 8 | "includePlatforms": [], 9 | "excludePlatforms": [], 10 | "allowUnsafeCode": false, 11 | "overrideReferences": false, 12 | "precompiledReferences": [], 13 | "autoReferenced": true, 14 | "defineConstraints": [], 15 | "versionDefines": [], 16 | "noEngineReferences": true 17 | } -------------------------------------------------------------------------------- /Compiler/Exodrifter.Rumor.Compiler.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bbc44ed372f620f4183704e278f0c6a7 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Compiler/RumorCompiler.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ee62da3c9a8ea082c8402dd289e42c3d 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Compiler/RumorParserState.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e57b05a93ae97b39db96f4a72a7bfc6a 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Compiler/Tests.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 851cc9ceeae7e7d4eb9fbcb3b7305828 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Compiler/Tests/AddChoice.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4947d31f9162b884c8e346fcfe9f2b8f 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Compiler/Tests/AppendDialog.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f4f8bf637ecdc0c43ab02dd6afa4c4ae 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Compiler/Tests/Arithmetic.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 30bee7bb7fcc4c64fb56b599d6ba32e0 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Compiler/Tests/BindingAction.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 37c93a9ac7709794e80db54eb78fae5b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Compiler/Tests/Call.cs: -------------------------------------------------------------------------------- 1 | using Exodrifter.Rumor.Engine; 2 | using Exodrifter.Rumor.Parser; 3 | using NUnit.Framework; 4 | 5 | namespace Exodrifter.Rumor.Compiler.Tests 6 | { 7 | public static class Call 8 | { 9 | [Test] 10 | public static void CallSuccess() 11 | { 12 | var state = new ParserState("call start", 4); 13 | 14 | var node = Compiler.Call(state); 15 | Assert.AreEqual(new CallNode("start"), node); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Compiler/Tests/Call.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5e31bf4d46e842141a894ce8e14b922a 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Compiler/Tests/Choose.cs: -------------------------------------------------------------------------------- 1 | using Exodrifter.Rumor.Engine; 2 | using Exodrifter.Rumor.Parser; 3 | using NUnit.Framework; 4 | 5 | namespace Exodrifter.Rumor.Compiler.Tests 6 | { 7 | public static class Choose 8 | { 9 | [Test] 10 | public static void ChooseSuccess() 11 | { 12 | var state = new ParserState("choose", 4); 13 | 14 | var node = Compiler.Choose(state); 15 | Assert.AreEqual(new ChooseNode(), node); 16 | } 17 | 18 | [Test] 19 | public static void ChooseTimeoutJumpSuccess() 20 | { 21 | var state = new ParserState("choose in { 2 } seconds or jump foobar", 4); 22 | 23 | var node = Compiler.Choose(state); 24 | Assert.AreEqual( 25 | new ChooseNode(new NumberLiteral(2), MoveType.Jump, "foobar"), 26 | node 27 | ); 28 | } 29 | 30 | [Test] 31 | public static void ChooseTimeoutCallSuccess() 32 | { 33 | var state = new ParserState("choose in { 2 } seconds or call foobar", 4); 34 | 35 | var node = Compiler.Choose(state); 36 | Assert.AreEqual( 37 | new ChooseNode(new NumberLiteral(2), MoveType.Call, "foobar"), 38 | node 39 | ); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Compiler/Tests/Choose.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d9086bac7ae607840b10e10a45d2e64a 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Compiler/Tests/Clear.cs: -------------------------------------------------------------------------------- 1 | using Exodrifter.Rumor.Engine; 2 | using Exodrifter.Rumor.Parser; 3 | using NUnit.Framework; 4 | 5 | namespace Exodrifter.Rumor.Compiler.Tests 6 | { 7 | public static class Clear 8 | { 9 | #region Node 10 | 11 | [Test] 12 | public static void ClearSuccess() 13 | { 14 | var state = new ParserState("clear", 4); 15 | 16 | var node = Compiler.Clear(state); 17 | Assert.AreEqual(new ClearNode(ClearType.All, null), node); 18 | } 19 | 20 | [Test] 21 | public static void ClearAllSuccess() 22 | { 23 | var state = new ParserState("clear all", 4); 24 | 25 | var node = Compiler.Clear(state); 26 | Assert.AreEqual(new ClearNode(ClearType.All, null), node); 27 | } 28 | 29 | [Test] 30 | public static void ClearChoicesSuccess() 31 | { 32 | var state = new ParserState("clear choices", 4); 33 | 34 | var node = Compiler.Clear(state); 35 | Assert.AreEqual(new ClearNode(ClearType.Choices, null), node); 36 | } 37 | 38 | [Test] 39 | public static void ClearChoiceSuccess() 40 | { 41 | var state = new ParserState("clear choice foobar", 4); 42 | 43 | var node = Compiler.Clear(state); 44 | Assert.AreEqual(new ClearNode(ClearType.Choice, "foobar"), node); 45 | } 46 | 47 | [Test] 48 | public static void ClearDialogSuccess() 49 | { 50 | var state = new ParserState("clear dialog", 4); 51 | 52 | var node = Compiler.Clear(state); 53 | Assert.AreEqual(new ClearNode(ClearType.Dialog, null), node); 54 | } 55 | 56 | #endregion 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /Compiler/Tests/Clear.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 93ee5f27b234f3d48b7688ef5c9762cd 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Compiler/Tests/Comparison.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e474a32f36a669e458331283b44bb3e1 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Compiler/Tests/Exodrifter.Rumor.Compiler.Tests.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Exodrifter.Rumor.Compiler.Tests", 3 | "rootNamespace": "", 4 | "references": [ 5 | "GUID:bbc44ed372f620f4183704e278f0c6a7", 6 | "GUID:3b1021c3659174e4d8475c19a9c62fd5", 7 | "GUID:99f7064735b3e3144b8444c435c2d6d4" 8 | ], 9 | "includePlatforms": [ 10 | "Editor" 11 | ], 12 | "excludePlatforms": [], 13 | "allowUnsafeCode": false, 14 | "overrideReferences": true, 15 | "precompiledReferences": [], 16 | "autoReferenced": false, 17 | "defineConstraints": [ 18 | "UNITY_TEST_FRAMEWORK_EXISTS" 19 | ], 20 | "versionDefines": [ 21 | { 22 | "name": "com.unity.test-framework", 23 | "expression": "0", 24 | "define": "UNITY_TEST_FRAMEWORK_EXISTS" 25 | } 26 | ], 27 | "noEngineReferences": true 28 | } -------------------------------------------------------------------------------- /Compiler/Tests/Exodrifter.Rumor.Compiler.Tests.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 37d76eb5c05fd3544905e6d99b3c9467 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Compiler/Tests/Identifier.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 35de2a7ce40448c45855b54e86b6b1a0 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Compiler/Tests/If.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3b2f1faf33435034788568048e9a8f2b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Compiler/Tests/Jump.cs: -------------------------------------------------------------------------------- 1 | using Exodrifter.Rumor.Engine; 2 | using Exodrifter.Rumor.Parser; 3 | using NUnit.Framework; 4 | 5 | namespace Exodrifter.Rumor.Compiler.Tests 6 | { 7 | public static class Jump 8 | { 9 | [Test] 10 | public static void JumpSuccess() 11 | { 12 | var state = new ParserState("jump start", 4); 13 | 14 | var node = Compiler.Jump(state); 15 | Assert.AreEqual(new JumpNode("start"), node); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Compiler/Tests/Jump.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a61254c3d02dfe444b1e82915fd81aad 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Compiler/Tests/Logic.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e7813e3d945d96e4494270621888305d 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Compiler/Tests/Pause.cs: -------------------------------------------------------------------------------- 1 | using Exodrifter.Rumor.Engine; 2 | using Exodrifter.Rumor.Parser; 3 | using NUnit.Framework; 4 | 5 | namespace Exodrifter.Rumor.Compiler.Tests 6 | { 7 | public static class Pause 8 | { 9 | #region Node 10 | 11 | [Test] 12 | public static void PauseMillisecondsSuccess() 13 | { 14 | var state = new ParserState("pause { 100 } milliseconds", 4); 15 | 16 | var node = Compiler.Pause(state); 17 | Assert.AreEqual(new PauseNode(0.1d), node); 18 | } 19 | 20 | [Test] 21 | public static void PauseMsSuccess() 22 | { 23 | var state = new ParserState("pause { 100 } ms", 4); 24 | 25 | var node = Compiler.Pause(state); 26 | Assert.AreEqual(new PauseNode(0.1d), node); 27 | } 28 | 29 | [Test] 30 | public static void PauseSecondsSuccess() 31 | { 32 | var state = new ParserState("pause { 100 } seconds", 4); 33 | 34 | var node = Compiler.Pause(state); 35 | Assert.AreEqual(new PauseNode(100d), node); 36 | } 37 | 38 | 39 | [Test] 40 | public static void PauseSSuccess() 41 | { 42 | var state = new ParserState("pause { 100 } s", 4); 43 | 44 | var node = Compiler.Pause(state); 45 | Assert.AreEqual(new PauseNode(100d), node); 46 | } 47 | 48 | [Test] 49 | public static void PauseMinutesSuccess() 50 | { 51 | var state = new ParserState("pause { 100 } minutes", 4); 52 | 53 | var node = Compiler.Pause(state); 54 | Assert.AreEqual(new PauseNode(6000d), node); 55 | } 56 | 57 | [Test] 58 | public static void PauseMSuccess() 59 | { 60 | var state = new ParserState("pause { 100 } m", 4); 61 | 62 | var node = Compiler.Pause(state); 63 | Assert.AreEqual(new PauseNode(6000d), node); 64 | } 65 | 66 | #endregion 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /Compiler/Tests/Pause.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0582bf84def28c24f93ee0602e92a7ce 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Compiler/Tests/Return.cs: -------------------------------------------------------------------------------- 1 | using Exodrifter.Rumor.Engine; 2 | using Exodrifter.Rumor.Parser; 3 | using NUnit.Framework; 4 | 5 | namespace Exodrifter.Rumor.Compiler.Tests 6 | { 7 | public static class Return 8 | { 9 | [Test] 10 | public static void ReturnSuccess() 11 | { 12 | var state = new ParserState("return", 4); 13 | 14 | var node = Compiler.Return(state); 15 | Assert.AreEqual(new ReturnNode(), node); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Compiler/Tests/Return.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fe00ad6bc466eec4e9bb0654dda5006a 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Compiler/Tests/Script.cs: -------------------------------------------------------------------------------- 1 | using Exodrifter.Rumor.Engine; 2 | using Exodrifter.Rumor.Parser; 3 | using NUnit.Framework; 4 | using System.Collections.Generic; 5 | 6 | namespace Exodrifter.Rumor.Compiler.Tests 7 | { 8 | using Rumor = Engine.Rumor; 9 | 10 | public static class Script 11 | { 12 | [Test] 13 | public static void ScriptOneSuccess() 14 | { 15 | var state = new ParserState("Alice: Hello world!", 4); 16 | 17 | var result = Compiler.Script(state); 18 | Assert.AreEqual( 19 | new Dictionary> 20 | { 21 | { Rumor.MainIdentifier, new List() 22 | { new SetDialogNode("Alice", "Hello world!") 23 | } 24 | }, 25 | }, 26 | result 27 | ); 28 | 29 | Assert.AreEqual(19, state.Index); 30 | Assert.AreEqual(0, state.IndentIndex); 31 | } 32 | 33 | [Test] 34 | public static void ScriptMultipleSuccess() 35 | { 36 | var state = new ParserState( 37 | "Alice: Hello world!\n" + 38 | "Alice: How are you?\n" + 39 | "Alice: The weather seems nice today.\n" 40 | , 4 41 | ); 42 | 43 | var result = Compiler.Script(state); 44 | Assert.AreEqual( 45 | new Dictionary> 46 | { 47 | { Rumor.MainIdentifier, new List() 48 | { new SetDialogNode("Alice", "Hello world!") 49 | , new SetDialogNode("Alice", "How are you?") 50 | , new SetDialogNode("Alice", "The weather seems nice today.") 51 | } 52 | }, 53 | }, 54 | result 55 | ); 56 | 57 | Assert.AreEqual(76, state.Index); 58 | Assert.AreEqual(0, state.IndentIndex); 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /Compiler/Tests/Script.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 47ff26592a60cc249afdf75614f9dbf5 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Compiler/Tests/SetDialog.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bca51cf5de115f94696c7408235192b4 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Compiler/Tests/SetVariable.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9336b5416385d9345b4eb9fe4ee2a208 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Compiler/Tests/Wait.cs: -------------------------------------------------------------------------------- 1 | using Exodrifter.Rumor.Engine; 2 | using Exodrifter.Rumor.Parser; 3 | using NUnit.Framework; 4 | 5 | namespace Exodrifter.Rumor.Compiler.Tests 6 | { 7 | public static class Wait 8 | { 9 | [Test] 10 | public static void WaitSuccess() 11 | { 12 | var state = new ParserState("wait", 4); 13 | 14 | var node = Compiler.Wait(state); 15 | Assert.AreEqual(new WaitNode(), node); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Compiler/Tests/Wait.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 824524174edf4f94f8d0fb8845361ea7 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7adf52ba8443aa648b014b3696dcd9e9 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Editor/Exodrifter.Rumor.Editor.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Exodrifter.Rumor.Editor", 3 | "rootNamespace": "", 4 | "references": [], 5 | "includePlatforms": [ 6 | "Editor" 7 | ], 8 | "excludePlatforms": [], 9 | "allowUnsafeCode": false, 10 | "overrideReferences": false, 11 | "precompiledReferences": [], 12 | "autoReferenced": true, 13 | "defineConstraints": [], 14 | "versionDefines": [], 15 | "noEngineReferences": false 16 | } -------------------------------------------------------------------------------- /Editor/Exodrifter.Rumor.Editor.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 80d2d07618e8cff498f532e364c6885c 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Editor/RumorImporter.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEditor.AssetImporters; 3 | using System.IO; 4 | 5 | /// 6 | /// Allows the use of files with ".rumor" extensions as a UnityAsset. 7 | /// 8 | namespace Exodrifter.Rumor.Editor 9 | { 10 | [ScriptedImporter(1, "rumor")] 11 | public class RumorImporter : ScriptedImporter 12 | { 13 | private RumorImporter() { } 14 | 15 | public override void OnImportAsset(UnityEditor.AssetImporters.AssetImportContext ctx) 16 | { 17 | var str = File.ReadAllText(ctx.assetPath); 18 | 19 | var textAsset = new TextAsset(str); 20 | ctx.AddObjectToAsset("text", textAsset); 21 | ctx.SetMainObject(textAsset); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Editor/RumorImporter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e2fdc37c0fa7174d8befebc783142f93 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Engine.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 89e6f381b1439504d8d6a8c922352a97 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Engine/Binding.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5521919812dd3ecd2b29e1818f41a431 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Engine/Binding/Binding.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fc364cfe3944908488e8ab688354b1e9 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Engine/Binding/BindingHint.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6bcdc34ea76d0db49840eba4c8cb2a4f 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Engine/Binding/BindingType.cs: -------------------------------------------------------------------------------- 1 | namespace Exodrifter.Rumor.Engine 2 | { 3 | public enum BindingType { Action, Function } 4 | } 5 | -------------------------------------------------------------------------------- /Engine/Binding/BindingType.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 114326aa34c0027468af46fc88eb8144 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Engine/Binding/BindingUtil.cs: -------------------------------------------------------------------------------- 1 | namespace Exodrifter.Rumor.Engine 2 | { 3 | public static class BindingUtil 4 | { 5 | /// 6 | /// Munges a binding name. 7 | /// 8 | /// The binding name to munge. 9 | /// 10 | /// The number of parameters in the binding. 11 | /// 12 | /// The munged name 13 | public static string MungeName(BindingType type, string name, int paramCount) 14 | { 15 | return string.Format("{0}:{1}@{2}", type, name, paramCount); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Engine/Binding/BindingUtil.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6187dcae5320b3b4f9e97f435198524c 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Engine/Exception.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 72bb840e82cf68cd49ec87e793c342ca 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Engine/Exception/FunctionTypeException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Exodrifter.Rumor.Engine 4 | { 5 | public class FunctionTypeException : Exception 6 | { 7 | public FunctionTypeException(string message) : base(message) { } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Engine/Exception/FunctionTypeException.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f08f903f42349cbb2987e6de85339555 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Engine/Exception/UndefinedVariableException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Exodrifter.Rumor.Engine 4 | { 5 | public class UndefinedVariableException : Exception 6 | { 7 | public UndefinedVariableException(string message) : base(message) { } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Engine/Exception/UndefinedVariableException.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4ad99c2dc1c07754bb836cd3b9388726 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Engine/Exception/VariableTypeException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Exodrifter.Rumor.Engine 4 | { 5 | public class VariableTypeException : Exception 6 | { 7 | public VariableTypeException(string message) : base(message) { } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Engine/Exception/VariableTypeException.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4e32ef89dc9febc41a9d2fe776bca9f6 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Engine/Exodrifter.Rumor.Engine.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Exodrifter.Rumor.Engine", 3 | "references": [], 4 | "includePlatforms": [], 5 | "excludePlatforms": [], 6 | "allowUnsafeCode": false, 7 | "overrideReferences": false, 8 | "precompiledReferences": [], 9 | "autoReferenced": true, 10 | "defineConstraints": [], 11 | "versionDefines": [], 12 | "noEngineReferences": true 13 | } -------------------------------------------------------------------------------- /Engine/Exodrifter.Rumor.Engine.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3b1021c3659174e4d8475c19a9c62fd5 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Engine/Expression.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 603cd90c63b71bf4e9c5a81adf82af2e 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Engine/Expression/AddExpression.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.Serialization; 3 | 4 | namespace Exodrifter.Rumor.Engine 5 | { 6 | [Serializable] 7 | public class AddExpression : Expression, ISerializable 8 | { 9 | internal readonly Expression l; 10 | internal readonly Expression r; 11 | 12 | public AddExpression(Expression l, Expression r) 13 | { 14 | this.l = l; 15 | this.r = r; 16 | } 17 | 18 | public override Value Evaluate(RumorScope scope, RumorBindings bindings) 19 | { 20 | return l.Evaluate(scope, bindings).AsNumber() 21 | + r.Evaluate(scope, bindings).AsNumber(); 22 | } 23 | 24 | public override Expression Simplify() 25 | { 26 | if (l is NumberLiteral && r is NumberLiteral) 27 | { 28 | var left = l as NumberLiteral; 29 | var right = r as NumberLiteral; 30 | 31 | return new NumberLiteral( 32 | left.Value.AsNumber() + right.Value.AsNumber() 33 | ); 34 | } 35 | else 36 | { 37 | var left = l.Simplify(); 38 | var right = r.Simplify(); 39 | 40 | if (l == left && r == right) 41 | { 42 | return this; 43 | } 44 | else 45 | { 46 | return new AddExpression(left, right).Simplify(); 47 | } 48 | } 49 | } 50 | 51 | #region Equality 52 | 53 | public override bool Equals(object obj) 54 | { 55 | return Equals(obj as AddExpression); 56 | } 57 | 58 | public bool Equals(AddExpression other) 59 | { 60 | if (other == null) 61 | { 62 | return false; 63 | } 64 | 65 | return Equals(l, other.l) 66 | && Equals(r, other.r); 67 | } 68 | 69 | public override int GetHashCode() 70 | { 71 | return Util.GetHashCode(l, r); 72 | } 73 | 74 | #endregion 75 | 76 | #region Serialization 77 | 78 | public AddExpression(SerializationInfo info, StreamingContext context) 79 | { 80 | l = info.GetValue("l"); 81 | r = info.GetValue("r"); 82 | } 83 | 84 | public override void GetObjectData 85 | (SerializationInfo info, StreamingContext context) 86 | { 87 | info.AddValue("l", l); 88 | info.AddValue("r", r); 89 | } 90 | 91 | #endregion 92 | 93 | public override string ToString() 94 | { 95 | return "(" + l.ToString() + " + " + r.ToString() + ")"; 96 | } 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /Engine/Expression/AddExpression.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d95c215aade69f3498fd6fc3adcb47d7 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Engine/Expression/AndExpression.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.Serialization; 3 | 4 | namespace Exodrifter.Rumor.Engine 5 | { 6 | [Serializable] 7 | public class AndExpression : Expression, ISerializable 8 | { 9 | private readonly Expression l; 10 | private readonly Expression r; 11 | 12 | public AndExpression(Expression l, Expression r) 13 | { 14 | this.l = l; 15 | this.r = r; 16 | } 17 | 18 | public override Value Evaluate(RumorScope scope, RumorBindings bindings) 19 | { 20 | return l.Evaluate(scope, bindings).AsBoolean() 21 | && r.Evaluate(scope, bindings).AsBoolean(); 22 | } 23 | 24 | public override Expression Simplify() 25 | { 26 | if (l is BooleanLiteral && r is BooleanLiteral) 27 | { 28 | var left = l as BooleanLiteral; 29 | var right = r as BooleanLiteral; 30 | 31 | return new BooleanLiteral( 32 | left.Value.AsBoolean() && right.Value.AsBoolean() 33 | ); 34 | } 35 | else 36 | { 37 | var left = l.Simplify(); 38 | var right = r.Simplify(); 39 | 40 | if (l == left && r == right) 41 | { 42 | return this; 43 | } 44 | else 45 | { 46 | return new AndExpression(left, right).Simplify(); 47 | } 48 | } 49 | } 50 | 51 | #region Equality 52 | 53 | public override bool Equals(object obj) 54 | { 55 | return Equals(obj as AndExpression); 56 | } 57 | 58 | public bool Equals(AndExpression other) 59 | { 60 | if (other == null) 61 | { 62 | return false; 63 | } 64 | 65 | return Equals(l, other.l) 66 | && Equals(r, other.r); 67 | } 68 | 69 | public override int GetHashCode() 70 | { 71 | return Util.GetHashCode(l, r); 72 | } 73 | 74 | #endregion 75 | 76 | #region Serialization 77 | 78 | public AndExpression(SerializationInfo info, StreamingContext context) 79 | { 80 | l = info.GetValue("l"); 81 | r = info.GetValue("r"); 82 | } 83 | 84 | public override void GetObjectData 85 | (SerializationInfo info, StreamingContext context) 86 | { 87 | info.AddValue("l", l); 88 | info.AddValue("r", r); 89 | } 90 | 91 | #endregion 92 | 93 | public override string ToString() 94 | { 95 | return "(" + l.ToString() + " and " + r.ToString() + ")"; 96 | } 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /Engine/Expression/AndExpression.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0e002204a1c154645a3cceaaa50ba800 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Engine/Expression/BooleanBinding.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.Serialization; 3 | 4 | namespace Exodrifter.Rumor.Engine 5 | { 6 | [Serializable] 7 | public class BooleanBinding : Expression, ISerializable 8 | { 9 | private readonly string id; 10 | private Expression[] param; 11 | 12 | public BooleanBinding(string id, params Expression[] param) 13 | { 14 | this.id = id; 15 | this.param = param; 16 | } 17 | 18 | public override Value Evaluate(RumorScope scope, RumorBindings bindings) 19 | { 20 | object[] ps = new object[param.Length]; 21 | for (int i = 0; i < param.Length; ++i) 22 | { 23 | ps[i] = param[i].Evaluate(scope, bindings).InternalValue; 24 | } 25 | 26 | var value = bindings.CallBinding(BindingType.Function, id, ps); 27 | if (value == null) 28 | { 29 | throw new VariableTypeException( 30 | "Function \"" + id + "\" returned null!" 31 | ); 32 | } 33 | if (!(value is bool)) 34 | { 35 | throw new VariableTypeException( 36 | "Function \"" + id + "\" did not return a boolean!" 37 | ); 38 | } 39 | 40 | return new BooleanValue((bool)value); 41 | } 42 | 43 | public override Expression Simplify() 44 | { 45 | return this; 46 | } 47 | 48 | #region Equality 49 | 50 | public override bool Equals(object obj) 51 | { 52 | return Equals(obj as BooleanBinding); 53 | } 54 | 55 | public bool Equals(BooleanBinding other) 56 | { 57 | if (other == null) 58 | { 59 | return false; 60 | } 61 | 62 | return Equals(id, other.id); 63 | } 64 | 65 | public override int GetHashCode() 66 | { 67 | return Util.GetHashCode(id); 68 | } 69 | 70 | #endregion 71 | 72 | #region Serialization 73 | 74 | public BooleanBinding 75 | (SerializationInfo info, StreamingContext context) 76 | : base(info, context) 77 | { 78 | id = info.GetValue("id"); 79 | param = info.GetValue("param"); 80 | } 81 | 82 | public override void GetObjectData 83 | (SerializationInfo info, StreamingContext context) 84 | { 85 | info.AddValue("id", id); 86 | info.AddValue("param", param); 87 | } 88 | 89 | #endregion 90 | 91 | public override string ToString() 92 | { 93 | string[] ps = new string[param.Length]; 94 | for (int i = 0; i < param.Length; ++i) 95 | { 96 | ps[i] = param[i].ToString(); 97 | } 98 | 99 | return id + "(" + string.Join(", ", ps) + ")"; 100 | } 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /Engine/Expression/BooleanBinding.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c52b9e205126f178193dc3332af26cad 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Engine/Expression/BooleanFunction.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c707c29ee1edd0815ad9b36894db46a1 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Engine/Expression/BooleanLiteral.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.Serialization; 3 | 4 | namespace Exodrifter.Rumor.Engine 5 | { 6 | [Serializable] 7 | public class BooleanLiteral : LiteralExpression, ISerializable 8 | { 9 | public BooleanLiteral(BooleanValue value) : base(value) { } 10 | public BooleanLiteral(bool value) : base(new BooleanValue(value)) { } 11 | 12 | #region Equality 13 | 14 | public override bool Equals(object obj) 15 | { 16 | return Equals(obj as BooleanLiteral); 17 | } 18 | 19 | public bool Equals(BooleanLiteral other) 20 | { 21 | if (other == null) 22 | { 23 | return false; 24 | } 25 | 26 | return Equals(Value, other.Value); 27 | } 28 | 29 | public override int GetHashCode() 30 | { 31 | return Util.GetHashCode(Value); 32 | } 33 | 34 | #endregion 35 | 36 | #region Serialization 37 | 38 | public BooleanLiteral(SerializationInfo info, StreamingContext context) 39 | : base(info, context) { } 40 | 41 | #endregion 42 | 43 | public override string ToString() 44 | { 45 | return Value.AsBoolean() ? "true" : "false"; 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /Engine/Expression/BooleanLiteral.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 133e7c2d05305cc4cace54ad9913861d 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Engine/Expression/BooleanVariable.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.Serialization; 3 | 4 | namespace Exodrifter.Rumor.Engine 5 | { 6 | [Serializable] 7 | public class BooleanVariable : Expression, ISerializable 8 | { 9 | private readonly string name; 10 | 11 | public BooleanVariable(string name) 12 | { 13 | this.name = name; 14 | } 15 | 16 | public override Value Evaluate(RumorScope scope, RumorBindings _) 17 | { 18 | var value = scope.Get(name); 19 | if (value == null) 20 | { 21 | throw new UndefinedVariableException( 22 | "Variable \"" + name+ "\" has not been defined yet!" 23 | ); 24 | } 25 | if (!(value is BooleanValue)) 26 | { 27 | throw new VariableTypeException( 28 | "Variable is not a boolean!" 29 | ); 30 | } 31 | 32 | return (BooleanValue)value; 33 | } 34 | 35 | public override Expression Simplify() 36 | { 37 | return this; 38 | } 39 | 40 | #region Equality 41 | 42 | public override bool Equals(object obj) 43 | { 44 | return Equals(obj as BooleanVariable); 45 | } 46 | 47 | public bool Equals(BooleanVariable other) 48 | { 49 | if (other == null) 50 | { 51 | return false; 52 | } 53 | 54 | return Equals(name, other.name); 55 | } 56 | 57 | public override int GetHashCode() 58 | { 59 | return name.GetHashCode(); 60 | } 61 | 62 | #endregion 63 | 64 | #region Serialization 65 | 66 | public BooleanVariable 67 | (SerializationInfo info, StreamingContext context) 68 | { 69 | name = info.GetValue("name"); 70 | } 71 | 72 | public override void GetObjectData 73 | (SerializationInfo info, StreamingContext context) 74 | { 75 | info.AddValue("name", name); 76 | } 77 | 78 | #endregion 79 | 80 | public override string ToString() 81 | { 82 | return name; 83 | } 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /Engine/Expression/BooleanVariable.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4353dfcd38f830848a342928b50c5d33 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Engine/Expression/ConcatExpression.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7c2f50c116887b34d941b3408d60f01c 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Engine/Expression/DivideExpression.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.Serialization; 3 | 4 | namespace Exodrifter.Rumor.Engine 5 | { 6 | [Serializable] 7 | public class DivideExpression : Expression, ISerializable 8 | { 9 | private readonly Expression l; 10 | private readonly Expression r; 11 | 12 | public DivideExpression 13 | (Expression l, Expression r) 14 | { 15 | this.l = l; 16 | this.r = r; 17 | } 18 | 19 | public override Value Evaluate(RumorScope scope, RumorBindings bindings) 20 | { 21 | return l.Evaluate(scope, bindings).AsNumber() 22 | / r.Evaluate(scope, bindings).AsNumber(); 23 | } 24 | 25 | public override Expression Simplify() 26 | { 27 | if (l is NumberLiteral && r is NumberLiteral) 28 | { 29 | var left = l as NumberLiteral; 30 | var right = r as NumberLiteral; 31 | 32 | return new NumberLiteral( 33 | left.Value.AsNumber() / right.Value.AsNumber() 34 | ); 35 | } 36 | else 37 | { 38 | var left = l.Simplify(); 39 | var right = r.Simplify(); 40 | 41 | if (l == left && r == right) 42 | { 43 | return this; 44 | } 45 | else 46 | { 47 | return new DivideExpression(left, right).Simplify(); 48 | } 49 | } 50 | } 51 | 52 | #region Equality 53 | 54 | public override bool Equals(object obj) 55 | { 56 | return Equals(obj as DivideExpression); 57 | } 58 | 59 | public bool Equals(DivideExpression other) 60 | { 61 | if (other == null) 62 | { 63 | return false; 64 | } 65 | 66 | return Equals(l, other.l) 67 | && Equals(r, other.r); 68 | } 69 | 70 | public override int GetHashCode() 71 | { 72 | return Util.GetHashCode(l, r); 73 | } 74 | 75 | #endregion 76 | 77 | #region Serialization 78 | 79 | public DivideExpression 80 | (SerializationInfo info, StreamingContext context) 81 | { 82 | l = info.GetValue("l"); 83 | r = info.GetValue("r"); 84 | } 85 | 86 | public override void GetObjectData 87 | (SerializationInfo info, StreamingContext context) 88 | { 89 | info.AddValue("l", l); 90 | info.AddValue("r", r); 91 | } 92 | 93 | #endregion 94 | 95 | public override string ToString() 96 | { 97 | return "(" + l.ToString() + " / " + r.ToString() + ")"; 98 | } 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /Engine/Expression/DivideExpression.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 65379e81dc0c16443a2d68482f7b5eec 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Engine/Expression/Expression.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.Serialization; 3 | 4 | namespace Exodrifter.Rumor.Engine 5 | { 6 | [Serializable] 7 | public abstract class Expression : ISerializable 8 | { 9 | public Expression() { } 10 | 11 | public abstract Value Evaluate(RumorScope scope, RumorBindings bindings); 12 | 13 | public abstract Expression Simplify(); 14 | 15 | public override bool Equals(object obj) 16 | { 17 | return base.Equals(obj); 18 | } 19 | 20 | public override int GetHashCode() 21 | { 22 | return base.GetHashCode(); 23 | } 24 | 25 | public static bool operator ==(Expression l, Expression r) 26 | { 27 | if (ReferenceEquals(l, r)) 28 | { 29 | return true; 30 | } 31 | if (l as object == null || r as object == null) 32 | { 33 | return false; 34 | } 35 | return l.Equals(r); 36 | } 37 | 38 | public static bool operator !=(Expression l, Expression r) 39 | { 40 | return !(l == r); 41 | } 42 | 43 | #region Serialization 44 | 45 | public Expression(SerializationInfo info, StreamingContext context) { } 46 | 47 | public abstract void GetObjectData 48 | (SerializationInfo info, StreamingContext context); 49 | 50 | #endregion 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /Engine/Expression/Expression.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 33d697d59fa50e7408e98731f02b7fc2 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Engine/Expression/FunctionExpression.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.Serialization; 3 | 4 | namespace Exodrifter.Rumor.Engine 5 | { 6 | [Serializable] 7 | public abstract class FunctionExpression : Expression, ISerializable 8 | { 9 | public FunctionExpression() {} 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Engine/Expression/FunctionExpression.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b09a3c150533db8af9de63e2e0e3bc48 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Engine/Expression/GreaterThanExpression.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.Serialization; 3 | 4 | namespace Exodrifter.Rumor.Engine 5 | { 6 | [Serializable] 7 | public class GreaterThanExpression : Expression, ISerializable 8 | { 9 | internal readonly Expression l; 10 | internal readonly Expression r; 11 | 12 | public GreaterThanExpression(Expression l, Expression r) 13 | { 14 | this.l = l; 15 | this.r = r; 16 | } 17 | 18 | public override Value Evaluate(RumorScope scope, RumorBindings bindings) 19 | { 20 | return new BooleanValue( 21 | l.Evaluate(scope, bindings).AsNumber() > 22 | r.Evaluate(scope, bindings).AsNumber() 23 | ); 24 | } 25 | 26 | public override Expression Simplify() 27 | { 28 | if (l is NumberLiteral && r is NumberLiteral) 29 | { 30 | var left = l as NumberLiteral; 31 | var right = r as NumberLiteral; 32 | 33 | return new BooleanLiteral( 34 | left.Value.AsNumber() > right.Value.AsNumber() 35 | ); 36 | } 37 | else 38 | { 39 | var left = l.Simplify(); 40 | var right = r.Simplify(); 41 | 42 | if (l == left && r == right) 43 | { 44 | return this; 45 | } 46 | else 47 | { 48 | return new GreaterThanExpression(left, right).Simplify(); 49 | } 50 | } 51 | } 52 | 53 | #region Equality 54 | 55 | public override bool Equals(object obj) 56 | { 57 | return Equals(obj as GreaterThanExpression); 58 | } 59 | 60 | public bool Equals(GreaterThanExpression other) 61 | { 62 | if (other == null) 63 | { 64 | return false; 65 | } 66 | 67 | return Equals(l, other.l) 68 | && Equals(r, other.r); 69 | } 70 | 71 | public override int GetHashCode() 72 | { 73 | return Util.GetHashCode(l, r); 74 | } 75 | 76 | #endregion 77 | 78 | #region Serialization 79 | 80 | public GreaterThanExpression 81 | (SerializationInfo info, StreamingContext context) 82 | { 83 | l = info.GetValue("l"); 84 | r = info.GetValue("r"); 85 | } 86 | 87 | public override void GetObjectData 88 | (SerializationInfo info, StreamingContext context) 89 | { 90 | info.AddValue("l", l); 91 | info.AddValue("r", r); 92 | } 93 | 94 | #endregion 95 | 96 | public override string ToString() 97 | { 98 | return "(" + l.ToString() + " > " + r.ToString() + ")"; 99 | } 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /Engine/Expression/GreaterThanExpression.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 38c0d60d2457ce54185bcbb9be5dec7e 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Engine/Expression/GreaterThanOrEqualExpression.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.Serialization; 3 | 4 | namespace Exodrifter.Rumor.Engine 5 | { 6 | [Serializable] 7 | public class GreaterThanOrEqualExpression : Expression, ISerializable 8 | { 9 | internal readonly Expression l; 10 | internal readonly Expression r; 11 | 12 | public GreaterThanOrEqualExpression(Expression l, Expression r) 13 | { 14 | this.l = l; 15 | this.r = r; 16 | } 17 | 18 | public override Value Evaluate(RumorScope scope, RumorBindings bindings) 19 | { 20 | return new BooleanValue( 21 | l.Evaluate(scope, bindings).AsNumber() >= 22 | r.Evaluate(scope, bindings).AsNumber() 23 | ); 24 | } 25 | 26 | public override Expression Simplify() 27 | { 28 | if (l is NumberLiteral && r is NumberLiteral) 29 | { 30 | var left = l as NumberLiteral; 31 | var right = r as NumberLiteral; 32 | 33 | return new BooleanLiteral( 34 | left.Value.AsNumber() >= right.Value.AsNumber() 35 | ); 36 | } 37 | else 38 | { 39 | var left = l.Simplify(); 40 | var right = r.Simplify(); 41 | 42 | if (l == left && r == right) 43 | { 44 | return this; 45 | } 46 | else 47 | { 48 | return new GreaterThanOrEqualExpression(left, right).Simplify(); 49 | } 50 | } 51 | } 52 | 53 | #region Equality 54 | 55 | public override bool Equals(object obj) 56 | { 57 | return Equals(obj as GreaterThanOrEqualExpression); 58 | } 59 | 60 | public bool Equals(GreaterThanOrEqualExpression other) 61 | { 62 | if (other == null) 63 | { 64 | return false; 65 | } 66 | 67 | return Equals(l, other.l) 68 | && Equals(r, other.r); 69 | } 70 | 71 | public override int GetHashCode() 72 | { 73 | return Util.GetHashCode(l, r); 74 | } 75 | 76 | #endregion 77 | 78 | #region Serialization 79 | 80 | public GreaterThanOrEqualExpression 81 | (SerializationInfo info, StreamingContext context) 82 | { 83 | l = info.GetValue("l"); 84 | r = info.GetValue("r"); 85 | } 86 | 87 | public override void GetObjectData 88 | (SerializationInfo info, StreamingContext context) 89 | { 90 | info.AddValue("l", l); 91 | info.AddValue("r", r); 92 | } 93 | 94 | #endregion 95 | 96 | public override string ToString() 97 | { 98 | return "(" + l.ToString() + " >= " + r.ToString() + ")"; 99 | } 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /Engine/Expression/GreaterThanOrEqualExpression.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 83e65bdc8defe724093e6f36499ab89d 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Engine/Expression/IsExpression.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0c9bc74294b82d548bd050fa8b32c63a 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Engine/Expression/IsNotExpression.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 11f27b63ad6659e458003322a51a2137 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Engine/Expression/LessThanExpression.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.Serialization; 3 | 4 | namespace Exodrifter.Rumor.Engine 5 | { 6 | [Serializable] 7 | public class LessThanExpression : Expression, ISerializable 8 | { 9 | internal readonly Expression l; 10 | internal readonly Expression r; 11 | 12 | public LessThanExpression(Expression l, Expression r) 13 | { 14 | this.l = l; 15 | this.r = r; 16 | } 17 | 18 | public override Value Evaluate(RumorScope scope, RumorBindings bindings) 19 | { 20 | return new BooleanValue( 21 | l.Evaluate(scope, bindings).AsNumber() < 22 | r.Evaluate(scope, bindings).AsNumber() 23 | ); 24 | } 25 | 26 | public override Expression Simplify() 27 | { 28 | if (l is NumberLiteral && r is NumberLiteral) 29 | { 30 | var left = l as NumberLiteral; 31 | var right = r as NumberLiteral; 32 | 33 | return new BooleanLiteral( 34 | left.Value.AsNumber() < right.Value.AsNumber() 35 | ); 36 | } 37 | else 38 | { 39 | var left = l.Simplify(); 40 | var right = r.Simplify(); 41 | 42 | if (l == left && r == right) 43 | { 44 | return this; 45 | } 46 | else 47 | { 48 | return new LessThanExpression(left, right).Simplify(); 49 | } 50 | } 51 | } 52 | 53 | #region Equality 54 | 55 | public override bool Equals(object obj) 56 | { 57 | return Equals(obj as LessThanExpression); 58 | } 59 | 60 | public bool Equals(LessThanExpression other) 61 | { 62 | if (other == null) 63 | { 64 | return false; 65 | } 66 | 67 | return Equals(l, other.l) 68 | && Equals(r, other.r); 69 | } 70 | 71 | public override int GetHashCode() 72 | { 73 | return Util.GetHashCode(l, r); 74 | } 75 | 76 | #endregion 77 | 78 | #region Serialization 79 | 80 | public LessThanExpression 81 | (SerializationInfo info, StreamingContext context) 82 | { 83 | l = info.GetValue("l"); 84 | r = info.GetValue("r"); 85 | } 86 | 87 | public override void GetObjectData 88 | (SerializationInfo info, StreamingContext context) 89 | { 90 | info.AddValue("l", l); 91 | info.AddValue("r", r); 92 | } 93 | 94 | #endregion 95 | 96 | public override string ToString() 97 | { 98 | return "(" + l.ToString() + " < " + r.ToString() + ")"; 99 | } 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /Engine/Expression/LessThanExpression.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6def7d1b3c84f784997d2eee12f2f8c3 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Engine/Expression/LessThanOrEqualExpression.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.Serialization; 3 | 4 | namespace Exodrifter.Rumor.Engine 5 | { 6 | [Serializable] 7 | public class LessThanOrEqualExpression : Expression, ISerializable 8 | { 9 | internal readonly Expression l; 10 | internal readonly Expression r; 11 | 12 | public LessThanOrEqualExpression(Expression l, Expression r) 13 | { 14 | this.l = l; 15 | this.r = r; 16 | } 17 | 18 | public override Value Evaluate(RumorScope scope, RumorBindings bindings) 19 | { 20 | return new BooleanValue( 21 | l.Evaluate(scope, bindings).AsNumber() <= 22 | r.Evaluate(scope, bindings).AsNumber() 23 | ); 24 | } 25 | 26 | public override Expression Simplify() 27 | { 28 | if (l is NumberLiteral && r is NumberLiteral) 29 | { 30 | var left = l as NumberLiteral; 31 | var right = r as NumberLiteral; 32 | 33 | return new BooleanLiteral( 34 | left.Value.AsNumber() <= right.Value.AsNumber() 35 | ); 36 | } 37 | else 38 | { 39 | var left = l.Simplify(); 40 | var right = r.Simplify(); 41 | 42 | if (l == left && r == right) 43 | { 44 | return this; 45 | } 46 | else 47 | { 48 | return new LessThanOrEqualExpression(left, right) 49 | .Simplify(); 50 | } 51 | } 52 | } 53 | 54 | #region Equality 55 | 56 | public override bool Equals(object obj) 57 | { 58 | return Equals(obj as LessThanOrEqualExpression); 59 | } 60 | 61 | public bool Equals(LessThanOrEqualExpression other) 62 | { 63 | if (other == null) 64 | { 65 | return false; 66 | } 67 | 68 | return Equals(l, other.l) 69 | && Equals(r, other.r); 70 | } 71 | 72 | public override int GetHashCode() 73 | { 74 | return Util.GetHashCode(l, r); 75 | } 76 | 77 | #endregion 78 | 79 | #region Serialization 80 | 81 | public LessThanOrEqualExpression 82 | (SerializationInfo info, StreamingContext context) 83 | { 84 | l = info.GetValue("l"); 85 | r = info.GetValue("r"); 86 | } 87 | 88 | public override void GetObjectData 89 | (SerializationInfo info, StreamingContext context) 90 | { 91 | info.AddValue("l", l); 92 | info.AddValue("r", r); 93 | } 94 | 95 | #endregion 96 | 97 | public override string ToString() 98 | { 99 | return "(" + l.ToString() + " <= " + r.ToString() + ")"; 100 | } 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /Engine/Expression/LessThanOrEqualExpression.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d3aaedcdec4ecbf48a1a91b4d423f48f 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Engine/Expression/LiteralExpression.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.Serialization; 3 | 4 | namespace Exodrifter.Rumor.Engine 5 | { 6 | [Serializable] 7 | public abstract class LiteralExpression : Expression, ISerializable 8 | { 9 | public readonly Value Value; 10 | 11 | public LiteralExpression(Value value) 12 | { 13 | Value = value; 14 | } 15 | 16 | public override Value Evaluate(RumorScope _scope, RumorBindings _bindings) 17 | { 18 | return Value; 19 | } 20 | 21 | public override Expression Simplify() 22 | { 23 | return this; 24 | } 25 | 26 | #region Equality 27 | 28 | public override bool Equals(object obj) 29 | { 30 | return Equals(obj as LiteralExpression); 31 | } 32 | 33 | public bool Equals(LiteralExpression other) 34 | { 35 | if (other == null) 36 | { 37 | return false; 38 | } 39 | 40 | return Equals(Value, other.Value); 41 | } 42 | 43 | public override int GetHashCode() 44 | { 45 | return Util.GetHashCode(Value); 46 | } 47 | 48 | #endregion 49 | 50 | #region Serialization 51 | 52 | public LiteralExpression 53 | (SerializationInfo info, StreamingContext context) 54 | { 55 | Value = info.GetValue("value"); 56 | } 57 | 58 | public override void GetObjectData 59 | (SerializationInfo info, StreamingContext context) 60 | { 61 | info.AddValue("value", Value); 62 | } 63 | 64 | #endregion 65 | 66 | public override string ToString() 67 | { 68 | return Value.ToString(); 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /Engine/Expression/LiteralExpression.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3bbdd54aadfeaa247b79962a15368c7c 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Engine/Expression/MultiplyExpression.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.Serialization; 3 | 4 | namespace Exodrifter.Rumor.Engine 5 | { 6 | [Serializable] 7 | public class MultiplyExpression : Expression, ISerializable 8 | { 9 | private readonly Expression l; 10 | private readonly Expression r; 11 | 12 | public MultiplyExpression(Expression l, Expression r) 13 | { 14 | this.l = l; 15 | this.r = r; 16 | } 17 | 18 | public override Value Evaluate(RumorScope scope, RumorBindings bindings) 19 | { 20 | return l.Evaluate(scope, bindings).AsNumber() 21 | * r.Evaluate(scope, bindings).AsNumber(); 22 | } 23 | 24 | public override Expression Simplify() 25 | { 26 | if (l is NumberLiteral && r is NumberLiteral) 27 | { 28 | var left = l as NumberLiteral; 29 | var right = r as NumberLiteral; 30 | 31 | return new NumberLiteral( 32 | left.Value.AsNumber() * right.Value.AsNumber() 33 | ); 34 | } 35 | else 36 | { 37 | var left = l.Simplify(); 38 | var right = r.Simplify(); 39 | 40 | if (l == left && r == right) 41 | { 42 | return this; 43 | } 44 | else 45 | { 46 | return new MultiplyExpression(left, right).Simplify(); 47 | } 48 | } 49 | } 50 | 51 | #region Equality 52 | 53 | public override bool Equals(object obj) 54 | { 55 | return Equals(obj as MultiplyExpression); 56 | } 57 | 58 | public bool Equals(MultiplyExpression other) 59 | { 60 | if (other == null) 61 | { 62 | return false; 63 | } 64 | 65 | return Equals(l, other.l) 66 | && Equals(r, other.r); 67 | } 68 | 69 | public override int GetHashCode() 70 | { 71 | return Util.GetHashCode(l, r); 72 | } 73 | 74 | #endregion 75 | 76 | #region Serialization 77 | 78 | public MultiplyExpression 79 | (SerializationInfo info, StreamingContext context) 80 | { 81 | l = info.GetValue("l"); 82 | r = info.GetValue("r"); 83 | } 84 | 85 | public override void GetObjectData 86 | (SerializationInfo info, StreamingContext context) 87 | { 88 | info.AddValue("l", l); 89 | info.AddValue("r", r); 90 | } 91 | 92 | #endregion 93 | 94 | public override string ToString() 95 | { 96 | return "(" + l.ToString() + " * " + r.ToString() + ")"; 97 | } 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /Engine/Expression/MultiplyExpression.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 951732a2757dd0c45ab5e3f6bb8992ad 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Engine/Expression/NotExpression.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.Serialization; 3 | 4 | namespace Exodrifter.Rumor.Engine 5 | { 6 | public class NotExpression : Expression 7 | { 8 | private readonly Expression expression; 9 | 10 | public NotExpression(Expression expression) 11 | { 12 | this.expression = expression; 13 | } 14 | 15 | public override Value Evaluate(RumorScope scope, RumorBindings bindings) 16 | { 17 | return !expression.Evaluate(scope, bindings).AsBoolean(); 18 | } 19 | 20 | public override Expression Simplify() 21 | { 22 | if (expression is BooleanLiteral) 23 | { 24 | var e = expression as BooleanLiteral; 25 | return new BooleanLiteral(!e.Value.AsBoolean()); 26 | } 27 | else 28 | { 29 | var e = expression.Simplify(); 30 | 31 | if (e == expression) 32 | { 33 | return this; 34 | } 35 | else 36 | { 37 | return new NotExpression(e).Simplify(); 38 | } 39 | } 40 | } 41 | 42 | #region Equality 43 | 44 | public override bool Equals(object obj) 45 | { 46 | return Equals(obj as NotExpression); 47 | } 48 | 49 | public bool Equals(NotExpression other) 50 | { 51 | if (other == null) 52 | { 53 | return false; 54 | } 55 | 56 | return Equals(expression, other.expression); 57 | } 58 | 59 | public override int GetHashCode() 60 | { 61 | return Util.GetHashCode(expression); 62 | } 63 | 64 | #endregion 65 | 66 | #region Serialization 67 | 68 | public NotExpression(SerializationInfo info, StreamingContext context) 69 | { 70 | expression = info.GetValue("expression"); 71 | } 72 | 73 | public override void GetObjectData 74 | (SerializationInfo info, StreamingContext context) 75 | { 76 | info.AddValue("expression", expression); 77 | } 78 | 79 | #endregion 80 | 81 | public override string ToString() 82 | { 83 | return "(not " + expression.ToString() + ")"; 84 | } 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /Engine/Expression/NotExpression.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ef05ccdca6e5fe34c862387f0f5441b4 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Engine/Expression/NumberBinding.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.Serialization; 3 | 4 | namespace Exodrifter.Rumor.Engine 5 | { 6 | [Serializable] 7 | public class NumberBinding : Expression, ISerializable 8 | { 9 | private readonly string id; 10 | private Expression[] param; 11 | 12 | public NumberBinding(string id, params Expression[] param) 13 | { 14 | this.id = id; 15 | this.param = param; 16 | } 17 | 18 | public override Value Evaluate(RumorScope scope, RumorBindings bindings) 19 | { 20 | object[] ps = new object[param.Length]; 21 | for (int i = 0; i < param.Length; ++i) 22 | { 23 | ps[i] = param[i].Evaluate(scope, bindings).InternalValue; 24 | } 25 | 26 | var value = bindings.CallBinding(BindingType.Function, id, ps); 27 | if (value == null) 28 | { 29 | throw new VariableTypeException( 30 | "Function \"" + id + "\" returned null!" 31 | ); 32 | } 33 | if (!(value is double)) 34 | { 35 | throw new VariableTypeException( 36 | "Function \"" + id + "\" did not return a double!" 37 | ); 38 | } 39 | 40 | return new NumberValue((double)value); 41 | } 42 | 43 | public override Expression Simplify() 44 | { 45 | return this; 46 | } 47 | 48 | #region Equality 49 | 50 | public override bool Equals(object obj) 51 | { 52 | return Equals(obj as NumberBinding); 53 | } 54 | 55 | public bool Equals(NumberBinding other) 56 | { 57 | if (other == null) 58 | { 59 | return false; 60 | } 61 | 62 | return Equals(id, other.id); 63 | } 64 | 65 | public override int GetHashCode() 66 | { 67 | return Util.GetHashCode(id); 68 | } 69 | 70 | #endregion 71 | 72 | #region Serialization 73 | 74 | public NumberBinding 75 | (SerializationInfo info, StreamingContext context) 76 | : base(info, context) 77 | { 78 | id = info.GetValue("id"); 79 | param = info.GetValue("param"); 80 | } 81 | 82 | public override void GetObjectData 83 | (SerializationInfo info, StreamingContext context) 84 | { 85 | info.AddValue("id", id); 86 | info.AddValue("param", param); 87 | } 88 | 89 | #endregion 90 | 91 | public override string ToString() 92 | { 93 | string[] ps = new string[param.Length]; 94 | for (int i = 0; i < param.Length; ++i) 95 | { 96 | ps[i] = param[i].ToString(); 97 | } 98 | 99 | return id + "(" + string.Join(", ", ps) + ")"; 100 | } 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /Engine/Expression/NumberBinding.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 86b110e79b9d92411853f7c67c02e93c 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Engine/Expression/NumberFunction.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 94ddf4a39c659addc8a909677a03ea6c 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Engine/Expression/NumberLiteral.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.Serialization; 3 | 4 | namespace Exodrifter.Rumor.Engine 5 | { 6 | [Serializable] 7 | public class NumberLiteral : LiteralExpression, ISerializable 8 | { 9 | public NumberLiteral(NumberValue value) : base(value) { } 10 | public NumberLiteral(double value) : base(new NumberValue(value)) { } 11 | 12 | #region Equality 13 | 14 | public override bool Equals(object obj) 15 | { 16 | return Equals(obj as NumberLiteral); 17 | } 18 | 19 | public bool Equals(NumberLiteral other) 20 | { 21 | if (other == null) 22 | { 23 | return false; 24 | } 25 | 26 | return Equals(Value, other.Value); 27 | } 28 | 29 | public override int GetHashCode() 30 | { 31 | return Util.GetHashCode(Value); 32 | } 33 | 34 | #endregion 35 | 36 | #region Serialization 37 | 38 | public NumberLiteral(SerializationInfo info, StreamingContext context) 39 | : base(info, context) { } 40 | 41 | #endregion 42 | 43 | public override string ToString() 44 | { 45 | return Value.ToString(); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /Engine/Expression/NumberLiteral.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 625a316b4f71ff84c88b250d82bcbcc9 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Engine/Expression/NumberVariable.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.Serialization; 3 | 4 | namespace Exodrifter.Rumor.Engine 5 | { 6 | [Serializable] 7 | public class NumberVariable : Expression, ISerializable 8 | { 9 | private readonly string name; 10 | 11 | public NumberVariable(string name) 12 | { 13 | this.name = name; 14 | } 15 | 16 | public override Value Evaluate(RumorScope scope, RumorBindings _) 17 | { 18 | var value = scope.Get(name); 19 | if (value == null) 20 | { 21 | throw new UndefinedVariableException( 22 | "Variable \"" + name+ "\" has not been defined yet!" 23 | ); 24 | } 25 | if (!(value is NumberValue)) 26 | { 27 | throw new VariableTypeException( 28 | "Variable is not a number!" 29 | ); 30 | } 31 | 32 | return (NumberValue)value; 33 | } 34 | 35 | public override Expression Simplify() 36 | { 37 | return this; 38 | } 39 | 40 | #region Equality 41 | 42 | public override bool Equals(object obj) 43 | { 44 | return Equals(obj as NumberVariable); 45 | } 46 | 47 | public bool Equals(NumberVariable other) 48 | { 49 | if (other == null) 50 | { 51 | return false; 52 | } 53 | 54 | return Equals(name, other.name); 55 | } 56 | 57 | public override int GetHashCode() 58 | { 59 | return name.GetHashCode(); 60 | } 61 | 62 | #endregion 63 | 64 | #region Serialization 65 | 66 | public NumberVariable 67 | (SerializationInfo info, StreamingContext context) 68 | { 69 | name = info.GetValue("name"); 70 | } 71 | 72 | public override void GetObjectData 73 | (SerializationInfo info, StreamingContext context) 74 | { 75 | info.AddValue("name", name); 76 | } 77 | 78 | #endregion 79 | 80 | public override string ToString() 81 | { 82 | return name; 83 | } 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /Engine/Expression/NumberVariable.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: adeb9bd0c5843c4409f679c891fd766d 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Engine/Expression/OrExpression.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.Serialization; 3 | 4 | namespace Exodrifter.Rumor.Engine 5 | { 6 | [Serializable] 7 | public class OrExpression : Expression, ISerializable 8 | { 9 | private readonly Expression l; 10 | private readonly Expression r; 11 | 12 | public OrExpression(Expression l, Expression r) 13 | { 14 | this.l = l; 15 | this.r = r; 16 | } 17 | 18 | public override Value Evaluate(RumorScope scope, RumorBindings bindings) 19 | { 20 | return l.Evaluate(scope, bindings).AsBoolean() 21 | || r.Evaluate(scope, bindings).AsBoolean(); 22 | } 23 | 24 | public override Expression Simplify() 25 | { 26 | if (l is BooleanLiteral && r is BooleanLiteral) 27 | { 28 | var left = l as BooleanLiteral; 29 | var right = r as BooleanLiteral; 30 | 31 | return new BooleanLiteral( 32 | left.Value.AsBoolean() || right.Value.AsBoolean() 33 | ); 34 | } 35 | else 36 | { 37 | var left = l.Simplify(); 38 | var right = r.Simplify(); 39 | 40 | if (l == left && r == right) 41 | { 42 | return this; 43 | } 44 | else 45 | { 46 | return new OrExpression(left, right).Simplify(); 47 | } 48 | } 49 | } 50 | 51 | #region Equality 52 | 53 | public override bool Equals(object obj) 54 | { 55 | return Equals(obj as OrExpression); 56 | } 57 | 58 | public bool Equals(OrExpression other) 59 | { 60 | if (other == null) 61 | { 62 | return false; 63 | } 64 | 65 | return Equals(l, other.l) 66 | && Equals(r, other.r); 67 | } 68 | 69 | public override int GetHashCode() 70 | { 71 | return Util.GetHashCode(l, r); 72 | } 73 | 74 | #endregion 75 | 76 | #region Serialization 77 | 78 | public OrExpression(SerializationInfo info, StreamingContext context) 79 | { 80 | l = info.GetValue("l"); 81 | r = info.GetValue("r"); 82 | } 83 | 84 | public override void GetObjectData 85 | (SerializationInfo info, StreamingContext context) 86 | { 87 | info.AddValue("l", l); 88 | info.AddValue("r", r); 89 | } 90 | 91 | #endregion 92 | 93 | public override string ToString() 94 | { 95 | return "(" + l.ToString() + " or " + r.ToString() + ")"; 96 | } 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /Engine/Expression/OrExpression.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 092300faa4306914dbab267adb75d347 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Engine/Expression/StringBinding.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.Serialization; 3 | 4 | namespace Exodrifter.Rumor.Engine 5 | { 6 | [Serializable] 7 | public class StringBinding : Expression, ISerializable 8 | { 9 | private readonly string id; 10 | private Expression[] param; 11 | 12 | public StringBinding(string id, params Expression[] param) 13 | { 14 | this.id = id; 15 | this.param = param; 16 | } 17 | 18 | public override Value Evaluate(RumorScope scope, RumorBindings bindings) 19 | { 20 | object[] ps = new object[param.Length]; 21 | for (int i = 0; i < param.Length; ++i) 22 | { 23 | ps[i] = param[i].Evaluate(scope, bindings).InternalValue; 24 | } 25 | 26 | var value = bindings.CallBinding(BindingType.Function, id, ps); 27 | if (value == null) 28 | { 29 | throw new VariableTypeException( 30 | "Function \"" + id + "\" returned null!" 31 | ); 32 | } 33 | if (!(value is string)) 34 | { 35 | throw new VariableTypeException( 36 | "Function \"" + id + "\" did not return a string!" 37 | ); 38 | } 39 | 40 | return new StringValue((string)value); 41 | } 42 | 43 | public override Expression Simplify() 44 | { 45 | return this; 46 | } 47 | 48 | #region Equality 49 | 50 | public override bool Equals(object obj) 51 | { 52 | return Equals(obj as StringBinding); 53 | } 54 | 55 | public bool Equals(StringBinding other) 56 | { 57 | if (other == null) 58 | { 59 | return false; 60 | } 61 | 62 | return Equals(id, other.id); 63 | } 64 | 65 | public override int GetHashCode() 66 | { 67 | return Util.GetHashCode(id); 68 | } 69 | 70 | #endregion 71 | 72 | #region Serialization 73 | 74 | public StringBinding 75 | (SerializationInfo info, StreamingContext context) 76 | : base(info, context) 77 | { 78 | id = info.GetValue("id"); 79 | param = info.GetValue("param"); 80 | } 81 | 82 | public override void GetObjectData 83 | (SerializationInfo info, StreamingContext context) 84 | { 85 | info.AddValue("id", id); 86 | info.AddValue("param", param); 87 | } 88 | 89 | #endregion 90 | 91 | public override string ToString() 92 | { 93 | string[] ps = new string[param.Length]; 94 | for (int i = 0; i < param.Length; ++i) 95 | { 96 | ps[i] = param[i].ToString(); 97 | } 98 | 99 | return id + "(" + string.Join(", ", ps) + ")"; 100 | } 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /Engine/Expression/StringBinding.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 789b235b98a5c8fe489aaca724620684 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Engine/Expression/StringFunction.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ea81f42803907c51eb5b177efba8de05 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Engine/Expression/StringLiteral.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.Serialization; 3 | 4 | namespace Exodrifter.Rumor.Engine 5 | { 6 | [Serializable] 7 | public class StringLiteral : LiteralExpression, ISerializable 8 | { 9 | public StringLiteral(StringValue value) : base(value) { } 10 | public StringLiteral(string value) : base(new StringValue(value)) { } 11 | 12 | #region Equality 13 | 14 | public override bool Equals(object obj) 15 | { 16 | return Equals(obj as StringLiteral); 17 | } 18 | 19 | public bool Equals(StringLiteral other) 20 | { 21 | if (other == null) 22 | { 23 | return false; 24 | } 25 | 26 | return Equals(Value, other.Value); 27 | } 28 | 29 | public override int GetHashCode() 30 | { 31 | return Util.GetHashCode(Value); 32 | } 33 | 34 | #endregion 35 | 36 | #region Serialization 37 | 38 | public StringLiteral(SerializationInfo info, StreamingContext context) 39 | : base(info, context) { } 40 | 41 | #endregion 42 | 43 | public override string ToString() 44 | { 45 | return Value.ToString(); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /Engine/Expression/StringLiteral.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8c5e37fa96fe66a45aad7983822d0a35 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Engine/Expression/StringVariable.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.Serialization; 3 | 4 | namespace Exodrifter.Rumor.Engine 5 | { 6 | [Serializable] 7 | public class StringVariable : Expression, ISerializable 8 | { 9 | private readonly string name; 10 | 11 | public StringVariable(string name) 12 | { 13 | this.name = name; 14 | } 15 | 16 | public override Value Evaluate(RumorScope scope, RumorBindings _) 17 | { 18 | var value = scope.Get(name); 19 | if (value == null) 20 | { 21 | throw new UndefinedVariableException( 22 | "Variable \"" + name+ "\" has not been defined yet!" 23 | ); 24 | } 25 | if (!(value is StringValue)) 26 | { 27 | throw new VariableTypeException( 28 | "Variable is not a string!" 29 | ); 30 | } 31 | 32 | return (StringValue)value; 33 | } 34 | 35 | public override Expression Simplify() 36 | { 37 | return this; 38 | } 39 | 40 | #region Equality 41 | 42 | public override bool Equals(object obj) 43 | { 44 | return Equals(obj as StringVariable); 45 | } 46 | 47 | public bool Equals(StringVariable other) 48 | { 49 | if (other == null) 50 | { 51 | return false; 52 | } 53 | 54 | return Equals(name, other.name); 55 | } 56 | 57 | public override int GetHashCode() 58 | { 59 | return name.GetHashCode(); 60 | } 61 | 62 | #endregion 63 | 64 | #region Serialization 65 | 66 | public StringVariable 67 | (SerializationInfo info, StreamingContext context) 68 | { 69 | name = info.GetValue("name"); 70 | } 71 | 72 | public override void GetObjectData 73 | (SerializationInfo info, StreamingContext context) 74 | { 75 | info.AddValue("name", name); 76 | } 77 | 78 | #endregion 79 | 80 | public override string ToString() 81 | { 82 | return name; 83 | } 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /Engine/Expression/StringVariable.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b99daaaa3ed074a41b365e1a38a45c9c 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Engine/Expression/SubstitutionExpression.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.Serialization; 3 | 4 | namespace Exodrifter.Rumor.Engine 5 | { 6 | [Serializable] 7 | public class SubstitutionExpression : Expression, ISerializable 8 | { 9 | private readonly Expression value; 10 | 11 | public SubstitutionExpression(Expression value) 12 | { 13 | this.value = value; 14 | } 15 | 16 | public override Value Evaluate(RumorScope scope, RumorBindings bindings) 17 | { 18 | return new StringValue(value.Evaluate(scope, bindings).ToString()); 19 | } 20 | 21 | public override Expression Simplify() 22 | { 23 | // Inline literals 24 | if (value is BooleanLiteral) 25 | { 26 | var b = (value as BooleanLiteral).Value; 27 | return new StringLiteral(b.ToString()); 28 | } 29 | else if (value is NumberLiteral) 30 | { 31 | var n = (value as NumberLiteral).Value; 32 | return new StringLiteral(n.ToString()); 33 | } 34 | else if (value is StringLiteral) 35 | { 36 | return value as StringLiteral; 37 | } 38 | 39 | // Attempt more simplification 40 | else 41 | { 42 | var v = value.Simplify(); 43 | 44 | // No further simplification can be done 45 | if (v == value) 46 | { 47 | return this; 48 | } 49 | else 50 | { 51 | return new SubstitutionExpression(v).Simplify(); 52 | } 53 | } 54 | } 55 | 56 | #region Equality 57 | 58 | public override bool Equals(object obj) 59 | { 60 | return Equals(obj as SubstitutionExpression); 61 | } 62 | 63 | public bool Equals(SubstitutionExpression other) 64 | { 65 | if (other == null) 66 | { 67 | return false; 68 | } 69 | 70 | return Equals(value, other.value); 71 | } 72 | 73 | public override int GetHashCode() 74 | { 75 | return Util.GetHashCode(value); 76 | } 77 | 78 | #endregion 79 | 80 | #region Serialization 81 | 82 | public SubstitutionExpression 83 | (SerializationInfo info, StreamingContext context) 84 | { 85 | value = info.GetValue("value"); 86 | } 87 | 88 | public override void GetObjectData 89 | (SerializationInfo info, StreamingContext context) 90 | { 91 | info.AddValue("value", value); 92 | } 93 | 94 | #endregion 95 | 96 | public override string ToString() 97 | { 98 | return "{" + value.ToString() + "}"; 99 | } 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /Engine/Expression/SubstitutionExpression.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: feb3b0d206d452c43b05bf6423c316e0 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Engine/Expression/SubtractExpression.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.Serialization; 3 | 4 | namespace Exodrifter.Rumor.Engine 5 | { 6 | [Serializable] 7 | public class SubtractExpression : Expression, ISerializable 8 | { 9 | private readonly Expression l; 10 | private readonly Expression r; 11 | 12 | public SubtractExpression(Expression l, Expression r) 13 | { 14 | this.l = l; 15 | this.r = r; 16 | } 17 | 18 | public override Value Evaluate(RumorScope scope, RumorBindings bindings) 19 | { 20 | return l.Evaluate(scope, bindings).AsNumber() 21 | - r.Evaluate(scope, bindings).AsNumber(); 22 | } 23 | 24 | public override Expression Simplify() 25 | { 26 | if (l is NumberLiteral && r is NumberLiteral) 27 | { 28 | var left = l as NumberLiteral; 29 | var right = r as NumberLiteral; 30 | 31 | return new NumberLiteral( 32 | left.Value.AsNumber() - right.Value.AsNumber() 33 | ); 34 | } 35 | else 36 | { 37 | var left = l.Simplify(); 38 | var right = r.Simplify(); 39 | 40 | if (l == left && r == right) 41 | { 42 | return this; 43 | } 44 | else 45 | { 46 | return new SubtractExpression(left, right).Simplify(); 47 | } 48 | } 49 | } 50 | 51 | #region Equality 52 | 53 | public override bool Equals(object obj) 54 | { 55 | return Equals(obj as SubtractExpression); 56 | } 57 | 58 | public bool Equals(SubtractExpression other) 59 | { 60 | if (other == null) 61 | { 62 | return false; 63 | } 64 | 65 | return Equals(l, other.l) 66 | && Equals(r, other.r); 67 | } 68 | 69 | public override int GetHashCode() 70 | { 71 | return Util.GetHashCode(l, r); 72 | } 73 | 74 | #endregion 75 | 76 | #region Serialization 77 | 78 | public SubtractExpression 79 | (SerializationInfo info, StreamingContext context) 80 | { 81 | l = info.GetValue("l"); 82 | r = info.GetValue("r"); 83 | } 84 | 85 | public override void GetObjectData 86 | (SerializationInfo info, StreamingContext context) 87 | { 88 | info.AddValue("l", l); 89 | info.AddValue("r", r); 90 | } 91 | 92 | #endregion 93 | 94 | public override string ToString() 95 | { 96 | return "(" + l.ToString() + " - " + r.ToString() + ")"; 97 | } 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /Engine/Expression/SubtractExpression.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b1ee9e9b8ed6f4a48b0bbeeac11ca93d 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Engine/Expression/ToStringExpression.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.Serialization; 3 | 4 | namespace Exodrifter.Rumor.Engine 5 | { 6 | [Serializable] 7 | public class ToStringExpression : Expression, ISerializable 8 | { 9 | private readonly Expression value; 10 | 11 | public ToStringExpression(Expression value) 12 | { 13 | this.value = value; 14 | } 15 | 16 | public override Value Evaluate(RumorScope scope, RumorBindings bindings) 17 | { 18 | var result = value.Evaluate(scope, bindings).InternalValue; 19 | return new StringValue(result.ToString()); 20 | } 21 | 22 | public override Expression Simplify() 23 | { 24 | // Inline literals 25 | if (value is BooleanLiteral) 26 | { 27 | var b = (value as BooleanLiteral).Value; 28 | return new StringLiteral(b.ToString()); 29 | } 30 | else if (value is NumberLiteral) 31 | { 32 | var n = (value as NumberLiteral).Value; 33 | return new StringLiteral(n.ToString()); 34 | } 35 | else if (value is StringLiteral) 36 | { 37 | return value as StringLiteral; 38 | } 39 | 40 | // Attempt more simplification 41 | else 42 | { 43 | var v = value.Simplify(); 44 | 45 | // No further simplification can be done 46 | if (v == value) 47 | { 48 | return this; 49 | } 50 | else 51 | { 52 | return new ToStringExpression(v).Simplify(); 53 | } 54 | } 55 | } 56 | 57 | #region Equality 58 | 59 | public override bool Equals(object obj) 60 | { 61 | return Equals(obj as ToStringExpression); 62 | } 63 | 64 | public bool Equals(ToStringExpression other) 65 | { 66 | if (other == null) 67 | { 68 | return false; 69 | } 70 | 71 | return Equals(value, other.value); 72 | } 73 | 74 | public override int GetHashCode() 75 | { 76 | return Util.GetHashCode(value); 77 | } 78 | 79 | #endregion 80 | 81 | #region Serialization 82 | 83 | public ToStringExpression 84 | (SerializationInfo info, StreamingContext context) 85 | { 86 | value = info.GetValue("value"); 87 | } 88 | 89 | public override void GetObjectData 90 | (SerializationInfo info, StreamingContext context) 91 | { 92 | info.AddValue("value", value); 93 | } 94 | 95 | #endregion 96 | 97 | public override string ToString() 98 | { 99 | return "<" + value.ToString() + ">"; 100 | } 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /Engine/Expression/ToStringExpression.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f7843330917de404a8511d23b6ccb0a9 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Engine/Expression/VariableExpression.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.Serialization; 3 | 4 | namespace Exodrifter.Rumor.Engine 5 | { 6 | [Serializable] 7 | public class VariableExpression : Expression, ISerializable 8 | { 9 | private readonly string name; 10 | 11 | public VariableExpression(string name) 12 | { 13 | this.name = name; 14 | } 15 | 16 | public override Value Evaluate(RumorScope scope, RumorBindings _) 17 | { 18 | var value = scope.Get(name); 19 | if (value == null) 20 | { 21 | throw new UndefinedVariableException( 22 | "Variable \"" + name+ "\" has not been defined yet!" 23 | ); 24 | } 25 | 26 | return value; 27 | } 28 | 29 | public override Expression Simplify() 30 | { 31 | return this; 32 | } 33 | 34 | #region Equality 35 | 36 | public override bool Equals(object obj) 37 | { 38 | return Equals(obj as VariableExpression); 39 | } 40 | 41 | public bool Equals(VariableExpression other) 42 | { 43 | if (other == null) 44 | { 45 | return false; 46 | } 47 | 48 | return Equals(name, other.name); 49 | } 50 | 51 | public override int GetHashCode() 52 | { 53 | return name.GetHashCode(); 54 | } 55 | 56 | #endregion 57 | 58 | #region Serialization 59 | 60 | public VariableExpression 61 | (SerializationInfo info, StreamingContext context) 62 | { 63 | name = info.GetValue("name"); 64 | } 65 | 66 | public override void GetObjectData 67 | (SerializationInfo info, StreamingContext context) 68 | { 69 | info.AddValue("name", name); 70 | } 71 | 72 | #endregion 73 | 74 | public override string ToString() 75 | { 76 | return name; 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /Engine/Expression/VariableExpression.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: feb83f7bd7e1dd548bca4c6cdf487faf 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Engine/Expression/XorExpression.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.Serialization; 3 | 4 | namespace Exodrifter.Rumor.Engine 5 | { 6 | [Serializable] 7 | public class XorExpression : Expression, ISerializable 8 | { 9 | private readonly Expression l; 10 | private readonly Expression r; 11 | 12 | public XorExpression(Expression l, Expression r) 13 | { 14 | this.l = l; 15 | this.r = r; 16 | } 17 | 18 | public override Value Evaluate(RumorScope scope, RumorBindings bindings) 19 | { 20 | return l.Evaluate(scope, bindings).AsBoolean() 21 | ^ r.Evaluate(scope, bindings).AsBoolean(); 22 | } 23 | 24 | public override Expression Simplify() 25 | { 26 | if (l is BooleanLiteral && r is BooleanLiteral) 27 | { 28 | var left = l as BooleanLiteral; 29 | var right = r as BooleanLiteral; 30 | 31 | return new BooleanLiteral( 32 | left.Value.AsBoolean() ^ right.Value.AsBoolean() 33 | ); 34 | } 35 | else 36 | { 37 | var left = l.Simplify(); 38 | var right = r.Simplify(); 39 | 40 | if (l == left && r == right) 41 | { 42 | return this; 43 | } 44 | else 45 | { 46 | return new XorExpression(left, right).Simplify(); 47 | } 48 | } 49 | } 50 | 51 | #region Equality 52 | 53 | public override bool Equals(object obj) 54 | { 55 | return Equals(obj as XorExpression); 56 | } 57 | 58 | public bool Equals(XorExpression other) 59 | { 60 | if (other == null) 61 | { 62 | return false; 63 | } 64 | 65 | return Equals(l, other.l) 66 | && Equals(r, other.r); 67 | } 68 | 69 | public override int GetHashCode() 70 | { 71 | return Util.GetHashCode(l, r); 72 | } 73 | 74 | #endregion 75 | 76 | #region Serialization 77 | 78 | public XorExpression(SerializationInfo info, StreamingContext context) 79 | { 80 | l = info.GetValue("l"); 81 | r = info.GetValue("r"); 82 | } 83 | 84 | public override void GetObjectData 85 | (SerializationInfo info, StreamingContext context) 86 | { 87 | info.AddValue("l", l); 88 | info.AddValue("r", r); 89 | } 90 | 91 | #endregion 92 | 93 | public override string ToString() 94 | { 95 | return "(" + l.ToString() + " xor " + r.ToString() + ")"; 96 | } 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /Engine/Expression/XorExpression.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 38ea550ec64a76940992c80d4ff15fea 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Engine/Nodes.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5e1d1f95b965d3e44a4b12344ce1a434 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Engine/Nodes/AddChoiceNode.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.Serialization; 3 | 4 | namespace Exodrifter.Rumor.Engine 5 | { 6 | [Serializable] 7 | public class AddChoiceNode : Node, ISerializable 8 | { 9 | public string Label { get; } 10 | public Expression Text { get; } 11 | 12 | public AddChoiceNode(string label, string text) 13 | { 14 | Label = label; 15 | Text = new StringLiteral(text); 16 | } 17 | 18 | public AddChoiceNode(string label, Expression text) 19 | { 20 | Label = label; 21 | Text = text; 22 | } 23 | 24 | public override Yield Execute(Rumor rumor) 25 | { 26 | rumor.State.AddChoice( 27 | Label, 28 | Text.Evaluate(rumor.Scope, rumor.Bindings).AsString().Value 29 | ); 30 | return null; 31 | } 32 | 33 | #region Equality 34 | 35 | public override bool Equals(object obj) 36 | { 37 | return Equals(obj as AddChoiceNode); 38 | } 39 | 40 | public bool Equals(AddChoiceNode other) 41 | { 42 | if (other == null) 43 | { 44 | return false; 45 | } 46 | 47 | return this.Label == other.Label 48 | && this.Text == other.Text; 49 | } 50 | 51 | public override int GetHashCode() 52 | { 53 | return Util.GetHashCode("add", Label, Text); 54 | } 55 | 56 | #endregion 57 | 58 | #region Serialization 59 | 60 | public AddChoiceNode(SerializationInfo info, StreamingContext context) 61 | : base(info, context) 62 | { 63 | Label = info.GetValue("label"); 64 | Text = info.GetValue("text"); 65 | } 66 | 67 | public override void GetObjectData 68 | (SerializationInfo info, StreamingContext context) 69 | { 70 | info.AddValue("label", Label); 71 | info.AddValue("text", Text); 72 | } 73 | 74 | #endregion 75 | 76 | public override string ToString() 77 | { 78 | return "choice [" + Label + "] > " + Text; 79 | } 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /Engine/Nodes/AddChoiceNode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d02ce9c2f0d9af74ca7b4cfd8fbd69e4 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Engine/Nodes/AppendDialogNode.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.Serialization; 3 | 4 | namespace Exodrifter.Rumor.Engine 5 | { 6 | [Serializable] 7 | public class AppendDialogNode : DialogNode, ISerializable 8 | { 9 | public AppendDialogNode(string speaker, string dialog) 10 | : base(speaker, dialog) { } 11 | 12 | public AppendDialogNode(string speaker, Expression dialog) 13 | : base(speaker, dialog) { } 14 | 15 | public override Yield Execute(Rumor rumor) 16 | { 17 | var value = Dialog.Evaluate(rumor.Scope, rumor.Bindings); 18 | var dialog = value.AsString().Value; 19 | rumor.State.AppendDialog(Speaker, dialog); 20 | return new ForAdvance(); 21 | } 22 | 23 | #region Equality 24 | 25 | public override bool Equals(object obj) 26 | { 27 | return Equals(obj as AppendDialogNode); 28 | } 29 | 30 | public bool Equals(AppendDialogNode other) 31 | { 32 | if (other == null) 33 | { 34 | return false; 35 | } 36 | 37 | return Speaker == other.Speaker 38 | && Dialog == other.Dialog; 39 | } 40 | 41 | public override int GetHashCode() 42 | { 43 | return Util.GetHashCode("append", Speaker, Dialog); 44 | } 45 | 46 | #endregion 47 | 48 | #region Serialization 49 | 50 | public AppendDialogNode(SerializationInfo info, StreamingContext context) 51 | : base(info, context) { } 52 | 53 | #endregion 54 | 55 | public override string ToString() 56 | { 57 | return Speaker + "+ " + Dialog; 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /Engine/Nodes/AppendDialogNode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: be4d36480c5fddc4fbc5373cb13ce0b9 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Engine/Nodes/BindingActionNode.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.Serialization; 3 | 4 | namespace Exodrifter.Rumor.Engine 5 | { 6 | [Serializable] 7 | public class BindingActionNode : Node, ISerializable 8 | { 9 | private readonly string id; 10 | private Expression[] param; 11 | 12 | public BindingActionNode(string id, params Expression[] param) 13 | { 14 | this.id = id; 15 | this.param = param; 16 | } 17 | 18 | public override Yield Execute(Rumor rumor) 19 | { 20 | object[] ps = new object[param.Length]; 21 | for (int i = 0; i < param.Length; ++i) 22 | { 23 | var value = param[i].Evaluate(rumor.Scope, rumor.Bindings); 24 | ps[i] = value.InternalValue; 25 | } 26 | 27 | rumor.Bindings.CallBinding(BindingType.Action, id, ps); 28 | return null; 29 | } 30 | 31 | #region Equality 32 | 33 | public override bool Equals(object obj) 34 | { 35 | return Equals(obj as BindingActionNode); 36 | } 37 | 38 | public bool Equals(BindingActionNode other) 39 | { 40 | if (other == null) 41 | { 42 | return false; 43 | } 44 | 45 | return this.id == other.id 46 | && Util.ArrayEquals(this.param, this.param); 47 | } 48 | 49 | public override int GetHashCode() 50 | { 51 | return Util.GetHashCode("binding", id, Util.GetHashCode(param)); 52 | } 53 | 54 | #endregion 55 | 56 | #region Serialization 57 | 58 | public BindingActionNode 59 | (SerializationInfo info, StreamingContext context) 60 | : base(info, context) 61 | { 62 | id = info.GetValue("id"); 63 | param = info.GetValue("param"); 64 | } 65 | 66 | public override void GetObjectData 67 | (SerializationInfo info, StreamingContext context) 68 | { 69 | info.AddValue("id", id); 70 | info.AddValue("param", param); 71 | } 72 | 73 | #endregion 74 | 75 | public override string ToString() 76 | { 77 | string[] ps = new string[param.Length]; 78 | for (int i = 0; i < param.Length; ++i) 79 | { 80 | ps[i] = param[i].ToString(); 81 | } 82 | 83 | return id + "(" + string.Join(", ", ps) + ")"; 84 | } 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /Engine/Nodes/BindingActionNode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7e177c65325d8a940a2afb202a97e65e 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Engine/Nodes/CallNode.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.Serialization; 3 | 4 | namespace Exodrifter.Rumor.Engine 5 | { 6 | [Serializable] 7 | public class CallNode : Node, ISerializable 8 | { 9 | public string Label { get; } 10 | 11 | public CallNode(string label) 12 | { 13 | Label = label; 14 | } 15 | 16 | public override Yield Execute(Rumor rumor) 17 | { 18 | rumor.Call(Label); 19 | return null; 20 | } 21 | 22 | #region Equality 23 | 24 | public override bool Equals(object obj) 25 | { 26 | return Equals(obj as CallNode); 27 | } 28 | 29 | public bool Equals(CallNode other) 30 | { 31 | if (other == null) 32 | { 33 | return false; 34 | } 35 | 36 | return Label == other.Label; 37 | } 38 | 39 | public override int GetHashCode() 40 | { 41 | return Util.GetHashCode("call", Label); 42 | } 43 | 44 | #endregion 45 | 46 | #region Serialization 47 | 48 | public CallNode(SerializationInfo info, StreamingContext context) 49 | : base(info, context) 50 | { 51 | Label = info.GetValue("label"); 52 | } 53 | 54 | public override void GetObjectData 55 | (SerializationInfo info, StreamingContext context) 56 | { 57 | info.AddValue("label", Label); 58 | } 59 | 60 | #endregion 61 | 62 | public override string ToString() 63 | { 64 | return "jump " + Label; 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /Engine/Nodes/CallNode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 51581b5b0a9d01943ad3125e6348f8cb 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Engine/Nodes/ChooseNode.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.Serialization; 3 | 4 | namespace Exodrifter.Rumor.Engine 5 | { 6 | [Serializable] 7 | public class ChooseNode : Node, ISerializable 8 | { 9 | private readonly Expression timeout; 10 | private readonly MoveType? moveType; 11 | private readonly string label; 12 | 13 | public ChooseNode() { } 14 | 15 | public ChooseNode(Expression timeout, MoveType moveType, string label) 16 | { 17 | this.timeout = timeout; 18 | this.moveType = moveType; 19 | this.label = label; 20 | } 21 | 22 | public override Yield Execute(Rumor rumor) 23 | { 24 | var value = timeout?.Evaluate(rumor.Scope, rumor.Bindings); 25 | return new ForChoose( 26 | value?.AsNumber()?.Value, 27 | moveType, 28 | label 29 | ); 30 | } 31 | 32 | #region Equality 33 | 34 | public override bool Equals(object obj) 35 | { 36 | return Equals(obj as ChooseNode); 37 | } 38 | 39 | public bool Equals(ChooseNode other) 40 | { 41 | if (other == null) 42 | { 43 | return false; 44 | } 45 | 46 | return this.timeout == other.timeout 47 | && this.moveType == other.moveType 48 | && this.label == other.label; 49 | } 50 | 51 | public override int GetHashCode() 52 | { 53 | return Util.GetHashCode("choose", timeout, moveType, label); 54 | } 55 | 56 | #endregion 57 | 58 | #region Serialization 59 | 60 | public ChooseNode(SerializationInfo info, StreamingContext context) 61 | : base(info, context) 62 | { 63 | timeout = info.GetValue("timeout"); 64 | moveType = info.GetValue("moveType"); 65 | label = info.GetValue("label"); 66 | } 67 | 68 | public override void GetObjectData 69 | (SerializationInfo info, StreamingContext context) 70 | { 71 | info.AddValue("timeout", timeout); 72 | info.AddValue("moveType", moveType); 73 | info.AddValue("label", label); 74 | } 75 | 76 | #endregion 77 | 78 | public override string ToString() 79 | { 80 | if (timeout == null) 81 | { 82 | return "choose"; 83 | } 84 | else 85 | { 86 | var move = moveType == MoveType.Jump ? "jump" : "call"; 87 | return "choose in {" + timeout + "} seconds or " + move + " " + 88 | label; 89 | } 90 | } 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /Engine/Nodes/ChooseNode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 323073157bcde9549b4d10568ef72bc2 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Engine/Nodes/ClearNode.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.Serialization; 3 | 4 | namespace Exodrifter.Rumor.Engine 5 | { 6 | [Serializable] 7 | public class ClearNode : Node, ISerializable 8 | { 9 | public ClearType Type { get; } 10 | public string LabelTarget { get; } 11 | 12 | public ClearNode(ClearType type, string labelTarget) 13 | { 14 | Type = type; 15 | LabelTarget = labelTarget; 16 | } 17 | 18 | public override Yield Execute(Rumor rumor) 19 | { 20 | rumor.State.Clear(Type, LabelTarget); 21 | return null; 22 | } 23 | 24 | #region Equality 25 | 26 | public override bool Equals(object obj) 27 | { 28 | return Equals(obj as ClearNode); 29 | } 30 | 31 | public bool Equals(ClearNode other) 32 | { 33 | if (other == null) 34 | { 35 | return false; 36 | } 37 | 38 | return this.Type == other.Type 39 | && this.LabelTarget == other.LabelTarget; 40 | } 41 | 42 | public override int GetHashCode() 43 | { 44 | return Util.GetHashCode("clear", Type, LabelTarget); 45 | } 46 | 47 | #endregion 48 | 49 | #region Serialization 50 | 51 | public ClearNode(SerializationInfo info, StreamingContext context) 52 | : base(info, context) 53 | { 54 | Type = info.GetValue("type"); 55 | } 56 | 57 | public override void GetObjectData 58 | (SerializationInfo info, StreamingContext context) 59 | { 60 | info.AddValue("type", Type); 61 | } 62 | 63 | #endregion 64 | 65 | public override string ToString() 66 | { 67 | switch (Type) 68 | { 69 | case ClearType.All: 70 | return "clear all"; 71 | case ClearType.Choices: 72 | return "clear choices"; 73 | case ClearType.Dialog: 74 | return "clear dialog"; 75 | 76 | default: 77 | return "clear " + Type; 78 | } 79 | } 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /Engine/Nodes/ClearNode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e3abaa48860f0b34fa894e61ebd531d9 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Engine/Nodes/ControlNode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 400e6d70cb733c245a48b1b1f403d760 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Engine/Nodes/DialogNode.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.Serialization; 3 | 4 | namespace Exodrifter.Rumor.Engine 5 | { 6 | [Serializable] 7 | public abstract class DialogNode : Node, ISerializable 8 | { 9 | public string Speaker { get; } 10 | public Expression Dialog { get; } 11 | 12 | public DialogNode(string speaker, string dialog) 13 | { 14 | Speaker = speaker; 15 | Dialog = new StringLiteral(dialog); 16 | } 17 | 18 | public DialogNode(string speaker, Expression dialog) 19 | { 20 | Speaker = speaker; 21 | Dialog = dialog; 22 | } 23 | 24 | #region Serialization 25 | 26 | public DialogNode(SerializationInfo info, StreamingContext context) 27 | : base(info, context) 28 | { 29 | Speaker = info.GetValue("speaker"); 30 | Dialog = info.GetValue("dialog"); 31 | } 32 | 33 | public override void GetObjectData 34 | (SerializationInfo info, StreamingContext context) 35 | { 36 | info.AddValue("speaker", Speaker); 37 | info.AddValue("dialog", Dialog); 38 | } 39 | 40 | #endregion 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Engine/Nodes/DialogNode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 60deecf3ab649a74787d0ef3574224c4 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Engine/Nodes/JumpNode.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.Serialization; 3 | 4 | namespace Exodrifter.Rumor.Engine 5 | { 6 | [Serializable] 7 | public class JumpNode : Node, ISerializable 8 | { 9 | public string Label { get; } 10 | 11 | public JumpNode(string label) 12 | { 13 | Label = label; 14 | } 15 | 16 | public override Yield Execute(Rumor rumor) 17 | { 18 | rumor.Jump(Label); 19 | return null; 20 | } 21 | 22 | #region Equality 23 | 24 | public override bool Equals(object obj) 25 | { 26 | return Equals(obj as JumpNode); 27 | } 28 | 29 | public bool Equals(JumpNode other) 30 | { 31 | if (other == null) 32 | { 33 | return false; 34 | } 35 | 36 | return Label == other.Label; 37 | } 38 | 39 | public override int GetHashCode() 40 | { 41 | return Util.GetHashCode("jump", Label); 42 | } 43 | 44 | #endregion 45 | 46 | #region Serialization 47 | 48 | public JumpNode(SerializationInfo info, StreamingContext context) 49 | : base(info, context) 50 | { 51 | Label = info.GetValue("label"); 52 | } 53 | 54 | public override void GetObjectData 55 | (SerializationInfo info, StreamingContext context) 56 | { 57 | info.AddValue("label", Label); 58 | } 59 | 60 | #endregion 61 | 62 | public override string ToString() 63 | { 64 | return "jump " + Label; 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /Engine/Nodes/JumpNode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 35e71ef577f2db34aba19dae3763464f 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Engine/Nodes/Node.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.Serialization; 3 | 4 | namespace Exodrifter.Rumor.Engine 5 | { 6 | [Serializable] 7 | public abstract class Node : ISerializable 8 | { 9 | public Node() { } 10 | 11 | public abstract Yield Execute(Rumor rumor); 12 | 13 | public static bool operator ==(Node l, Node r) 14 | { 15 | if (ReferenceEquals(l, r)) 16 | { 17 | return true; 18 | } 19 | if (l as object == null || r as object == null) 20 | { 21 | return false; 22 | } 23 | return l.Equals(r); 24 | } 25 | 26 | public static bool operator !=(Node l, Node r) 27 | { 28 | return !(l == r); 29 | } 30 | 31 | #region Serialization 32 | 33 | public Node(SerializationInfo info, StreamingContext context) { } 34 | 35 | public abstract void GetObjectData 36 | (SerializationInfo info, StreamingContext context); 37 | 38 | #endregion 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Engine/Nodes/Node.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cd9f02ca8756e7e49bd76dd189b6a78b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Engine/Nodes/PauseNode.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.Serialization; 3 | 4 | namespace Exodrifter.Rumor.Engine 5 | { 6 | [Serializable] 7 | public class PauseNode : Node, ISerializable 8 | { 9 | public Expression Time { get; } 10 | 11 | public PauseNode(double seconds) 12 | { 13 | Time = new NumberLiteral(seconds); 14 | } 15 | 16 | public PauseNode(Expression time) 17 | { 18 | Time = time; 19 | } 20 | 21 | public override Yield Execute(Rumor rumor) 22 | { 23 | var value = Time.Evaluate(rumor.Scope, rumor.Bindings); 24 | var seconds = value.AsNumber().Value; 25 | return new ForSeconds(seconds); 26 | } 27 | 28 | #region Equality 29 | 30 | public override bool Equals(object obj) 31 | { 32 | return Equals(obj as PauseNode); 33 | } 34 | 35 | public bool Equals(PauseNode other) 36 | { 37 | if (other == null) 38 | { 39 | return false; 40 | } 41 | 42 | return Time == other.Time; 43 | } 44 | 45 | public override int GetHashCode() 46 | { 47 | return Util.GetHashCode("pause", Time); 48 | } 49 | 50 | #endregion 51 | 52 | #region Serialization 53 | 54 | public PauseNode(SerializationInfo info, StreamingContext context) 55 | : base(info, context) 56 | { 57 | Time = info.GetValue("time"); 58 | } 59 | 60 | public override void GetObjectData 61 | (SerializationInfo info, StreamingContext context) 62 | { 63 | info.AddValue("time", Time); 64 | } 65 | 66 | #endregion 67 | 68 | public override string ToString() 69 | { 70 | return "pause " + Time; 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /Engine/Nodes/PauseNode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 09a7edda239383a48b3f4d72e3b75712 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Engine/Nodes/ReturnNode.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.Serialization; 3 | 4 | namespace Exodrifter.Rumor.Engine 5 | { 6 | [Serializable] 7 | public class ReturnNode : Node, ISerializable 8 | { 9 | public ReturnNode() { } 10 | 11 | public override Yield Execute(Rumor rumor) 12 | { 13 | rumor.Return(); 14 | return null; 15 | } 16 | 17 | #region Equality 18 | 19 | public override bool Equals(object obj) 20 | { 21 | return Equals(obj as ReturnNode); 22 | } 23 | 24 | public bool Equals(ReturnNode other) 25 | { 26 | if (other == null) 27 | { 28 | return false; 29 | } 30 | 31 | return true; 32 | } 33 | 34 | public override int GetHashCode() 35 | { 36 | return Util.GetHashCode("return"); 37 | } 38 | 39 | #endregion 40 | 41 | #region Serialization 42 | 43 | public ReturnNode(SerializationInfo info, StreamingContext context) 44 | : base(info, context) { } 45 | 46 | public override void GetObjectData 47 | (SerializationInfo info, StreamingContext context) { } 48 | 49 | #endregion 50 | 51 | public override string ToString() 52 | { 53 | return "return"; 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /Engine/Nodes/ReturnNode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b66ffc36690ca7140bc9de6b34dfea05 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Engine/Nodes/SetDialogNode.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.Serialization; 3 | 4 | namespace Exodrifter.Rumor.Engine 5 | { 6 | [Serializable] 7 | public class SetDialogNode : DialogNode, ISerializable 8 | { 9 | public SetDialogNode(string speaker, string dialog) 10 | : base(speaker, dialog) { } 11 | 12 | public SetDialogNode(string speaker, Expression dialog) 13 | : base(speaker, dialog) { } 14 | 15 | public override Yield Execute(Rumor rumor) 16 | { 17 | var value = Dialog.Evaluate(rumor.Scope, rumor.Bindings); 18 | var dialog = value.AsString().Value; 19 | rumor.State.SetDialog(Speaker, dialog); 20 | return new ForAdvance(); 21 | } 22 | 23 | #region Equality 24 | 25 | public override bool Equals(object obj) 26 | { 27 | return Equals(obj as SetDialogNode); 28 | } 29 | 30 | public bool Equals(SetDialogNode other) 31 | { 32 | if (other == null) 33 | { 34 | return false; 35 | } 36 | 37 | return Speaker == other.Speaker 38 | && Dialog == other.Dialog; 39 | } 40 | 41 | public override int GetHashCode() 42 | { 43 | return Util.GetHashCode("set", Speaker, Dialog); 44 | } 45 | 46 | #endregion 47 | 48 | #region Serialization 49 | 50 | public SetDialogNode(SerializationInfo info, StreamingContext context) 51 | : base(info, context) { } 52 | 53 | #endregion 54 | 55 | public override string ToString() 56 | { 57 | return Speaker + ": " + Dialog; 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /Engine/Nodes/SetDialogNode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 12b4ba6191503b242b58598257b1399e 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Engine/Nodes/SetVariableNode.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.Serialization; 3 | 4 | namespace Exodrifter.Rumor.Engine 5 | { 6 | [Serializable] 7 | public class SetVariableNode : Node, ISerializable 8 | { 9 | public string Name { get; } 10 | public Expression Expression { get; } 11 | 12 | public SetVariableNode(string name, Expression expression) 13 | { 14 | Name = name; 15 | Expression = expression; 16 | } 17 | 18 | public override Yield Execute(Rumor rumor) 19 | { 20 | var value = Expression.Evaluate(rumor.Scope, rumor.Bindings); 21 | rumor.Scope.Set(Name, value); 22 | return null; 23 | } 24 | 25 | #region Equality 26 | 27 | public override bool Equals(object obj) 28 | { 29 | return Equals(obj as SetVariableNode); 30 | } 31 | 32 | public bool Equals(SetVariableNode other) 33 | { 34 | if (other == null) 35 | { 36 | return false; 37 | } 38 | 39 | return Name == other.Name 40 | && Expression == other.Expression; 41 | } 42 | 43 | public override int GetHashCode() 44 | { 45 | return Util.GetHashCode("variable", Name, Expression); 46 | } 47 | 48 | #endregion 49 | 50 | #region Serialization 51 | 52 | public SetVariableNode(SerializationInfo info, StreamingContext context) 53 | : base(info, context) 54 | { 55 | Name = info.GetValue("name"); 56 | Expression = info.GetValue("expression"); 57 | } 58 | 59 | public override void GetObjectData 60 | (SerializationInfo info, StreamingContext context) 61 | { 62 | info.AddValue("name", Name); 63 | info.AddValue("expression", Expression); 64 | } 65 | 66 | #endregion 67 | 68 | public override string ToString() 69 | { 70 | return Name + " = " + Expression; 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /Engine/Nodes/SetVariableNode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9ffcd3ae8a2f97148bf8000a074d8750 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Engine/Nodes/WaitNode.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.Serialization; 3 | 4 | namespace Exodrifter.Rumor.Engine 5 | { 6 | [Serializable] 7 | public class WaitNode : Node, ISerializable 8 | { 9 | public WaitNode() { } 10 | 11 | public override Yield Execute(Rumor rumor) 12 | { 13 | return new ForAdvance(); 14 | } 15 | 16 | #region Equality 17 | 18 | public override bool Equals(object obj) 19 | { 20 | return Equals(obj as WaitNode); 21 | } 22 | 23 | public bool Equals(WaitNode other) 24 | { 25 | if (other == null) 26 | { 27 | return false; 28 | } 29 | 30 | return true; 31 | } 32 | 33 | public override int GetHashCode() 34 | { 35 | return Util.GetHashCode("wait"); 36 | } 37 | 38 | #endregion 39 | 40 | #region Serialization 41 | 42 | public WaitNode(SerializationInfo info, StreamingContext context) 43 | : base(info, context) { } 44 | 45 | public override void GetObjectData 46 | (SerializationInfo info, StreamingContext context) { } 47 | 48 | #endregion 49 | 50 | public override string ToString() 51 | { 52 | return "wait"; 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /Engine/Nodes/WaitNode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ad3a76924b6c6334684bb4e87c2b232c 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Engine/Rumor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cffc64723b07f6741873e11217ed31c5 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Engine/RumorBindings.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fed7f4be21afae0858219386d03a86da 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Engine/RumorScope.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Runtime.Serialization; 4 | 5 | namespace Exodrifter.Rumor.Engine 6 | { 7 | [Serializable] 8 | public class RumorScope : ISerializable 9 | { 10 | private readonly Dictionary vars; 11 | 12 | public RumorScope() 13 | { 14 | vars = new Dictionary(); 15 | } 16 | 17 | public Dictionary GetVars() 18 | { 19 | return new Dictionary(vars); 20 | } 21 | 22 | public Value Get(string name) 23 | { 24 | if (vars.ContainsKey(name)) 25 | { 26 | return vars[name]; 27 | } 28 | return null; 29 | } 30 | 31 | public void Set(string name, Value value) 32 | { 33 | if (vars.ContainsKey(name) && vars[name].Type != value.Type) 34 | { 35 | throw new InvalidOperationException( 36 | "Cannot change the type of \"" + name + "\"!" 37 | ); 38 | } 39 | else 40 | { 41 | vars[name] = value; 42 | } 43 | } 44 | 45 | public void Set(string name, bool value) 46 | { 47 | Set(name, new BooleanValue(value)); 48 | } 49 | 50 | public void Set(string name, double value) 51 | { 52 | Set(name, new NumberValue(value)); 53 | } 54 | 55 | public void Set(string name, string value) 56 | { 57 | Set(name, new StringValue(value)); 58 | } 59 | 60 | #region Serialization 61 | 62 | public RumorScope(SerializationInfo info, StreamingContext context) 63 | { 64 | vars = info.GetValue>("vars"); 65 | } 66 | 67 | public void GetObjectData 68 | (SerializationInfo info, StreamingContext context) 69 | { 70 | info.AddValue>("vars", vars); 71 | } 72 | 73 | #endregion 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /Engine/RumorScope.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ccd38b90263cd7bf082fb8b5c8f48636 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Engine/RumorState.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5f61b8c525ea61146931c0be97e10a0f 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Engine/SerializationInfoExtensions.cs: -------------------------------------------------------------------------------- 1 | 2 | using System.Runtime.Serialization; 3 | 4 | namespace Exodrifter.Rumor.Engine 5 | { 6 | internal static class SerializationInfoExtensions 7 | { 8 | /// 9 | /// Retreives a value from the store. 10 | /// 11 | /// 12 | /// The type of the value. 13 | /// 14 | /// 15 | /// The to retreive the value from. 16 | /// 17 | /// 18 | /// The name associated with the value to retreive. 19 | /// 20 | /// The value. 21 | public static T GetValue(this SerializationInfo self, string name) 22 | { 23 | return (T)self.GetValue(name, typeof(T)); 24 | } 25 | 26 | /// 27 | /// Adds a value into the store, where 28 | /// value is associated with name and is serialized as being of 29 | /// type. 30 | /// 31 | /// 32 | /// The type of the value. 33 | /// 34 | /// 35 | /// The to add the value to. 36 | /// 37 | /// 38 | /// The name to associate with the value. 39 | /// 40 | /// The value to add. 41 | public static void AddValue 42 | (this SerializationInfo self, string name, T @object) 43 | { 44 | self.AddValue(name, @object, typeof(T)); 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /Engine/SerializationInfoExtensions.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c8d02fe0d9906104d99b4fbe297f5985 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Engine/StackFrame.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Runtime.Serialization; 4 | 5 | namespace Exodrifter.Rumor.Engine 6 | { 7 | /// 8 | /// Contains a pointer to a list of nodes that are currently being 9 | /// executed in Rumor. 10 | /// 11 | [Serializable] 12 | internal sealed class StackFrame : ISerializable 13 | { 14 | /// 15 | /// The list of nodes in this stack frame. 16 | /// 17 | private List Nodes { get; } 18 | 19 | /// 20 | /// The index of the next node to execute. 21 | /// 22 | private int NextIndex { get; set; } 23 | 24 | /// 25 | /// True if all nodes have been executed. 26 | internal bool Done { get { return NextIndex >= Nodes.Count; } } 27 | 28 | /// 29 | /// Creates a new stack frame. 30 | /// 31 | /// 32 | /// The list of nodes to use in this stack frame. 33 | /// 34 | internal StackFrame(List nodes) 35 | { 36 | // Make a copy so our version does not change 37 | Nodes = new List(nodes); 38 | NextIndex = 0; 39 | } 40 | 41 | /// 42 | /// Executes the next node in the stack frame. 43 | /// 44 | /// The rumor executing this stack frame. 45 | /// The yield preventing further execution, if any. 46 | internal Yield Execute(Rumor rumor) 47 | { 48 | var node = Nodes[NextIndex]; 49 | NextIndex++; 50 | 51 | return node.Execute(rumor); 52 | } 53 | 54 | #region Serialization 55 | 56 | public StackFrame(SerializationInfo info, StreamingContext context) 57 | { 58 | Nodes = info.GetValue>("nodes"); 59 | NextIndex = info.GetValue("nextIndex"); 60 | } 61 | 62 | public void GetObjectData 63 | (SerializationInfo info, StreamingContext context) 64 | { 65 | info.AddValue>("nodes", Nodes); 66 | info.AddValue("nextIndex", NextIndex); 67 | } 68 | 69 | #endregion 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /Engine/StackFrame.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 146dcd7553afe60479b6b7d2a2c2fac8 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Engine/Tests.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 26e89aa4f508ac34f9e912e77aa26446 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Engine/Tests/AppendExecution.cs: -------------------------------------------------------------------------------- 1 | using NUnit.Framework; 2 | using System.Collections.Generic; 3 | 4 | namespace Exodrifter.Rumor.Engine.Tests 5 | { 6 | public static class AppendExecution 7 | { 8 | [Test] 9 | public static void AppendSuccess() 10 | { 11 | var rumor = new Rumor( 12 | new Dictionary> 13 | { 14 | { Rumor.MainIdentifier, new List() 15 | { new AppendDialogNode("Alice", "Hello world!") 16 | , new AppendDialogNode("Alice", "How are you?") 17 | } 18 | } 19 | } 20 | ); 21 | 22 | rumor.Start(); 23 | Assert.IsTrue(rumor.Executing); 24 | Assert.AreEqual( 25 | new Dictionary() 26 | { 27 | { "Alice", "Hello world!" } 28 | }, 29 | rumor.State.GetDialog() 30 | ); 31 | 32 | rumor.Advance(); 33 | Assert.IsTrue(rumor.Executing); 34 | Assert.AreEqual( 35 | new Dictionary() 36 | { 37 | { "Alice", "Hello world! How are you?" } 38 | }, 39 | rumor.State.GetDialog() 40 | ); 41 | 42 | rumor.Advance(); 43 | Assert.IsFalse(rumor.Executing); 44 | Assert.AreEqual(1, rumor.FinishCount); 45 | Assert.AreEqual(0, rumor.CancelCount); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /Engine/Tests/AppendExecution.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 204bd5d0ba47681469d3078b06ce2bbb 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Engine/Tests/AutoAdvanceExecution.cs: -------------------------------------------------------------------------------- 1 | using NUnit.Framework; 2 | using System.Collections.Generic; 3 | 4 | namespace Exodrifter.Rumor.Engine.Tests 5 | { 6 | public static class AutoAdvanceExecution 7 | { 8 | [Test] 9 | public static void AutoAdvance0() 10 | { 11 | var rumor = new Rumor( 12 | new Dictionary> 13 | { 14 | { Rumor.MainIdentifier, new List() 15 | { new SetDialogNode("Alice", "Hello world!") 16 | , new SetDialogNode("Alice", "How are you?") 17 | } 18 | } 19 | } 20 | ); 21 | 22 | rumor.Start(); 23 | rumor.SetAutoAdvance(0); 24 | Assert.AreEqual( 25 | new Dictionary() 26 | { 27 | { "Alice", "How are you?" } 28 | }, 29 | rumor.State.GetDialog() 30 | ); 31 | 32 | Assert.IsFalse(rumor.Executing); 33 | Assert.AreEqual(1, rumor.FinishCount); 34 | Assert.AreEqual(0, rumor.CancelCount); 35 | } 36 | 37 | [Test] 38 | public static void AutoAdvanceNormal() 39 | { 40 | var rumor = new Rumor( 41 | new Dictionary> 42 | { 43 | { Rumor.MainIdentifier, new List() 44 | { new SetDialogNode("Alice", "Hello world!") 45 | , new SetDialogNode("Alice", "How are you?") 46 | } 47 | } 48 | } 49 | ); 50 | 51 | rumor.Start(); 52 | rumor.SetAutoAdvance(1); 53 | Assert.IsTrue(rumor.Executing); 54 | Assert.AreEqual( 55 | new Dictionary() 56 | { 57 | { "Alice", "Hello world!" } 58 | }, 59 | rumor.State.GetDialog() 60 | ); 61 | 62 | rumor.Update(1); 63 | Assert.IsTrue(rumor.Executing); 64 | Assert.AreEqual( 65 | new Dictionary() 66 | { 67 | { "Alice", "How are you?" } 68 | }, 69 | rumor.State.GetDialog() 70 | ); 71 | 72 | rumor.Update(1); 73 | Assert.IsFalse(rumor.Executing); 74 | Assert.AreEqual(1, rumor.FinishCount); 75 | Assert.AreEqual(0, rumor.CancelCount); 76 | } 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /Engine/Tests/AutoAdvanceExecution.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1e7cfca81477c744d857b4139a88164d 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Engine/Tests/CallExecution.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 73ad2ee5d5a809e4d8aa82ea40228380 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Engine/Tests/ChoiceExecution.cs: -------------------------------------------------------------------------------- 1 | using NUnit.Framework; 2 | using System.Collections.Generic; 3 | 4 | namespace Exodrifter.Rumor.Engine.Tests 5 | { 6 | public static class ChoiceExecution 7 | { 8 | [Test] 9 | public static void ChoiceSuccess() 10 | { 11 | var rumor = new Rumor( 12 | new Dictionary> 13 | { 14 | { Rumor.MainIdentifier, new List() 15 | { new AddChoiceNode("choice1", "Hello?") 16 | , new AddChoiceNode("choice2", "Hello??") 17 | } 18 | } 19 | } 20 | ); 21 | 22 | rumor.Start(); 23 | Assert.IsFalse(rumor.Executing); 24 | Assert.AreEqual(1, rumor.FinishCount); 25 | Assert.AreEqual(0, rumor.CancelCount); 26 | Assert.AreEqual( 27 | new Dictionary() 28 | { 29 | { "choice1", "Hello?" }, 30 | { "choice2", "Hello??" } 31 | }, 32 | rumor.State.GetChoices() 33 | ); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Engine/Tests/ChoiceExecution.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9138abbc34e00f84984762cfbd430141 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Engine/Tests/ChooseExecution.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 940653feb31f3944dbc031070251f1c0 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Engine/Tests/ClearExecution.cs: -------------------------------------------------------------------------------- 1 | using NUnit.Framework; 2 | using System.Collections.Generic; 3 | 4 | namespace Exodrifter.Rumor.Engine.Tests 5 | { 6 | public static class ClearExecution 7 | { 8 | [Test] 9 | public static void ClearDialogSuccess() 10 | { 11 | var rumor = new Rumor( 12 | new Dictionary> 13 | { 14 | { Rumor.MainIdentifier, new List() 15 | { new SetDialogNode("Alice", "Hello world!") 16 | , new ClearNode(ClearType.Dialog, null) 17 | } 18 | } 19 | } 20 | ); 21 | 22 | rumor.Start(); 23 | Assert.IsTrue(rumor.Executing); 24 | Assert.AreEqual( 25 | new Dictionary() 26 | { 27 | { "Alice", "Hello world!" } 28 | }, 29 | rumor.State.GetDialog() 30 | ); 31 | 32 | rumor.Advance(); 33 | Assert.IsFalse(rumor.Executing); 34 | Assert.AreEqual(1, rumor.FinishCount); 35 | Assert.AreEqual(0, rumor.CancelCount); 36 | Assert.AreEqual( 37 | new Dictionary() { }, 38 | rumor.State.GetDialog() 39 | ); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Engine/Tests/ClearExecution.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9fcc604ecf480574987686b91598fa0d 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Engine/Tests/Exodrifter.Rumor.Engine.Tests.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Exodrifter.Rumor.Engine.Tests", 3 | "rootNamespace": "", 4 | "references": [ 5 | "GUID:3b1021c3659174e4d8475c19a9c62fd5" 6 | ], 7 | "includePlatforms": [ 8 | "Editor" 9 | ], 10 | "excludePlatforms": [], 11 | "allowUnsafeCode": false, 12 | "overrideReferences": true, 13 | "precompiledReferences": [], 14 | "autoReferenced": false, 15 | "defineConstraints": [ 16 | "UNITY_TEST_FRAMEWORK_EXISTS" 17 | ], 18 | "versionDefines": [ 19 | { 20 | "name": "com.unity.test-framework", 21 | "expression": "0", 22 | "define": "UNITY_TEST_FRAMEWORK_EXISTS" 23 | } 24 | ], 25 | "noEngineReferences": true 26 | } -------------------------------------------------------------------------------- /Engine/Tests/Exodrifter.Rumor.Engine.Tests.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7c576a1537603c94b83790e10792e046 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Engine/Tests/ExpressionSerialization.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b7628f280bbc89046af78774cee3ea2d 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Engine/Tests/JumpExecution.cs: -------------------------------------------------------------------------------- 1 | using NUnit.Framework; 2 | using System; 3 | using System.Collections.Generic; 4 | 5 | namespace Exodrifter.Rumor.Engine.Tests 6 | { 7 | public static class JumpExecution 8 | { 9 | [Test] 10 | public static void JumpSuccess() 11 | { 12 | var rumor = new Rumor( 13 | new Dictionary> 14 | { 15 | { Rumor.MainIdentifier, new List() 16 | { new JumpNode("foobar") 17 | , new WaitNode() 18 | } 19 | }, 20 | { "foobar", new List() 21 | { new WaitNode() 22 | } 23 | } 24 | } 25 | ); 26 | 27 | rumor.Start(); 28 | Assert.IsTrue(rumor.Executing); 29 | 30 | rumor.Advance(); 31 | Assert.IsFalse(rumor.Executing); 32 | Assert.AreEqual(1, rumor.FinishCount); 33 | Assert.AreEqual(0, rumor.CancelCount); 34 | } 35 | 36 | [Test] 37 | public static void JumpFailure() 38 | { 39 | var rumor = new Rumor( 40 | new Dictionary> 41 | { 42 | { Rumor.MainIdentifier, new List() 43 | { new JumpNode("foobar") 44 | } 45 | } 46 | } 47 | ); 48 | 49 | var exception = Assert.Throws(() => 50 | rumor.Start() 51 | ); 52 | Assert.AreEqual( 53 | "The label \"foobar\" does not exist!", 54 | exception.Message 55 | ); 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /Engine/Tests/JumpExecution.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a0fd0eed971cf5745af6fd15dc0e3fb0 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Engine/Tests/NodeSerialization.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 88ac26c1ba9f5f048b4f1da133b12c55 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Engine/Tests/PauseExecution.cs: -------------------------------------------------------------------------------- 1 | using NUnit.Framework; 2 | using System.Collections.Generic; 3 | 4 | namespace Exodrifter.Rumor.Engine.Tests 5 | { 6 | public static class PauseExecution 7 | { 8 | [Test] 9 | public static void PauseSuccess() 10 | { 11 | var rumor = new Rumor( 12 | new Dictionary> 13 | { 14 | { Rumor.MainIdentifier, new List() 15 | { new PauseNode(1d) 16 | } 17 | }, 18 | } 19 | ); 20 | 21 | rumor.Start(); 22 | Assert.IsTrue(rumor.Executing); 23 | 24 | rumor.Update(0.5f); 25 | Assert.IsTrue(rumor.Executing); 26 | 27 | rumor.Update(0.5f); 28 | Assert.IsFalse(rumor.Executing); 29 | Assert.AreEqual(1, rumor.FinishCount); 30 | Assert.AreEqual(0, rumor.CancelCount); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Engine/Tests/PauseExecution.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6e07d43fdcbf39f42bf9c59973ae1988 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Engine/Tests/ReturnExecution.cs: -------------------------------------------------------------------------------- 1 | using NUnit.Framework; 2 | using System.Collections.Generic; 3 | 4 | namespace Exodrifter.Rumor.Engine.Tests 5 | { 6 | public static class ReturnExecution 7 | { 8 | [Test] 9 | public static void ReturnSuccess() 10 | { 11 | var rumor = new Rumor( 12 | new Dictionary> 13 | { 14 | { Rumor.MainIdentifier, new List() 15 | { new ReturnNode() 16 | , new WaitNode() 17 | } 18 | }, 19 | } 20 | ); 21 | 22 | rumor.Start(); 23 | Assert.IsFalse(rumor.Executing); 24 | Assert.AreEqual(1, rumor.FinishCount); 25 | Assert.AreEqual(0, rumor.CancelCount); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Engine/Tests/ReturnExecution.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3fa7fd12bc2b4a9429f1ed9f7885d9dd 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Engine/Tests/SayExecution.cs: -------------------------------------------------------------------------------- 1 | using NUnit.Framework; 2 | using System.Collections.Generic; 3 | 4 | namespace Exodrifter.Rumor.Engine.Tests 5 | { 6 | public static class SayExecution 7 | { 8 | [Test] 9 | public static void SaySuccess() 10 | { 11 | var rumor = new Rumor( 12 | new Dictionary> 13 | { 14 | { Rumor.MainIdentifier, new List() 15 | { new SetDialogNode("Alice", "Hello world!") 16 | , new SetDialogNode("Alice", "How are you?") 17 | } 18 | } 19 | } 20 | ); 21 | 22 | rumor.Start(); 23 | Assert.IsTrue(rumor.Executing); 24 | Assert.AreEqual( 25 | new Dictionary() 26 | { 27 | { "Alice", "Hello world!" } 28 | }, 29 | rumor.State.GetDialog() 30 | ); 31 | 32 | rumor.Advance(); 33 | Assert.IsTrue(rumor.Executing); 34 | Assert.AreEqual( 35 | new Dictionary() 36 | { 37 | { "Alice", "How are you?" } 38 | }, 39 | rumor.State.GetDialog() 40 | ); 41 | 42 | rumor.Advance(); 43 | Assert.IsFalse(rumor.Executing); 44 | Assert.AreEqual(1, rumor.FinishCount); 45 | Assert.AreEqual(0, rumor.CancelCount); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /Engine/Tests/SayExecution.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: af35dd899bc584b45954bf26ffe1cb2d 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Engine/Tests/SerializationUtil.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using System.Runtime.Serialization; 3 | using System.Runtime.Serialization.Formatters.Binary; 4 | 5 | namespace Exodrifter.Rumor.Engine.Tests 6 | { 7 | public class SerializationUtil 8 | { 9 | /// 10 | /// Serializes and then deserializes the passed object. 11 | /// 12 | /// 13 | /// The type of the object. 14 | /// 15 | /// 16 | /// The object to re-serialize. 17 | /// 18 | /// 19 | /// The object after it has been re-serialized. 20 | /// 21 | public static T Reserialize(T o) 22 | { 23 | return Deserialize(Serialize(o)); 24 | } 25 | 26 | private static MemoryStream Serialize(T o) 27 | { 28 | MemoryStream stream = new MemoryStream(); 29 | IFormatter formatter = new BinaryFormatter(); 30 | formatter.Serialize(stream, o); 31 | return stream; 32 | } 33 | 34 | private static T Deserialize(MemoryStream stream) 35 | { 36 | IFormatter formatter = new BinaryFormatter(); 37 | stream.Seek(0, SeekOrigin.Begin); 38 | object rumor = formatter.Deserialize(stream); 39 | return (T)rumor; 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Engine/Tests/SerializationUtil.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 20cf06d7470610046a6bff3aad45a625 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Engine/Tests/WaitExecution.cs: -------------------------------------------------------------------------------- 1 | using NUnit.Framework; 2 | using System.Collections.Generic; 3 | 4 | namespace Exodrifter.Rumor.Engine.Tests 5 | { 6 | public static class WaitExecution 7 | { 8 | [Test] 9 | public static void WaitSuccess() 10 | { 11 | var rumor = new Rumor( 12 | new Dictionary> 13 | { 14 | { Rumor.MainIdentifier, new List() 15 | { new WaitNode() 16 | } 17 | }, 18 | } 19 | ); 20 | 21 | rumor.Start(); 22 | Assert.IsTrue(rumor.Executing); 23 | 24 | rumor.Advance(); 25 | Assert.IsFalse(rumor.Executing); 26 | Assert.AreEqual(1, rumor.FinishCount); 27 | Assert.AreEqual(0, rumor.CancelCount); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Engine/Tests/WaitExecution.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: aff980507c4ba3a4cb95ab33ea960a98 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Engine/Types.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4d6f96e8af3e2bf4098cd6c7ce3c7487 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Engine/Types/ClearType.cs: -------------------------------------------------------------------------------- 1 | namespace Exodrifter.Rumor.Engine 2 | { 3 | public enum ClearType { All = 3, Choices = 1, Dialog = 2, Choice = 4 } 4 | } 5 | -------------------------------------------------------------------------------- /Engine/Types/ClearType.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 823f2f694c73d20469ac1dccb3a977ac 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Engine/Types/MoveType.cs: -------------------------------------------------------------------------------- 1 | namespace Exodrifter.Rumor.Engine 2 | { 3 | public enum MoveType { Call = 1, Jump = 2 } 4 | } 5 | -------------------------------------------------------------------------------- /Engine/Types/MoveType.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2af349c34727cf347a31682a526e44e1 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Engine/Util.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Exodrifter.Rumor.Engine 4 | { 5 | internal class Util 6 | { 7 | public static bool ArrayEquals(T[] l, T[] r) 8 | { 9 | if (l == null && r == null) 10 | { 11 | return true; 12 | } 13 | if (l == null || r == null) 14 | { 15 | return false; 16 | } 17 | 18 | if (l.Length != r.Length) 19 | { 20 | return false; 21 | } 22 | 23 | for (int i = 0; i < l.Length; ++i) 24 | { 25 | if (l[i] == null && r[i] == null) { 26 | continue; 27 | } 28 | else if (l[i] == null || r[i] == null) { 29 | return false; 30 | } 31 | else if (!l[i].Equals(r[i])) { 32 | return false; 33 | } 34 | } 35 | 36 | return true; 37 | } 38 | 39 | public static int GetHashCode(params object[] args) 40 | { 41 | unchecked 42 | { 43 | int hash = 17; 44 | foreach (var arg in args) 45 | { 46 | hash *= 23; 47 | if (arg != null) 48 | { 49 | hash += arg.GetHashCode(); 50 | } 51 | } 52 | return hash; 53 | } 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /Engine/Util.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bec22dfd4446c414ebd55be16ede27f4 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Engine/Value.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 98be97b9bacabb54e9ea893becf2b30f 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Engine/Value/BooleanValue.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.Serialization; 3 | 4 | namespace Exodrifter.Rumor.Engine 5 | { 6 | [Serializable] 7 | public class BooleanValue : Value, ISerializable 8 | { 9 | public bool Value { get { return (bool)InternalValue; } } 10 | public override ValueType Type => ValueType.Boolean; 11 | 12 | public BooleanValue(bool b) : base(b) { } 13 | 14 | public static BooleanValue operator |(BooleanValue l, BooleanValue r) => 15 | new BooleanValue(l.Value | r.Value); 16 | public static BooleanValue operator &(BooleanValue l, BooleanValue r) => 17 | new BooleanValue(l.Value & r.Value); 18 | public static BooleanValue operator ^(BooleanValue l, BooleanValue r) => 19 | new BooleanValue(l.Value ^ r.Value); 20 | public static BooleanValue operator !(BooleanValue l) => 21 | new BooleanValue(!l.Value); 22 | 23 | public static bool operator true(BooleanValue x) => x.Value; 24 | public static bool operator false(BooleanValue x) => !x.Value; 25 | 26 | public override string ToString() 27 | { 28 | return Value ? "true" : "false"; 29 | } 30 | 31 | #region Serialization 32 | 33 | public BooleanValue(SerializationInfo info, StreamingContext context) 34 | : base(info, context) 35 | { 36 | } 37 | 38 | #endregion 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Engine/Value/BooleanValue.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6a9d1296e21464a4eb8eeef2089aa52f 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Engine/Value/NumberValue.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.Serialization; 3 | 4 | namespace Exodrifter.Rumor.Engine 5 | { 6 | [Serializable] 7 | public class NumberValue : Value, ISerializable 8 | { 9 | public double Value { get { return (double)InternalValue; } } 10 | public override ValueType Type => ValueType.Number; 11 | 12 | public NumberValue(double n) : base(n) { } 13 | 14 | public static NumberValue operator +(NumberValue n) => n; 15 | public static NumberValue operator -(NumberValue n) => 16 | new NumberValue(-n.Value); 17 | 18 | public static NumberValue operator +(NumberValue l, NumberValue r) => 19 | new NumberValue(l.Value + r.Value); 20 | public static NumberValue operator -(NumberValue l, NumberValue r) => 21 | new NumberValue(l.Value - r.Value); 22 | public static NumberValue operator *(NumberValue l, NumberValue r) => 23 | new NumberValue(l.Value * r.Value); 24 | public static NumberValue operator /(NumberValue l, NumberValue r) => 25 | new NumberValue(l.Value / r.Value); 26 | 27 | public static bool operator >(NumberValue l, NumberValue r) => 28 | l.Value > r.Value; 29 | public static bool operator <(NumberValue l, NumberValue r) => 30 | l.Value < r.Value; 31 | public static bool operator >=(NumberValue l, NumberValue r) => 32 | l.Value >= r.Value; 33 | public static bool operator <=(NumberValue l, NumberValue r) => 34 | l.Value <= r.Value; 35 | 36 | #region Serialization 37 | 38 | public NumberValue(SerializationInfo info, StreamingContext context) 39 | : base(info, context) 40 | { 41 | } 42 | 43 | #endregion 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Engine/Value/NumberValue.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 550105b3ebc1130428621f0b8c41726a 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Engine/Value/StringValue.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.Serialization; 3 | 4 | namespace Exodrifter.Rumor.Engine 5 | { 6 | [Serializable] 7 | public class StringValue : Value, ISerializable 8 | { 9 | public string Value { get { return (string)InternalValue; } } 10 | public override ValueType Type => ValueType.String; 11 | 12 | public StringValue(string str) : base(str) { } 13 | 14 | public static StringValue operator +(StringValue l, StringValue r) => 15 | new StringValue(l.Value + r.Value); 16 | 17 | #region Serialization 18 | 19 | public StringValue(SerializationInfo info, StreamingContext context) 20 | : base(info, context) 21 | { 22 | } 23 | 24 | #endregion 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Engine/Value/StringValue.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8c8dc48e066ed7e4dba85d2c2c23adbd 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Engine/Value/Value.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.Serialization; 3 | 4 | namespace Exodrifter.Rumor.Engine 5 | { 6 | /// 7 | /// Represents a value in Rumor. 8 | /// 9 | [Serializable] 10 | public abstract class Value : ISerializable 11 | { 12 | public object InternalValue { get; } 13 | 14 | public abstract ValueType Type { get; } 15 | 16 | /// 17 | /// Creates a new value. 18 | /// 19 | /// The value. 20 | public Value(object value) 21 | { 22 | InternalValue = value; 23 | } 24 | 25 | public BooleanValue AsBoolean() 26 | { 27 | return (BooleanValue)this; 28 | } 29 | 30 | public NumberValue AsNumber() 31 | { 32 | return (NumberValue)this; 33 | } 34 | 35 | public StringValue AsString() 36 | { 37 | return (StringValue)this; 38 | } 39 | 40 | public override string ToString() 41 | { 42 | if (InternalValue == null) 43 | { 44 | return ""; 45 | } 46 | return InternalValue.ToString(); 47 | } 48 | 49 | #region Equality 50 | 51 | public override bool Equals(object obj) 52 | { 53 | return Equals(obj as Value); 54 | } 55 | 56 | public bool Equals(Value other) 57 | { 58 | if (other == null) 59 | { 60 | return false; 61 | } 62 | return Equals(InternalValue, other.InternalValue); 63 | } 64 | 65 | public override int GetHashCode() 66 | { 67 | return Util.GetHashCode(InternalValue); 68 | } 69 | 70 | public static bool operator ==(Value l, Value r) 71 | { 72 | if (ReferenceEquals(l, r)) 73 | { 74 | return true; 75 | } 76 | if (l as object == null || r as object == null) 77 | { 78 | return false; 79 | } 80 | return l.Equals(r); 81 | } 82 | 83 | public static bool operator !=(Value l, Value r) 84 | { 85 | return !(l == r); 86 | } 87 | 88 | #endregion 89 | 90 | #region Serialization 91 | 92 | public Value(SerializationInfo info, StreamingContext context) 93 | { 94 | var value = info.GetValue("value"); 95 | var type = info.GetValue("type"); 96 | InternalValue = Convert.ChangeType(value, type); 97 | } 98 | 99 | public void GetObjectData 100 | (SerializationInfo info, StreamingContext context) 101 | { 102 | info.AddValue("type", InternalValue.GetType()); 103 | info.AddValue("value", InternalValue); 104 | } 105 | 106 | #endregion 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /Engine/Value/Value.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7ed305d6f51432f41a50d7f38f6073ec 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Engine/Value/ValueType.cs: -------------------------------------------------------------------------------- 1 | namespace Exodrifter.Rumor.Engine 2 | { 3 | /// 4 | /// The type of a value. 5 | /// 6 | public enum ValueType { Boolean, Number, String } 7 | } 8 | -------------------------------------------------------------------------------- /Engine/Value/ValueType.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bce0afa19469d4440adf38ea39b3d6e1 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Engine/Yield.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4889fbed49a138943a2549f8133fff48 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016 Ava Pek (exodrifter) 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | this software and associated documentation files (the "Software"), to deal in 5 | the Software without restriction, including without limitation the rights to 6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 7 | of the Software, and to permit persons to whom the Software is furnished to do 8 | so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. 20 | -------------------------------------------------------------------------------- /LICENSE.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: aa5f95600ac4dd14bab7f7346d886295 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Parser.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3a4496d0e118e8945b499f1e856c0f8a 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Parser/Exception.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ef977d707aeac0e42b87b5960a5e44e5 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Parser/Exception/ExpectedException.cs: -------------------------------------------------------------------------------- 1 | namespace Exodrifter.Rumor.Parser 2 | { 3 | /// 4 | /// Thrown when the parser is unable to find the expected input. 5 | /// 6 | public class ExpectedException : ParserException 7 | { 8 | /// 9 | /// The potential valid input the parser was expecting. 10 | /// 11 | public string[] Expected { get; } 12 | 13 | public ExpectedException(int index, params string[] expected) 14 | : base(index, MakeMessage(expected)) 15 | { 16 | Expected = expected; 17 | } 18 | 19 | private static string MakeMessage(params string[] expected) 20 | { 21 | return "expected " + string.Join(", ", expected); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Parser/Exception/ExpectedException.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c21b2d11188f1b546acefe9e7858f587 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Parser/Exception/FormatException.cs: -------------------------------------------------------------------------------- 1 |  2 | namespace Exodrifter.Rumor.Parser 3 | { 4 | /// 5 | /// Thrown when the parser fails to convert a type to the correct format. 6 | /// 7 | public class FormatException : ParserException 8 | { 9 | public FormatException(int index, string type, string suggestion) 10 | : base(index, MakeMessage(type, suggestion)) { } 11 | 12 | private static string MakeMessage(string type, string suggestion) 13 | { 14 | return "failed to parse the format for a " + type + "; " 15 | + suggestion; 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Parser/Exception/FormatException.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f1dad5e228e3d2d469e357d7e0fa1e20 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Parser/Exception/MultipleParserException.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace Exodrifter.Rumor.Parser 4 | { 5 | /// 6 | /// Used to accumulate errors from multiple parsers. 7 | /// 8 | public class MultipleParserException : ParserException 9 | { 10 | public readonly ParserException[] exceptions; 11 | 12 | public MultipleParserException(ParserException e1, ParserException e2) 13 | : base(FirstIndex(e1, e2), MakeMessage(e1, e2)) 14 | { 15 | exceptions = AllExceptions(e1, e2).ToArray(); 16 | } 17 | 18 | private static int FirstIndex(params ParserException[] exs) 19 | { 20 | var min = int.MaxValue; 21 | 22 | var exceptions = AllExceptions(exs); 23 | foreach (var exception in exceptions) 24 | { 25 | if (exception.Index < min) 26 | { 27 | min = exception.Index; 28 | } 29 | } 30 | 31 | return min; 32 | } 33 | 34 | private static string MakeMessage(params ParserException[] exs) 35 | { 36 | var messages = new List(); 37 | 38 | var exceptions = AllExceptions(exs); 39 | foreach (var exception in exceptions) 40 | { 41 | messages.Add(exception.Message); 42 | } 43 | 44 | return "expected one of the following exceptions to not happen: " + 45 | string.Join("; ", messages); 46 | } 47 | 48 | private static List AllExceptions 49 | (params ParserException[] exceptions) 50 | { 51 | var result = new List(); 52 | 53 | foreach (var e in exceptions) 54 | { 55 | if (e is MultipleParserException) 56 | { 57 | var multipleExceptions = e as MultipleParserException; 58 | result.AddRange( 59 | AllExceptions(multipleExceptions.exceptions) 60 | ); 61 | } 62 | else 63 | { 64 | result.Add(e); 65 | } 66 | } 67 | 68 | return result; 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /Parser/Exception/MultipleParserException.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4f1677b7fe80ca84cb3f94ded237ac11 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Parser/Exception/ParserException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Exodrifter.Rumor.Parser 4 | { 5 | public abstract class ParserException : Exception 6 | { 7 | public int Index { get; } 8 | 9 | public ParserException(int index, string message) 10 | : base(MakeMessage(index, message)) 11 | { 12 | Index = index; 13 | } 14 | 15 | public ParserException(int index, string message, Exception inner) 16 | : base(MakeMessage(index, message), inner) 17 | { 18 | Index = index; 19 | } 20 | 21 | private static string MakeMessage(int index, string message) 22 | { 23 | return "parse exception at index " + index + ": " + message; 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Parser/Exception/ParserException.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 84aa64350a6ea8c40acf8bf4faef350e 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Parser/Exception/ReasonException.cs: -------------------------------------------------------------------------------- 1 | namespace Exodrifter.Rumor.Parser 2 | { 3 | /// 4 | /// Thrown when the parser needs to throw an error with a general error 5 | /// message. 6 | /// 7 | public class ReasonException : ParserException 8 | { 9 | public ReasonException(int index, string message) 10 | : base(index, message) { } 11 | 12 | public ReasonException(int index, string message, ParserException inner) 13 | : base(index, message, inner) { } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Parser/Exception/ReasonException.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f64a6ac276e130140b1000b18bd54443 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Parser/Exodrifter.Rumor.Parser.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Exodrifter.Rumor.Parser", 3 | "references": [], 4 | "includePlatforms": [], 5 | "excludePlatforms": [], 6 | "allowUnsafeCode": false, 7 | "overrideReferences": false, 8 | "precompiledReferences": [], 9 | "autoReferenced": false, 10 | "defineConstraints": [], 11 | "versionDefines": [], 12 | "noEngineReferences": true 13 | } -------------------------------------------------------------------------------- /Parser/Exodrifter.Rumor.Parser.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 99f7064735b3e3144b8444c435c2d6d4 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Parser/Parse.Block.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c1d1f59b8055bc64aa3cddd6b38e02d1 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Parser/Parse.Char.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 70b56bbb54e9dd144a5af4abb7ad51d8 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Parser/Parse.Combinator.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 87fd7739221c3914aac782c2a53b0b09 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Parser/Parse.Double.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a6a718fb0f3b2de4d9a8a67558ae80aa 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Parser/Parse.Indented.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1d83ffcdbe3bb8f499ef4c0c4f27b88c 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Parser/Parse.String.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace Exodrifter.Rumor.Parser 4 | { 5 | public static partial class Parse 6 | { 7 | /// 8 | /// Converts a parser that returns a character into a parser that 9 | /// returns a string. 10 | /// 11 | /// The parser to convert. 12 | public static Parser String(this Parser parser) => 13 | parser.Select(x => x.ToString()); 14 | 15 | /// 16 | /// Converts a parser that returns a list of characters into a parser 17 | /// that returns a string. 18 | /// 19 | /// The parser to convert. 20 | public static Parser String(this Parser> parser) 21 | { 22 | return parser.Select(chs => new string(chs.ToArray())); 23 | } 24 | 25 | /// 26 | /// Parses the specified string. 27 | /// 28 | /// The string to parse. 29 | public static Parser String(string str) 30 | { 31 | return state => 32 | { 33 | if (string.IsNullOrEmpty(str)) 34 | { 35 | return str; 36 | } 37 | 38 | if (state.Source.Length <= state.Index + str.Length - 1) 39 | { 40 | throw new ExpectedException(state.Index, "\"" + str + "\""); 41 | } 42 | 43 | if (state.Source.Substring(state.Index, str.Length) == str) 44 | { 45 | state.Index += str.Length; 46 | return str; 47 | } 48 | 49 | throw new ExpectedException(state.Index, "\"" + str + "\""); 50 | }; 51 | } 52 | 53 | /// 54 | /// Parses any one of the specified strings. 55 | /// 56 | /// The string to parse. 57 | public static Parser String(params string[] strs) 58 | { 59 | var parsers = new List>(strs.Length); 60 | foreach (var str in strs) 61 | { 62 | parsers.Add(String(str)); 63 | } 64 | return Or(parsers.ToArray()); 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /Parser/Parse.String.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 54df1ab8dc0dc464aba7fffc3657d353 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Parser/Parse.Surround.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3fc41a93854e6904c8cff478ea159286 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Parser/Parse.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c30654ef89d8fd24598db4ebf8bf3b91 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Parser/Tests.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1e7cf5fca078aa54aadaf3a1c9aeae07 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Parser/Tests/Block.cs: -------------------------------------------------------------------------------- 1 | using NUnit.Framework; 2 | 3 | namespace Exodrifter.Rumor.Parser.Tests 4 | { 5 | public static class Block 6 | { 7 | /// 8 | /// Ensure that the last newline in a block is not consumed. 9 | /// 10 | [Test] 11 | public static void BlockDoesNotConsumesNewline() 12 | { 13 | var state = new ParserState(" a\n ", 4); 14 | state.IndentIndex = 2; 15 | 16 | var result = Parse.Block(Parse.Char('a'), Parse.Same)(state); 17 | Assert.AreEqual(new char[] { 'a' }, result); 18 | 19 | Assert.AreEqual(3, state.Index); 20 | Assert.AreEqual(2, state.IndentIndex); 21 | } 22 | 23 | /// 24 | /// Ensure that prefix blocks work as expected. 25 | /// 26 | [Test] 27 | public static void PrefixBlockSingleSuccess() 28 | { 29 | var state = new ParserState(" >a\n ", 4); 30 | state.IndentIndex = 2; 31 | 32 | var result = Parse.PrefixBlock( 33 | Parse.Char('>'), Parse.Char('a'), Parse.Same 34 | )(state); 35 | Assert.AreEqual(new char[] { 'a' }, result); 36 | 37 | Assert.AreEqual(4, state.Index); 38 | Assert.AreEqual(2, state.IndentIndex); 39 | } 40 | 41 | /// 42 | /// Ensure that prefix blocks work as expected. 43 | /// 44 | [Test] 45 | public static void PrefixBlockMultilineSuccess() 46 | { 47 | var state = new ParserState(" >a\n >a", 4); 48 | state.IndentIndex = 2; 49 | 50 | var result = Parse.PrefixBlock( 51 | Parse.Char('>'), Parse.Char('a'), Parse.Same 52 | )(state); 53 | Assert.AreEqual(new char[] { 'a', 'a' }, result); 54 | 55 | Assert.AreEqual(9, state.Index); 56 | Assert.AreEqual(2, state.IndentIndex); 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /Parser/Tests/Block.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: acf8223b2bf2d8e48bf2421429aaccaf 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Parser/Tests/Chain.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 223f53ee0406ce4428e1a39b038fa80a 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Parser/Tests/Char.cs: -------------------------------------------------------------------------------- 1 | using NUnit.Framework; 2 | 3 | namespace Exodrifter.Rumor.Parser.Tests 4 | { 5 | public static class Char 6 | { 7 | [Test] 8 | public static void CharParserSuccess() 9 | { 10 | var state = new ParserState("h", 4); 11 | 12 | var result = Parse.Char('h')(state); 13 | Assert.AreEqual('h', result); 14 | 15 | Assert.AreEqual(1, state.Index); 16 | Assert.AreEqual(0, state.IndentIndex); 17 | } 18 | 19 | [Test] 20 | public static void CharParserIndexSuccess() 21 | { 22 | var state = new ParserState("world", 4); 23 | state.Index = 3; 24 | 25 | var result = Parse.Char('l')(state); 26 | Assert.AreEqual('l', result); 27 | 28 | Assert.AreEqual(4, state.Index); 29 | Assert.AreEqual(0, state.IndentIndex); 30 | } 31 | 32 | [Test] 33 | public static void CharParserFail() 34 | { 35 | var state = new ParserState("h", 4); 36 | var exception = Assert.Throws(() => 37 | Parse.Char('H')(state) 38 | ); 39 | 40 | Assert.AreEqual(0, exception.Index); 41 | Assert.AreEqual(new string[] { "'H'" }, exception.Expected); 42 | 43 | Assert.AreEqual(0, state.Index); 44 | Assert.AreEqual(0, state.IndentIndex); 45 | } 46 | 47 | [Test] 48 | public static void CharParserIndexFail() 49 | { 50 | var state = new ParserState("world", 4); 51 | state.Index = 3; 52 | 53 | var exception = Assert.Throws(() => 54 | Parse.Char('L')(state) 55 | ); 56 | Assert.AreEqual(3, exception.Index); 57 | Assert.AreEqual(new string[] { "'L'" }, exception.Expected); 58 | 59 | Assert.AreEqual(3, state.Index); 60 | Assert.AreEqual(0, state.IndentIndex); 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /Parser/Tests/Char.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9d4672935b1252e458ccb8fad5a200df 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Parser/Tests/Exodrifter.Rumor.Parser.Tests.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Exodrifter.Rumor.Parser.Tests", 3 | "rootNamespace": "", 4 | "references": [ 5 | "GUID:99f7064735b3e3144b8444c435c2d6d4" 6 | ], 7 | "includePlatforms": [ 8 | "Editor" 9 | ], 10 | "excludePlatforms": [], 11 | "allowUnsafeCode": false, 12 | "overrideReferences": true, 13 | "precompiledReferences": [], 14 | "autoReferenced": false, 15 | "defineConstraints": [ 16 | "UNITY_TEST_FRAMEWORK_EXISTS" 17 | ], 18 | "versionDefines": [ 19 | { 20 | "name": "com.unity.test-framework", 21 | "expression": "0", 22 | "define": "UNITY_TEST_FRAMEWORK_EXISTS" 23 | } 24 | ], 25 | "noEngineReferences": true 26 | } -------------------------------------------------------------------------------- /Parser/Tests/Exodrifter.Rumor.Parser.Tests.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dab115816aa077b4491ec75d34ee5dc4 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Parser/Tests/Many.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7ff5d51b5f1f6034f8c7ab408565b22a 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Parser/Tests/Maybe.cs: -------------------------------------------------------------------------------- 1 | using NUnit.Framework; 2 | 3 | namespace Exodrifter.Rumor.Parser.Tests 4 | { 5 | public static class Maybe 6 | { 7 | /// 8 | /// Test what happens when the parser will succeed. 9 | /// 10 | [Test] 11 | public static void MaybeJustSuccess() 12 | { 13 | var state = new ParserState("a", 4); 14 | 15 | var result = Parse.Char('a').Maybe()(state); 16 | Assert.AreEqual(new Maybe('a'), result); 17 | 18 | Assert.AreEqual(1, state.Index); 19 | Assert.AreEqual(0, state.IndentIndex); 20 | } 21 | 22 | /// 23 | /// Test what happens when the parser will fail. 24 | /// 25 | [Test] 26 | public static void MaybeNothingSuccess() 27 | { 28 | var state = new ParserState("b", 4); 29 | 30 | var result = Parse.Char('a').Maybe()(state); 31 | Assert.AreEqual(new Maybe(), result); 32 | 33 | Assert.AreEqual(0, state.Index); 34 | Assert.AreEqual(0, state.IndentIndex); 35 | } 36 | 37 | /// 38 | /// Test what happens when the input is empty. 39 | /// 40 | [Test] 41 | public static void MaybeEmptySuccess() 42 | { 43 | var state = new ParserState("", 4); 44 | 45 | var result = Parse.Char('a').Maybe()(state); 46 | Assert.AreEqual(new Maybe(), result); 47 | 48 | Assert.AreEqual(0, state.Index); 49 | Assert.AreEqual(0, state.IndentIndex); 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /Parser/Tests/Maybe.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 98404de085ed54b46844a9cc5d8442c8 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Parser/Tests/Or.cs: -------------------------------------------------------------------------------- 1 | using NUnit.Framework; 2 | 3 | namespace Exodrifter.Rumor.Parser.Tests 4 | { 5 | public static class Or 6 | { 7 | /// 8 | /// Test what happens when the left parser succeeds. 9 | /// 10 | [Test] 11 | public static void OrLeftSuccess() 12 | { 13 | var state = new ParserState("a", 4); 14 | 15 | var result = Parse.Char('a').Or(Parse.Char('z'))(state); 16 | Assert.AreEqual('a', result); 17 | 18 | Assert.AreEqual(1, state.Index); 19 | Assert.AreEqual(0, state.IndentIndex); 20 | } 21 | 22 | /// 23 | /// Test what happens when the right parser succeeds. 24 | /// 25 | [Test] 26 | public static void OrRightSuccess() 27 | { 28 | var state = new ParserState("z", 4); 29 | 30 | var result = Parse.Char('a').Or(Parse.Char('z'))(state); 31 | Assert.AreEqual('z', result); 32 | 33 | Assert.AreEqual(1, state.Index); 34 | Assert.AreEqual(0, state.IndentIndex); 35 | } 36 | 37 | /// 38 | /// Test what happens when the input is empty. 39 | /// 40 | [Test] 41 | public static void OrEmptyFailure() 42 | { 43 | var state = new ParserState("", 4); 44 | 45 | var exception = Assert.Throws(() => 46 | Parse.Char('a').Or(Parse.Char('z'))(state) 47 | ); 48 | Assert.AreEqual(0, exception.Index); 49 | Assert.AreEqual( 50 | "parse exception at index 0: expected one of the following " + 51 | "exceptions to not happen: parse exception at index 0: " + 52 | "expected 'a'; parse exception at index 0: expected 'z'", 53 | exception.Message 54 | ); 55 | 56 | Assert.AreEqual(0, state.Index); 57 | Assert.AreEqual(0, state.IndentIndex); 58 | } 59 | 60 | /// 61 | /// Test what happens when neither parser will succeed. 62 | /// 63 | [Test] 64 | public static void OrFailure() 65 | { 66 | var state = new ParserState("m", 4); 67 | 68 | var exception = Assert.Throws(() => 69 | Parse.Char('a').Or(Parse.Char('z'))(state) 70 | ); 71 | Assert.AreEqual(0, exception.Index); 72 | Assert.AreEqual( 73 | "parse exception at index 0: expected one of the following " + 74 | "exceptions to not happen: parse exception at index 0: " + 75 | "expected 'a'; parse exception at index 0: expected 'z'", 76 | exception.Message 77 | ); 78 | 79 | Assert.AreEqual(0, state.Index); 80 | Assert.AreEqual(0, state.IndentIndex); 81 | } 82 | } 83 | } -------------------------------------------------------------------------------- /Parser/Tests/Or.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 76ec2109d326e4f4e9295765ad85fdd6 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Parser/Tests/Simple.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7427ec264ab3c4c47946aeffa3f87fa0 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Parser/Tests/Surround.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a9f99bec7c1e47245987eaec5df3813f 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Parser/Tests/SurroundBlock.cs: -------------------------------------------------------------------------------- 1 | using NUnit.Framework; 2 | 3 | namespace Exodrifter.Rumor.Parser.Tests 4 | { 5 | public static class SurroundBlock 6 | { 7 | /// 8 | /// Test what happens in the expected use case for this parser. 9 | /// 10 | [Test] 11 | public static void SurroundBlockSuccess() 12 | { 13 | var state = new ParserState("(\n a \n)", 4); 14 | 15 | var result = Parse.SurroundBlock('(', ')', 16 | Parse.Char('a'), Parse.SameOrIndented 17 | )(state); 18 | Assert.AreEqual('a', result); 19 | 20 | Assert.AreEqual(7, state.Index); 21 | Assert.AreEqual(0, state.IndentIndex); 22 | } 23 | 24 | /// 25 | /// Test what happens when the content is not indented properly 26 | /// 27 | [Test] 28 | public static void SurroundBlockFailure() 29 | { 30 | var state = new ParserState("(\na \n)", 4); 31 | 32 | var exception = Assert.Throws(() => 33 | Parse.SurroundBlock('(', ')', 34 | Parse.Char('a'), Parse.Indented 35 | )(state) 36 | ); 37 | Assert.AreEqual(2, exception.Index); 38 | Assert.AreEqual( 39 | "parse exception at index 2: line indented to column 1 or more", 40 | exception.Message 41 | ); 42 | 43 | Assert.AreEqual(0, state.Index); 44 | Assert.AreEqual(0, state.IndentIndex); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Parser/Tests/SurroundBlock.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b8c03117608d02345b18a9cc513e166e 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Parser/Tests/Then.cs: -------------------------------------------------------------------------------- 1 | using NUnit.Framework; 2 | 3 | namespace Exodrifter.Rumor.Parser.Tests 4 | { 5 | public static class Then 6 | { 7 | /// 8 | /// Test the expected use case for this parser. 9 | /// 10 | [Test] 11 | public static void ThenSuccess() 12 | { 13 | var state = new ParserState("ab", 4); 14 | 15 | var result = Parse.Char('a').Then(Parse.Char('b'))(state); 16 | Assert.AreEqual('b', result); 17 | 18 | Assert.AreEqual(2, state.Index); 19 | Assert.AreEqual(0, state.IndentIndex); 20 | } 21 | 22 | /// 23 | /// Test what happens when the first parser fails. 24 | /// 25 | [Test] 26 | public static void ThenLeftFailure() 27 | { 28 | var state = new ParserState("ab", 4); 29 | 30 | var exception = Assert.Throws(() => 31 | Parse.Char('z').Then(Parse.Char('b'))(state) 32 | ); 33 | Assert.AreEqual(0, exception.Index); 34 | Assert.AreEqual(new string[] { "'z'" }, exception.Expected); 35 | 36 | Assert.AreEqual(0, state.Index); 37 | Assert.AreEqual(0, state.IndentIndex); 38 | } 39 | 40 | /// 41 | /// Test what happens when the second parser fails. 42 | /// 43 | [Test] 44 | public static void ThenRightFailure() 45 | { 46 | var state = new ParserState("ab", 4); 47 | 48 | var exception = Assert.Throws(() => 49 | Parse.Char('a').Then(Parse.Char('z'))(state) 50 | ); 51 | Assert.AreEqual(1, exception.Index); 52 | Assert.AreEqual(new string[] { "'z'" }, exception.Expected); 53 | 54 | Assert.AreEqual(0, state.Index); 55 | Assert.AreEqual(0, state.IndentIndex); 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /Parser/Tests/Then.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ef580f060f90768479c2a257f2acd1cb 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Parser/Tests/Until.cs: -------------------------------------------------------------------------------- 1 | using NUnit.Framework; 2 | 3 | namespace Exodrifter.Rumor.Parser.Tests 4 | { 5 | public static class Until 6 | { 7 | /// 8 | /// Test the expected use case for this parser. 9 | /// 10 | [Test] 11 | public static void UntilSuccess() 12 | { 13 | var state = new ParserState("aaab", 4); 14 | 15 | var result = Parse.Char('a').Until(Parse.Char('b'))(state); 16 | Assert.AreEqual(new char[] { 'a', 'a', 'a' }, result); 17 | 18 | Assert.AreEqual(3, state.Index); 19 | Assert.AreEqual(0, state.IndentIndex); 20 | } 21 | 22 | /// 23 | /// Test what happens when the input is empty. 24 | /// 25 | [Test] 26 | public static void UntilEmptyFailure() 27 | { 28 | var state = new ParserState("", 4); 29 | 30 | var exception = Assert.Throws(() => 31 | Parse.Char('a').Until(Parse.Char('b'))(state) 32 | ); 33 | Assert.AreEqual(0, exception.Index); 34 | Assert.AreEqual(new string[] { "'b'" }, exception.Expected); 35 | 36 | Assert.AreEqual(0, state.Index); 37 | Assert.AreEqual(0, state.IndentIndex); 38 | } 39 | 40 | /// 41 | /// Test what happens when the parser fails, but the end parser 42 | /// succeeds. 43 | /// 44 | [Test] 45 | public static void Until0Success() 46 | { 47 | var state = new ParserState("b", 4); 48 | 49 | var result = Parse.Char('a').Until(Parse.Char('b'))(state); 50 | Assert.AreEqual(new char[] { }, result); 51 | 52 | Assert.AreEqual(0, state.Index); 53 | Assert.AreEqual(0, state.IndentIndex); 54 | } 55 | 56 | /// 57 | /// Test what happens when the end parser will never succeed. 58 | /// 59 | [Test] 60 | public static void UntilFailure() 61 | { 62 | var state = new ParserState("aaaa", 4); 63 | 64 | var exception = Assert.Throws(() => 65 | Parse.Char('a').Until(Parse.Char('b'))(state) 66 | ); 67 | Assert.AreEqual(4, exception.Index); 68 | Assert.AreEqual(new string[] { "'b'" }, exception.Expected); 69 | 70 | Assert.AreEqual(0, state.Index); 71 | Assert.AreEqual(0, state.IndentIndex); 72 | } 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /Parser/Tests/Until.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d27662fa334ed96409bdeedcea24fa17 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Parser/Types.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dc355ac2ab72cc6469ef0812cacf2c4d 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Parser/Types/Maybe.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Exodrifter.Rumor.Parser 4 | { 5 | /// 6 | /// Represents something that may or may not exist. 7 | /// 8 | /// The type to wrap. 9 | public class Maybe 10 | { 11 | public bool HasValue { get; } 12 | private readonly T value; 13 | 14 | public T Value 15 | { 16 | get 17 | { 18 | if (HasValue) 19 | { 20 | return value; 21 | } 22 | else 23 | { 24 | throw new InvalidOperationException( 25 | "Maybe does not have a value." 26 | ); 27 | } 28 | } 29 | } 30 | 31 | public Maybe() 32 | { 33 | HasValue = false; 34 | value = default; 35 | } 36 | 37 | public Maybe(T value) 38 | { 39 | HasValue = true; 40 | this.value = value; 41 | } 42 | 43 | /// 44 | /// Returns the value in this Maybe or the default value. 45 | /// 46 | public T GetValueOrDefault() 47 | { 48 | if (HasValue) 49 | { 50 | return value; 51 | } 52 | else 53 | { 54 | return default; 55 | } 56 | } 57 | 58 | /// 59 | /// Returns the value in this Maybe or the default value. 60 | /// 61 | /// The default value to use. 62 | public T GetValueOrDefault(T other) 63 | { 64 | if (HasValue) 65 | { 66 | return value; 67 | } 68 | else 69 | { 70 | return other; 71 | } 72 | } 73 | 74 | public override bool Equals(object obj) 75 | { 76 | return Equals(obj as Maybe); 77 | } 78 | 79 | public bool Equals(Maybe other) 80 | { 81 | if (HasValue) 82 | { 83 | return HasValue == other.HasValue 84 | && Value.Equals(other.Value); 85 | } 86 | 87 | return HasValue == other.HasValue; 88 | } 89 | 90 | public override int GetHashCode() 91 | { 92 | if (HasValue) 93 | { 94 | return 0; 95 | } 96 | else 97 | { 98 | return Value.GetHashCode(); 99 | } 100 | } 101 | } 102 | } -------------------------------------------------------------------------------- /Parser/Types/Maybe.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6753acbbaca88ff4daff2e1264b3ba08 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Parser/Types/Parser.cs: -------------------------------------------------------------------------------- 1 | namespace Exodrifter.Rumor.Parser 2 | { 3 | /// 4 | /// A parser is a function that takes an input state and returns a value 5 | /// which has been determined by reading the contents of the input. It is 6 | /// required to roll back the state to the original value on failure and 7 | /// to update the state to a new position on success. 8 | /// 9 | /// The type the parser will return. 10 | /// The input state. 11 | public delegate T Parser(ParserState state); 12 | } 13 | -------------------------------------------------------------------------------- /Parser/Types/Parser.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b1b8c232d21faab4593e5e4b5937225e 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Parser/Types/ParserState.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace Exodrifter.Rumor.Parser 4 | { 5 | /// 6 | /// Contains the state of a parsing operation. 7 | /// 8 | public class ParserState 9 | { 10 | /// 11 | /// The contents of the source file that is being parsed. 12 | /// 13 | public string Source { get; } 14 | 15 | /// 16 | /// The number of spaces each tab in the source file should be treated 17 | /// as. 18 | /// 19 | public int TabSize { get; } 20 | 21 | /// 22 | /// The current index in the source file the parser is pointing at. 23 | /// 24 | public int Index { get; set; } 25 | 26 | /// 27 | /// The index in the source file to check the current indentation level 28 | /// against, if needed. 29 | /// 30 | public int IndentIndex { get; set; } 31 | 32 | /// 33 | /// Returns true if the state is pointing to the end of the file. 34 | /// 35 | public bool EOF { get { return Index >= Source.Length; } } 36 | 37 | /// 38 | /// An arbitrary user state containing additional data that can be 39 | /// referenced while parsing. 40 | /// 41 | public ParserUserState UserState { get; set; } 42 | 43 | /// 44 | /// Creates a new parser state. 45 | /// 46 | /// 47 | /// The contents of the source to parse. 48 | /// 49 | /// 50 | /// Some arbitrary user state that can accompany a parsing operation. 51 | /// 52 | public ParserState 53 | (string source, int tabSize, ParserUserState userState = null) 54 | { 55 | Source = source; 56 | TabSize = tabSize; 57 | Index = 0; 58 | IndentIndex = 0; 59 | 60 | UserState = userState; 61 | } 62 | 63 | /// 64 | /// Creates a copy of a parser state. 65 | /// 66 | /// The other state to make a copy of. 67 | public ParserState(ParserState other) 68 | { 69 | Source = other.Source; 70 | TabSize = other.TabSize; 71 | Index = other.Index; 72 | IndentIndex = other.IndentIndex; 73 | 74 | UserState = other.UserState?.Clone(); 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /Parser/Types/ParserState.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 04f507ba3870999459ed0efbd61a8d1f 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Parser/Types/ParserUserState.cs: -------------------------------------------------------------------------------- 1 | /// 2 | /// Represents some arbitrary user state that can optionally accompany a parsing 3 | /// operation. 4 | /// 5 | public interface ParserUserState 6 | { 7 | /// 8 | /// Returns a new deep copy of the current state. 9 | /// 10 | ParserUserState Clone(); 11 | } 12 | -------------------------------------------------------------------------------- /Parser/Types/ParserUserState.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 824e951b1f70f034e8883918a48376f8 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Parser/Types/Transaction.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Exodrifter.Rumor.Parser 4 | { 5 | /// 6 | /// A class that can be used to roll back a to a 7 | /// previous set of values after some actions are done, even if an 8 | /// exception is thrown. 9 | /// 10 | public class Transaction : IDisposable 11 | { 12 | private readonly ParserState state; 13 | 14 | private int index; 15 | private int indentIndex; 16 | 17 | private ParserUserState userState; 18 | 19 | public Transaction(ParserState state) 20 | { 21 | this.state = state; 22 | index = state.Index; 23 | indentIndex = state.IndentIndex; 24 | userState = state.UserState?.Clone(); 25 | } 26 | 27 | /// 28 | /// Rolls back the state in this transaction to the most-recently 29 | /// committed state. 30 | /// 31 | public void Rollback() 32 | { 33 | state.Index = index; 34 | state.IndentIndex = indentIndex; 35 | state.UserState = userState; 36 | } 37 | 38 | /// 39 | /// Updates the transaction to use the current index when rolling back. 40 | /// 41 | public void CommitIndex() 42 | { 43 | index = state.Index; 44 | userState = state.UserState; 45 | } 46 | 47 | public void Dispose() 48 | { 49 | Rollback(); 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /Parser/Types/Transaction.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: df05854a95eeadf4db2c6c10885db054 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Parser/Types/Unit.cs: -------------------------------------------------------------------------------- 1 | namespace Exodrifter.Rumor.Parser 2 | { 3 | /// 4 | /// This class represents the result of the parser when the parser has no 5 | /// value to return. 6 | /// 7 | public class Unit { } 8 | } 9 | -------------------------------------------------------------------------------- /Parser/Types/Unit.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9197067cc9e4f3e45a90590640789b0f 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 |

4 | 5 | Rumor 6 | ===== 7 | Rumor is a free, open source narrative content framework meant to be integrated 8 | into any Unity3D game that needs a dialog system. It is easy to diff, easy to 9 | read, and it is very flexible! 10 | 11 | You can download official releases at the [releases page](https://github.com/exodrifter/unity-rumor/releases). 12 | 13 | To learn more about Rumor, check the official [wiki](https://github.com/exodrifter/unity-rumor/wiki). 14 | 15 | Change Log 16 | ---------- 17 | Please see the file named [`CHANGELOG.md`](CHANGELOG.md). 18 | 19 | Licensing 20 | --------- 21 | Please see the file named [`LICENSE.md`](LICENSE.md). 22 | -------------------------------------------------------------------------------- /README.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 088cfc52f87d7fc46b2e7feae40a30d1 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Tests.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a58328cbbe85265469bde5264f053ce6 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Tests/Exodrifter.Rumor.Tests.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Exodrifter.Rumor.Tests", 3 | "rootNamespace": "", 4 | "references": [ 5 | "GUID:bbc44ed372f620f4183704e278f0c6a7", 6 | "GUID:3b1021c3659174e4d8475c19a9c62fd5", 7 | "GUID:99f7064735b3e3144b8444c435c2d6d4", 8 | "GUID:7c576a1537603c94b83790e10792e046" 9 | ], 10 | "includePlatforms": [ 11 | "Editor" 12 | ], 13 | "excludePlatforms": [], 14 | "allowUnsafeCode": false, 15 | "overrideReferences": true, 16 | "precompiledReferences": [], 17 | "autoReferenced": false, 18 | "defineConstraints": [ 19 | "UNITY_TEST_FRAMEWORK_EXISTS" 20 | ], 21 | "versionDefines": [ 22 | { 23 | "name": "com.unity.test-framework", 24 | "expression": "0", 25 | "define": "UNITY_TEST_FRAMEWORK_EXISTS" 26 | } 27 | ], 28 | "noEngineReferences": true 29 | } -------------------------------------------------------------------------------- /Tests/Exodrifter.Rumor.Tests.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ea1d2cafeaac6581a9fdf57954cc470d 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Tests/Smoke.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0ff297b44505ef59282ef8192e3e0ac2 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "space.exodrifter.unity-rumor", 3 | "version": "5.0.0", 4 | "description": "Rumor is a free, open source narrative content framework meant to be integrated into any Unity3D game that needs a dialog system. It is easy to diff, easy to read, and it is very flexible!", 5 | "displayName": "Rumor", 6 | "unity": "2020.3", 7 | "author": { 8 | "name": "exodrifter", 9 | "email": "code@exodrifter.space", 10 | "url": "https://www.exodrifter.space" 11 | }, 12 | "changelogUrl": "https://github.com/exodrifter/unity-rumor/blob/master/CHANGELOG.md", 13 | "documentationUrl": "https://github.com/exodrifter/unity-rumor/wiki", 14 | "license": "https://github.com/exodrifter/unity-rumor/blob/master/LICENSE.md" 15 | } -------------------------------------------------------------------------------- /package.json.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d96cf2f27813cba4e93579b171875f0d 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | --------------------------------------------------------------------------------