private static bool SaveJDeployable(int id, JDeployable d)
        {
            DeployableSaveData sd = new DeployableSaveData {
                t = d.ToString(),
                s = d.data
            };

            JInfoAttribute info = null;

            if (!DeployableTypes.TryGetValue(d.GetType(), out info))
            {
                return(false);
            }

            if (!DataManager.data.p.ContainsKey(info.PluginInfo.Title))
            {
                DataManager.data.p.Add(info.PluginInfo.Title, new Dictionary <int, DeployableSaveData>());
            }

            DataManager.data.p[info.PluginInfo.Title].Add(id, sd);

            return(true);
        }
        private static bool LoadJDeployable(int id, DeployableSaveData data)
        {
            Type deployabletype;

            if (!TryGetType(data.t, out deployabletype))
            {
                return(false);
            }

            // create instance of deployable
            var instance = Activator.CreateInstance(deployabletype);

            // apply save data to instance
            var savefield = deployabletype.GetField("data");

            if (savefield == null)
            {
                return(false);
            }

            savefield.SetValue(instance, data.s);

            // spawn instance
            var  methodInfo = deployabletype.GetMethod("Spawn");
            bool spawned    = false;

            if (methodInfo != null)
            {
                try {
                    spawned = (bool)methodInfo.Invoke(instance, new object[] { false });
                } catch (Exception e) {
                    spawned = false;
                    Interface.Oxide.LogWarning($"[JtechCore] Failed to Spawn JDeployable: {e.InnerException.Message}");
                }
            }
            if (!spawned)
            {
                // clean up if deployable
                deployabletype.GetMethod("Kill")?.Invoke(instance, new object[] { BaseNetworkable.DestroyMode.None, false });
                return(false);
            }

            // set Id
            var fieldInfo = deployabletype.GetField("Id");

            if (fieldInfo == null)
            {
                return(false);
            }
            fieldInfo.SetValue(instance, id);

            // set last update
            var lastupdatefield = deployabletype.GetField("_lastUpdate");

            if (lastupdatefield == null)
            {
                return(false);
            }
            lastupdatefield.SetValue(instance, DateTime.Now.Ticks);

            // add to spawnedDeployables
            SpawnedDeployablesAdd(id, (JDeployable)instance, deployabletype);

            return(true);
        }