public UnitTypeBase FindOrCreateUnitType(string code, UnitType type, int wallType) { switch (type) { case UnitType.Feature: return(FeatureTypes.FirstOrDefault(ft => ft.Code == code) ?? new FeatureTypeBase { IsUnknown = true, Code = code, Footprint = { X = 1, Y = 1 } }); case UnitType.PlayerStructure: foreach (var structure in StructureTypes.Where(s => s.Code == code)) { if (wallType < 0) { return(structure); } if (structure.WallLink.IsConnected) { if (structure.WallLink.ArrayPosition == wallType) { return(structure); } } } return(new StructureTypeBase { IsUnknown = true, Code = code, Footprint = { X = 1, Y = 1 } }); case UnitType.PlayerDroid: return(DroidTemplates .Where(dt => dt.IsTemplate) .FirstOrDefault(dt => dt.Code == code) ?? new DroidTemplate { IsUnknown = true, Code = code }); default: return(null); } }
public Weapon FindWeaponCode(string code) { return(Weapons.FirstOrDefault(w => w.Code == code)); }
public Brain FindBrainCode(string code) { return(Brains.FirstOrDefault(b => b.Code == code)); }
public Ecm FindECMCode(string code) { return(ECMs.FirstOrDefault(e => e.Code == code)); }
public Repair FindRepairCode(string code) { return(Repairs.FirstOrDefault(r => r.Code == code)); }
public Sensor FindSensorCode(string code) { return(Sensors.FirstOrDefault(s => s.Code == code)); }
public Construct FindConstructorCode(string code) { return(Constructors.FirstOrDefault(c => c.Code == code)); }
public Propulsion FindPropulsionCode(string code) { return(Propulsions.FirstOrDefault(p => p.Code == code)); }
public Body FindBodyCode(string code) { return(Bodies.FirstOrDefault(b => b.Code == code)); }
public StructureTypeBase FindFirstStructureType(StructureType type) { return(StructureTypes.FirstOrDefault(s => s.StructureType == type)); }