mirror of
https://github.com/LazyDuchess/OpenTS2.git
synced 2025-01-22 08:11:47 -05:00
Implement random number prim
This commit is contained in:
parent
4d3fe674f5
commit
5b206ce748
3 changed files with 39 additions and 0 deletions
|
@ -14,6 +14,7 @@ namespace OpenTS2.SimAntics.Primitives
|
|||
{
|
||||
RegisterPrimitive<VMSleep>(0x0);
|
||||
RegisterPrimitive<VMExpression>(0x2);
|
||||
RegisterPrimitive<VMRandomNumber>(0x8);
|
||||
RegisterPrimitive<VMRemoveObjectInstance>(0x12);
|
||||
RegisterPrimitive<VMNotifyStackObjectOutOfIdle>(0x31);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/OpenTS2/SimAntics/Primitives/VMRandomNumber.cs.meta
generated
Normal file
11
Assets/Scripts/OpenTS2/SimAntics/Primitives/VMRandomNumber.cs.meta
generated
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f67753d3b8a97c442b581b3a03d97f53
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Reference in a new issue