diff --git a/Assets/Scripts/OpenTS2/SimAntics/Primitives/VMPrimitiveRegistry.cs b/Assets/Scripts/OpenTS2/SimAntics/Primitives/VMPrimitiveRegistry.cs index 30ebe4a..b434b77 100644 --- a/Assets/Scripts/OpenTS2/SimAntics/Primitives/VMPrimitiveRegistry.cs +++ b/Assets/Scripts/OpenTS2/SimAntics/Primitives/VMPrimitiveRegistry.cs @@ -14,6 +14,7 @@ namespace OpenTS2.SimAntics.Primitives { RegisterPrimitive(0x0); RegisterPrimitive(0x2); + RegisterPrimitive(0x8); RegisterPrimitive(0x12); RegisterPrimitive(0x31); } diff --git a/Assets/Scripts/OpenTS2/SimAntics/Primitives/VMRandomNumber.cs b/Assets/Scripts/OpenTS2/SimAntics/Primitives/VMRandomNumber.cs new file mode 100644 index 0000000..a9f5538 --- /dev/null +++ b/Assets/Scripts/OpenTS2/SimAntics/Primitives/VMRandomNumber.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace OpenTS2.SimAntics.Primitives +{ + public class VMRandomNumber : VMPrimitive + { + public override VMReturnValue Execute(VMContext ctx) + { + var lhsSource = (VMDataSource)ctx.Node.GetOperand(2); + var lhsData = ctx.Node.GetInt16Operand(0); + + var rhsSource = (VMDataSource)ctx.Node.GetOperand(6); + var rhsData = ctx.Node.GetInt16Operand(4); + + var randomMaxValue = ctx.GetData(rhsSource, rhsData); + var randomFinalValue = (short)UnityEngine.Random.Range(0, randomMaxValue); + + ctx.SetData(lhsSource, lhsData, randomFinalValue); + + return VMReturnValue.ReturnTrue; + } + } +} diff --git a/Assets/Scripts/OpenTS2/SimAntics/Primitives/VMRandomNumber.cs.meta b/Assets/Scripts/OpenTS2/SimAntics/Primitives/VMRandomNumber.cs.meta new file mode 100644 index 0000000..e4f9a3f --- /dev/null +++ b/Assets/Scripts/OpenTS2/SimAntics/Primitives/VMRandomNumber.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: f67753d3b8a97c442b581b3a03d97f53 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: