public override void Execute(EventExecutionContext context, CommandExecutionHandle handle) { if (target.Evaluate(context, out object result)) { string message = ""; switch (target.StoreType) { case VariableReferenceType.Constant: message = "定数"; break; case VariableReferenceType.Temporary: message = "一時変数"; break; case VariableReferenceType.Event: message = "イベント変数"; break; default: throw new ArgumentOutOfRangeException(); } message += ": " + result; Debug.Log(message); } handle.Complete(); }
public ScriptExecutionSession(EventScript script, EventExecutionContext context, Action onFinished, EventRuntimeReferenceHost resolver, IVariableStore temporaryVariables, IVariableStore eventVariables) { Commands = new List <EventCommand>(script.CommandList.Commands); WaitForAllCommands = script.WaitForAllCommands; OnFinished = onFinished; CurrentContext = context; ReferenceResolver = resolver; TemporaryVariables = temporaryVariables; EventVariables = eventVariables; }
public override void Execute(EventExecutionContext context, CommandExecutionHandle handle) { if (duration.Evaluate(context, out float durationValue)) { currentHandle = handle; Timer.AddTimer(durationValue, Tick, updateMode); } else { handle.Complete(); } }
public override void Execute(EventExecutionContext context, CommandExecutionHandle handle) { if (inheritVariables) { var script = scriptAsset.Script; script.WaitForAllCommands = true; context.InsertInherit(script, handle.Complete); } else { context.Insert(scriptAsset, handle.Complete, null); } }
private void UpdateLoop(EventExecutionContext context, CommandExecutionHandle handle) { if (condition.Evaluate(context)) { var script = new EventScript(); script.CommandList = routine; script.WaitForAllCommands = waitForAllCommand; context.InsertInherit(script, () => UpdateLoop(context, handle)); } else { handle.Complete(); } }
public override void Execute(EventExecutionContext context, CommandExecutionHandle handle) { if (condition.Evaluate(context, onFailed)) { var script = new EventScript(); script.CommandList = ifTrue; script.WaitForAllCommands = waitForAllCommand; context.InsertInherit(script, handle.Complete); } else { var script = new EventScript(); script.CommandList = ifFalse; script.WaitForAllCommands = waitForAllCommand; context.InsertInherit(script, handle.Complete); } }
private void UpdateLoop(EventExecutionContext context, CommandExecutionHandle handle) { counter++; if (count.Evaluate(context, out object result)) { if (result is IComparable resultComparable && counter.CompareTo(resultComparable) < 0) { var script = new EventScript(); script.CommandList = routine; script.WaitForAllCommands = waitForAllCommand; context.InsertInherit(script, () => UpdateLoop(context, handle)); return; } } handle.Complete(); }
public override void Execute(EventExecutionContext context, CommandExecutionHandle handle) { if (target == null || value == null) { Debug.LogWarning("VariableReferenceが未設定です。"); handle.Complete(); return; } if (target.ValueType != value.ValueType) { Debug.LogWarning("VariableReferenceの型が一致しません。"); handle.Complete(); return; } if (value.Evaluate(context, out var evaluated)) { target.SetValue(context, evaluated); } handle.Complete(); }
/// <summary> /// イベントスクリプトの再生が開始する直前に呼ばれる。 /// </summary> /// <param name="context"></param> public virtual void OnPlay(EventExecutionContext context) { }
public override void Execute(EventExecutionContext context, CommandExecutionHandle handle) { UpdateLoop(context, handle); }
public void Execute(EventExecutionContext context) { //右辺の計算に使用する型を選ぶ //できるだけ低次(高精度、高速?)の型で処理できた方がよい? if (right0 is IVariableReferenceNumericalOut <sbyte> r0sbyte && right1 is IVariableReferenceNumericalOut <sbyte> r1sbyte && left is IVariableReferenceNumericalIn <int> lsbyte) { var r0v = r0sbyte.EvaluateNumerical(context); var r1v = r1sbyte.EvaluateNumerical(context); switch (calculationOperator) { case CalculationOperatorType.Add: lsbyte.SetValue(context, r0v + r1v); break; case CalculationOperatorType.Subtract: lsbyte.SetValue(context, r0v - r1v); break; case CalculationOperatorType.Multiply: lsbyte.SetValue(context, r0v * r1v); break; case CalculationOperatorType.Divide: lsbyte.SetValue(context, r0v / r1v); break; default: throw new ArgumentOutOfRangeException(); } } else if (right0 is IVariableReferenceNumericalOut <byte> r0byte && right1 is IVariableReferenceNumericalOut <byte> r1byte && left is IVariableReferenceNumericalIn <int> lbyte) { var r0v = r0byte.EvaluateNumerical(context); var r1v = r1byte.EvaluateNumerical(context); switch (calculationOperator) { case CalculationOperatorType.Add: lbyte.SetValue(context, r0v + r1v); break; case CalculationOperatorType.Subtract: lbyte.SetValue(context, r0v - r1v); break; case CalculationOperatorType.Multiply: lbyte.SetValue(context, r0v * r1v); break; case CalculationOperatorType.Divide: lbyte.SetValue(context, r0v / r1v); break; default: throw new ArgumentOutOfRangeException(); } } else if (right0 is IVariableReferenceNumericalOut <short> r0short && right1 is IVariableReferenceNumericalOut <short> r1short && left is IVariableReferenceNumericalIn <int> lshort) { var r0v = r0short.EvaluateNumerical(context); var r1v = r1short.EvaluateNumerical(context); switch (calculationOperator) { case CalculationOperatorType.Add: lshort.SetValue(context, r0v + r1v); break; case CalculationOperatorType.Subtract: lshort.SetValue(context, r0v - r1v); break; case CalculationOperatorType.Multiply: lshort.SetValue(context, r0v * r1v); break; case CalculationOperatorType.Divide: lshort.SetValue(context, r0v / r1v); break; default: throw new ArgumentOutOfRangeException(); } } else if (right0 is IVariableReferenceNumericalOut <ushort> r0ushort && right1 is IVariableReferenceNumericalOut <ushort> r1ushort && left is IVariableReferenceNumericalIn <int> lushort) { var r0v = r0ushort.EvaluateNumerical(context); var r1v = r1ushort.EvaluateNumerical(context); switch (calculationOperator) { case CalculationOperatorType.Add: lushort.SetValue(context, r0v + r1v); break; case CalculationOperatorType.Subtract: lushort.SetValue(context, r0v - r1v); break; case CalculationOperatorType.Multiply: lushort.SetValue(context, r0v * r1v); break; case CalculationOperatorType.Divide: lushort.SetValue(context, r0v / r1v); break; default: throw new ArgumentOutOfRangeException(); } } else if (right0 is IVariableReferenceNumericalOut <int> r0int && right1 is IVariableReferenceNumericalOut <int> r1int && left is IVariableReferenceNumericalIn <int> lint) { var r0v = r0int.EvaluateNumerical(context); var r1v = r1int.EvaluateNumerical(context); switch (calculationOperator) { case CalculationOperatorType.Add: lint.SetValue(context, r0v + r1v); break; case CalculationOperatorType.Subtract: lint.SetValue(context, r0v - r1v); break; case CalculationOperatorType.Multiply: lint.SetValue(context, r0v * r1v); break; case CalculationOperatorType.Divide: lint.SetValue(context, r0v / r1v); break; default: throw new ArgumentOutOfRangeException(); } } else if (right0 is IVariableReferenceNumericalOut <uint> r0uint && right1 is IVariableReferenceNumericalOut <uint> r1uint && left is IVariableReferenceNumericalIn <uint> luint) { var r0v = r0uint.EvaluateNumerical(context); var r1v = r1uint.EvaluateNumerical(context); switch (calculationOperator) { case CalculationOperatorType.Add: luint.SetValue(context, r0v + r1v); break; case CalculationOperatorType.Subtract: luint.SetValue(context, r0v - r1v); break; case CalculationOperatorType.Multiply: luint.SetValue(context, r0v * r1v); break; case CalculationOperatorType.Divide: luint.SetValue(context, r0v / r1v); break; default: throw new ArgumentOutOfRangeException(); } } else if (right0 is IVariableReferenceNumericalOut <long> r0long && right1 is IVariableReferenceNumericalOut <long> r1long && left is IVariableReferenceNumericalIn <long> llong) { var r0v = r0long.EvaluateNumerical(context); var r1v = r1long.EvaluateNumerical(context); switch (calculationOperator) { case CalculationOperatorType.Add: llong.SetValue(context, r0v + r1v); break; case CalculationOperatorType.Subtract: llong.SetValue(context, r0v - r1v); break; case CalculationOperatorType.Multiply: llong.SetValue(context, r0v * r1v); break; case CalculationOperatorType.Divide: llong.SetValue(context, r0v / r1v); break; default: throw new ArgumentOutOfRangeException(); } } else if (right0 is IVariableReferenceNumericalOut <ulong> r0ulong && right1 is IVariableReferenceNumericalOut <ulong> r1ulong && left is IVariableReferenceNumericalIn <ulong> lulong) { var r0v = r0ulong.EvaluateNumerical(context); var r1v = r1ulong.EvaluateNumerical(context); switch (calculationOperator) { case CalculationOperatorType.Add: lulong.SetValue(context, r0v + r1v); break; case CalculationOperatorType.Subtract: lulong.SetValue(context, r0v - r1v); break; case CalculationOperatorType.Multiply: lulong.SetValue(context, r0v * r1v); break; case CalculationOperatorType.Divide: lulong.SetValue(context, r0v / r1v); break; default: throw new ArgumentOutOfRangeException(); } } else if (right0 is IVariableReferenceNumericalOut <float> r0float && right1 is IVariableReferenceNumericalOut <float> r1float && left is IVariableReferenceNumericalIn <float> lfloat) { var r0v = r0float.EvaluateNumerical(context); var r1v = r1float.EvaluateNumerical(context); switch (calculationOperator) { case CalculationOperatorType.Add: lfloat.SetValue(context, r0v + r1v); break; case CalculationOperatorType.Subtract: lfloat.SetValue(context, r0v - r1v); break; case CalculationOperatorType.Multiply: lfloat.SetValue(context, r0v * r1v); break; case CalculationOperatorType.Divide: lfloat.SetValue(context, r0v / r1v); break; default: throw new ArgumentOutOfRangeException(); } } else if (right0 is IVariableReferenceNumericalOut <double> r0double && right1 is IVariableReferenceNumericalOut <double> r1double && left is IVariableReferenceNumericalIn <double> ldouble) { var r0v = r0double.EvaluateNumerical(context); var r1v = r1double.EvaluateNumerical(context); switch (calculationOperator) { case CalculationOperatorType.Add: ldouble.SetValue(context, r0v + r1v); break; case CalculationOperatorType.Subtract: ldouble.SetValue(context, r0v - r1v); break; case CalculationOperatorType.Multiply: ldouble.SetValue(context, r0v * r1v); break; case CalculationOperatorType.Divide: ldouble.SetValue(context, r0v / r1v); break; default: throw new ArgumentOutOfRangeException(); } } else { throw new InvalidCastException("指定された変数の型に対する計算は実行できません。"); } }
public override void Execute(EventExecutionContext context, CommandExecutionHandle handle) { calculation.Execute(context); handle.Complete(); }
/// <summary> /// イベントスクリプトの再生が正常に終了したときに呼ばれる。 /// </summary> /// <param name="context"></param> public virtual void OnFinished(EventExecutionContext context) { }
/// <summary> /// イベントスクリプトの再生中にエラーが発生し中断されたときに呼ばれる。 /// </summary> /// <param name="context"></param> public virtual void OnError(EventExecutionContext context) { }
public override void Execute(EventExecutionContext context, CommandExecutionHandle handle) { ev.Invoke(context.ReferenceResolver); handle.Complete(); }
public override void Execute(EventExecutionContext context, CommandExecutionHandle handle) { currentHandle = handle; Timer.AddFrameTimer(frames, Tick); }
public override void Execute(EventExecutionContext context, CommandExecutionHandle handle) { Debug.Log(message); handle.Complete(); }
public override void Execute(EventExecutionContext context, CommandExecutionHandle handle) { handle.Complete(); }