コード例 #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));
 }