48 lines
1.2 KiB
C#
48 lines
1.2 KiB
C#
using UnityEngine;
|
|
using System.Collections.Generic;
|
|
|
|
namespace Octopus.Simulator
|
|
{
|
|
public class LogicMappingDataBase : MonoBehaviour
|
|
{
|
|
static Dictionary<string, SimulationModel> mappingObjectDict = new Dictionary<string, SimulationModel>();
|
|
|
|
public static void SetMapping(string name, SimulationModel target)
|
|
{
|
|
if (mappingObjectDict.ContainsKey(name))
|
|
{
|
|
if (target)
|
|
{
|
|
mappingObjectDict[name] = target;
|
|
target.nodeID = name;
|
|
}
|
|
else
|
|
{
|
|
mappingObjectDict.Remove(name);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
mappingObjectDict.Add(name, target);
|
|
target.nodeID = name;
|
|
}
|
|
}
|
|
|
|
public static SimulationModel GetGameObject(string name)
|
|
{
|
|
if (mappingObjectDict.ContainsKey(name))
|
|
{
|
|
return mappingObjectDict[name];
|
|
}
|
|
else
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
|
|
public static void LoadDataBase(Dictionary<string, SimulationModel> db)
|
|
{
|
|
mappingObjectDict = db;
|
|
}
|
|
}
|
|
} |