ripple-tool / Ripple-Data / LuaManager.cs
LuaManager.cs
Raw
using MoonSharp.Interpreter;
using Ripple_Data.Control;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Ripple_Data
{
    [MoonSharpUserData]
    public class LuaManager
    {
        public IIdentifyable Find(string objectType, string Name)
        {
            foreach (var objType in FindInstance(objectType).Objects)
            {
                if (objType.Name == Name)
                {
                    return objType;
                }
            }
            throw new ArgumentException("The object is not found.");
        }
        public IIdentifyable Find(string objectType, int ID)
        {
            foreach (var objType in FindInstance(objectType).Objects)
            {
                if (objType.ID == ID)
                {
                    return objType;
                }
            }
            throw new ArgumentException("The object is not found.");
        }

        public IIdentifyable FindInstance(string objectType)
        {
            foreach (var objType in RippleManager.All)
            {
                if (objType.GetType().Name == objectType)
                {
                    return objType;
                }
            }
            throw new ArgumentException("The object type is invalid.");

        }
    }
}