using System;
using Svelto.ECS;
namespace GamecraftModdingAPI.Blocks
{
///
/// Common tweakable stats operations.
/// The functionality of this class works best in build mode.
///
public static class Tweakable
{
private static TweakableEngine tweakableEngine = new TweakableEngine();
///
/// Get the tweakable stat's value using a dynamic variable type.
/// This is similar to GetStat but without strong type enforcement.
/// This should be used in dynamically-typed languages like Python.
///
/// The stat's value.
/// The block's id.
/// The stat's enumerated id.
public static dynamic GetStatD(uint blockID, TweakableStat stat)
{
return tweakableEngine.GetStatDynamic(blockID, stat);
}
///
/// Get the tweakable stat's value.
/// If T is not the same type as the stat, an InvalidCastException will be thrown.
///
/// The stat's value.
/// The block's id.
/// The stat's enumerated id.
/// The stat's type.
public static T GetStat(uint blockID, TweakableStat stat)
{
return tweakableEngine.GetStatAny(blockID, stat);
}
///
/// Set the tweakable stat's value using dynamically-typed variables.
/// This is similar to SetStat but without strong type enforcement.
/// This should be used in dynamically-typed languages like Python.
///
/// The stat's new value.
/// The block's id.
/// The stat's enumerated id.
/// The stat's new value.
public static dynamic SetStatD(uint blockID, TweakableStat stat, dynamic value)
{
return tweakableEngine.SetStatDynamic(blockID, stat, value);
}
///
/// Set the tweakable stat's value.
/// If T is not the stat's actual type, an InvalidCastException will be thrown.
///
/// The stat's new value.
/// The block's id.
/// The stat's enumerated id.
/// The stat's new value.
/// The stat's type.
public static T SetStat(uint blockID, TweakableStat stat, T value)
{
return tweakableEngine.SetStatAny(blockID, stat, value);
}
///
/// Add another value to the tweakable stat's value using dynamically-typed variables.
/// This is similar to AddStat but without strong type enforcement.
/// This should be used in dynamically-typed languages like Python.
///
/// The stat's new value.
/// The block's id.
/// The stat's enumerated id.
/// The value to be added to the stat.
public static dynamic AddStatD(uint blockID, TweakableStat stat, dynamic value)
{
return tweakableEngine.AddStatDynamic(blockID, stat, value);
}
///
/// Add another value to the tweakable stat's value.
/// If T is not the stat's actual type, an InvalidCastException will be thrown.
///
/// The stat's new value.
/// The block's id.
/// The stat's enumerated id.
/// The value to be added to the stat.
/// The stat's type.
public static T AddStat(uint blockID, TweakableStat stat, T value)
{
return tweakableEngine.AddStatAny(blockID, stat, value);
}
public static void Init()
{
GamecraftModdingAPI.Utility.GameEngineManager.AddGameEngine(tweakableEngine);
}
}
}