예제 #1
0
        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);
            }
        }
예제 #2
0
 public Weapon FindWeaponCode(string code)
 {
     return(Weapons.FirstOrDefault(w => w.Code == code));
 }
예제 #3
0
 public Brain FindBrainCode(string code)
 {
     return(Brains.FirstOrDefault(b => b.Code == code));
 }
예제 #4
0
 public Ecm FindECMCode(string code)
 {
     return(ECMs.FirstOrDefault(e => e.Code == code));
 }
예제 #5
0
 public Repair FindRepairCode(string code)
 {
     return(Repairs.FirstOrDefault(r => r.Code == code));
 }
예제 #6
0
 public Sensor FindSensorCode(string code)
 {
     return(Sensors.FirstOrDefault(s => s.Code == code));
 }
예제 #7
0
 public Construct FindConstructorCode(string code)
 {
     return(Constructors.FirstOrDefault(c => c.Code == code));
 }
예제 #8
0
 public Propulsion FindPropulsionCode(string code)
 {
     return(Propulsions.FirstOrDefault(p => p.Code == code));
 }
예제 #9
0
 public Body FindBodyCode(string code)
 {
     return(Bodies.FirstOrDefault(b => b.Code == code));
 }
예제 #10
0
 public StructureTypeBase FindFirstStructureType(StructureType type)
 {
     return(StructureTypes.FirstOrDefault(s => s.StructureType == type));
 }