static public bool LocationHasCASE(BattleMechHitLocation hitLocation) { foreach (CriticalSlot slot in hitLocation.CriticalSlots) { if (slot.AffectedComponent != null) { ComponentCASE caseComponent = slot.AffectedComponent.Component as ComponentCASE; if (caseComponent != null) { return(true); } } } return(false); }
public static void ResolveComponent(Design design) { List <ComponentCASE> caseComponents = ComponentCASE.GetCanonicalCASE(); foreach (HitLocation location in design.HitLocations) { BattleMechHitLocation bmhl = location as BattleMechHitLocation; Dictionary <ComponentCASE, List <CriticalSlot> > dicComponents = new Dictionary <ComponentCASE, List <CriticalSlot> >(); foreach (ComponentCASE component in caseComponents) { dicComponents.Add(component, new List <CriticalSlot>()); } foreach (CriticalSlot criticalSlot in bmhl.CriticalSlots) { foreach (ComponentCASE sKey in dicComponents.Keys) { if (Utilities.IsSynonymFor(sKey, criticalSlot.Label)) { dicComponents[sKey].Add(criticalSlot); } } } foreach (ComponentCASE component in dicComponents.Keys) { if (dicComponents[component].Count == component.CriticalSpaceMech) { //Add component to design UnitComponent uc = new UnitComponent(component.Clone() as Component, location); foreach (CriticalSlot criticalSlot in dicComponents[component]) { criticalSlot.AffectedComponent = uc; } design.Components.Add(uc); } } } }
public override object Clone() { ComponentCASE retval = base.Clone() as ComponentCASE; return(retval); }