private void CreateVehicleEquipmentMenu() { PluginMenu.Instance.AddMenu("VEHICLE_EQUIPMENT_SUBMENU"); PluginMenu.Instance.AddItem("OPEN_VEHICLE_EQUIPMENT_SUBMENU_ITEM", "MAIN_MENU", "Equipment", null, null, "VEHICLE_EQUIPMENT_SUBMENU"); foreach (KeyValuePair <Type, IFirefighterEquipment> p in RegisteredEquipments) { IFirefighterEquipment e = p.Value; PluginMenu.Instance.AddItem($"VEHICLE_EQUIPMENT_{e.DisplayName.ToUpper().Replace(" ", "_")}_ITEM", "VEHICLE_EQUIPMENT_SUBMENU", e.IsEquipped(this) ? $"Leave {e.DisplayName}" : $"Get {e.DisplayName}", () => { bool equipped = e.IsEquipped(this); if (equipped) { e.OnLeaveEquipment(this); } else { e.OnGetEquipment(this); } PluginMenu.Instance.UpdateItem($"VEHICLE_EQUIPMENT_{e.DisplayName.ToUpper().Replace(" ", "_")}_ITEM", !equipped ? $"Leave {e.DisplayName}" : $"Get {e.DisplayName}"); }); } }
public static void RegisterEquipments() { RegisteredEquipments.Clear(); RegisteredEquipmentsToUpdate.Clear(); IEnumerable <Type> types = Assembly.GetExecutingAssembly().GetTypes().Where(t => !t.IsAbstract && !t.IsInterface && typeof(IFirefighterEquipment).IsAssignableFrom(t)); foreach (Type type in types) { IFirefighterEquipment e = (IFirefighterEquipment)Activator.CreateInstance(type); if (e.ShouldUpdateIfEquipped) { RegisteredEquipmentsToUpdate.Add(e); } RegisteredEquipments.Add(type, e); } }