public override void OnLoad() { try { // Load assets AssetBundle ab = LoadAssets.LoadBundle(this, "floodlight.unity3d"); GameObject origLight = ab.LoadAsset <GameObject>("floodlight.prefab"); _light = GameObject.Instantiate <GameObject>(origLight); _light.name = "floodlight(Clone)"; _light.layer = LayerMask.NameToLayer("Parts"); _light.tag = "PART"; FloodlightBehaviour comp = _light.AddComponent <FloodlightBehaviour>(); comp.UseBattery = UseBattery; comp.Flicker = EnableFlicker; comp.Unbreakable = Unbreakable; GameObject origBox = ab.LoadAsset <GameObject>("lightbulb_box.prefab"); _box = GameObject.Instantiate <GameObject>(origBox); GameObject.Destroy(origLight); GameObject.Destroy(origBox); ab.Unload(false); // Initialize objects InitShop(); // Load save FloodlightSaveData data = FloodlightSaveData.Deserialize <FloodlightSaveData>(FloodlightSaveData.SavePath); _light.GetComponent <FloodlightBehaviour>().Load(data); for (int i = 0; i < data.BulbPos.Count; ++i) { GameObject box = GameObject.Instantiate <GameObject>(_box); box.transform.position = data.BulbPos[i]; box.transform.rotation = data.BulbRot[i]; LightbulbBoxBehaviour c = box.AddComponent <LightbulbBoxBehaviour>(); c.ShopList = _list; c.Activate(); c.SetBought(); } // Set up command ConsoleCommand.Add(new FloodlightCommand(_light)); } catch (Exception ex) { ModConsole.Error(ex.ToString()); } }
public FloodlightCommand(GameObject light) { _comp = light.GetComponent <FloodlightBehaviour>(); }