1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- using System;
- using System.Collections.Generic;
- using System.Reflection;
- namespace NTERA.Engine.Runtime.Base
- {
- public static class Variables
- {
- public class VariableAttribute : Attribute
- {
- public string Name { get; }
- public ValueType Type { get; }
- public VariableAttribute(string name, ValueType type)
- {
- Name = name;
- Type = type;
- }
- }
- public static Dictionary<VariableAttribute, Func<EraRuntime, int[], Value>> StaticVariables { get; } = _getFunctions();
- private static Dictionary<VariableAttribute, Func<EraRuntime, int[], Value>> _getFunctions()
- {
- var output = new Dictionary<VariableAttribute, Func<EraRuntime, int[], Value>>();
- foreach (MethodInfo method in typeof(Variables).GetMethods(BindingFlags.Public | BindingFlags.Static))
- {
- var variable = method.GetCustomAttribute<VariableAttribute>();
- if (variable != null)
- output[variable] = (Func<EraRuntime, int[], Value>)Delegate.CreateDelegate(typeof(Func<EraRuntime, int[], Value>), method);
- }
- return output;
- }
- [Variable("LINECOUNT", ValueType.Real)]
- public static Value LineCount(EraRuntime runtime, int[] index)
- {
- return runtime.Console.LineCount;
- }
- [Variable("GAMEBASE_AUTHOR", ValueType.String)]
- public static Value GameBaseAuthor(EraRuntime runtime, int[] index)
- {
- return runtime.ExecutionProvider.CSVDefinition.GameBaseInfo["作者"];
- }
- [Variable("GAMEBASE_INFO", ValueType.String)]
- public static Value GameBaseInfo(EraRuntime runtime, int[] index)
- {
- return runtime.ExecutionProvider.CSVDefinition.GameBaseInfo["追加情報"];
- }
- [Variable("GAMEBASE_YEAR", ValueType.String)]
- public static Value GameBaseYear(EraRuntime runtime, int[] index)
- {
- return runtime.ExecutionProvider.CSVDefinition.GameBaseInfo["製作年"];
- }
- [Variable("GAMEBASE_TITLE", ValueType.String)]
- public static Value GameBaseTitle(EraRuntime runtime, int[] index)
- {
- return runtime.ExecutionProvider.CSVDefinition.GameBaseInfo["タイトル"];
- }
- [Variable("GAMEBASE_GAMECODE", ValueType.Real)]
- public static Value GameBaseGameCode(EraRuntime runtime, int[] index)
- {
- return double.Parse(runtime.ExecutionProvider.CSVDefinition.GameBaseInfo["コード"]);
- }
- [Variable("GAMEBASE_VERSION", ValueType.Real)]
- public static Value GameBaseVersion(EraRuntime runtime, int[] index)
- {
- return double.Parse(runtime.ExecutionProvider.CSVDefinition.GameBaseInfo["バージョン"]);
- }
- [Variable("GAMEBASE_ALLOWVERSION", ValueType.Real)]
- public static Value GameBaseAllowVersion(EraRuntime runtime, int[] index)
- {
- return double.Parse(runtime.ExecutionProvider.CSVDefinition.GameBaseInfo["バージョン違い認める"]);
- }
- [Variable("GAMEBASE_DEFAULTCHARA", ValueType.Real)]
- public static Value GameBaseDefaultChara(EraRuntime runtime, int[] index)
- {
- return double.Parse(runtime.ExecutionProvider.CSVDefinition.GameBaseInfo["最初からいるキャラ"]);
- }
- [Variable("GAMEBASE_NOITEM", ValueType.Real)]
- public static Value GameBaseNoItem(EraRuntime runtime, int[] index)
- {
- return double.Parse(runtime.ExecutionProvider.CSVDefinition.GameBaseInfo["アイテムなし"]);
- }
- }
- }
|