public void AdjustTooltip(TooltipPrefab_Equipment tooltip, MechComponentDef componentDef) { foreach (var cc in componentDef.GetComponents <IAdjustTooltip>()) { cc.AdjustTooltip(tooltip, componentDef); } }
public static bool IsCategory(this MechComponentDef cdef, string category) { return(cdef.GetComponents <Category>().Any(c => c.CategoryID == category)); // Is<Category> // GetComponent<Category> }
public static bool IsCategory(this MechComponentDef cdef, string categoryid, out Category category) { category = cdef.GetComponents <Category>().FirstOrDefault(c => c.CategoryID == categoryid); return(category != null); // Is<Category> // GetComponent<Category> }
public void AdjustTooltipWeapon(TooltipPrefab_Weapon tooltip, MechComponentDef componentDef) { foreach (var cc in componentDef.GetComponents <IAdjustTooltipWeapon>()) { cc.AdjustTooltipWeapon(tooltip, componentDef); } }
internal static IEnumerable <ReplaceValidateDropDelegate> GetReplace(MechComponentDef component) { foreach (var item in component.GetComponents <IReplaceValidateDrop>()) { yield return(item.ReplaceValidateDrop); } foreach (var validator in rep_drop_validators) { yield return(validator); } }
internal static IEnumerable <PreValidateDropDelegate> GetPre(MechComponentDef component) { yield return(ValidateBase); foreach (var validator in component.GetComponents <IPreValidateDrop>()) { yield return(validator.PreValidateDrop); } foreach (var validator in pre_drop_validators) { yield return(validator); } }
internal static IEnumerable <PostValidateDropDelegate> GetPost(MechComponentDef component) { yield return(ValidateSize); yield return(ValidateJumpJets); foreach (var validator in component.GetComponents <IPostValidateDrop>()) { yield return(validator.PostValidateDrop); } foreach (var validator in chk_drop_validators) { yield return(validator); } }
public static Category GetCategory(this MechComponentDef item, string categoryid) { return(item.GetComponents <Category>()?.FirstOrDefault(i => i.CategoryID == categoryid)); }
private bool SetInvalid(MechComponentDef item) { var comps = item.GetComponents <IValid>(); return(comps == null || comps.All(i => i.Valid)); }
public static bool ApplyFilter(MechComponentDef item) { if (mechlab?.activeMechDef == null) { return(true); } if (item == null) { Control.LogError($"-- ITEM IS NULL!"); return(false); } //Control.LogDebug($"- {item.Description.Id}"); if (item.Is <Flags>(out var f) && f.HideFromInventory) { //Control.LogDebug($"-- default"); return(false); } bool black = !Control.Settings.ShowBlacklistedSkirmish && mechlab.sim == null || !Control.Settings.ShowBlacklistedSimGame && mechlab.sim != null; if (black && item.ComponentTags.Contains("BLACKLISTED")) { return(false); } if (!ApplyFilter(item, current_tab?.Filter)) { //Control.LogDebug($"-- tab filter miss"); return(false); } if (!ApplyFilter(item, current_button?.Filter)) { //Control.LogDebug($"-- button filter miss"); return(false); } foreach (var filter in item.GetComponents <IMechLabFilter>()) { try { if (!filter.CheckFilter(mechlab)) { return(false); } } catch (Exception e) { Control.LogError("Error in filter", e); } } if (item.ComponentType == ComponentType.JumpJet) { if (item is JumpJetDef jj) { if (mechlab.activeMechDef.Chassis.Tonnage < jj.MinTonnage) { return(false); } if (mechlab.activeMechDef.Chassis.Tonnage > jj.MaxTonnage) { return(false); } } } return(true); }