void Init() { LoadVariables(); permission.RegisterPermission(perms, this); data = Interface.Oxide.DataFileSystem.GetFile(Name); try { storedData = data.ReadObject <StoredData>(); PoweredTurrets = storedData.PoweredTurrets; PoweredSams = storedData.PoweredSams; } catch { storedData = new StoredData(); } plugin = this; }
void Unload() { foreach (var autoturret in UnityEngine.Object.FindObjectsOfType <AutoTurret>()) { if (autoturret.IsOnline()) // Turn turrets off on Unload { autoturret.SetIsOnline(false); autoturret.SendNetworkUpdateImmediate(); } } foreach (var sam in UnityEngine.Object.FindObjectsOfType <SamSite>()) { if (sam.IsPowered()) // Turn sams off on Unload { sam.UpdateHasPower(0, 1); sam.SendNetworkUpdateImmediate(); } } SaveData(); plugin = null; }