예제 #1
0
        List <StandardisedItemPort> BuildPortList(EntityClassDefinition entity)
        {
            var ports = new List <StandardisedItemPort>();

            if (entity.Components.SItemPortContainerComponentParams == null)
            {
                return(ports);
            }

            foreach (var port in entity.Components.SItemPortContainerComponentParams.Ports)
            {
                var stdPort = new StandardisedItemPort
                {
                    PortName = port.Name,
                    Size     = port.MaxSize,
                    Types    = BuildPortTypes(port),
                    Flags    = BuildPortFlags(port)
                };

                stdPort.Uneditable = stdPort.Flags.Contains("$uneditable") || stdPort.Flags.Contains("uneditable");

                ports.Add(stdPort);
            }

            return(ports);
        }
예제 #2
0
        public void InstallLoadout(StandardisedItemPort port, List <StandardisedLoadoutEntry> loadout)
        {
            var loadoutEntry = FindLoadoutEntry(port.PortName, loadout);

            if (String.IsNullOrEmpty(loadoutEntry?.ClassName))
            {
                return;
            }

            port.Loadout = loadoutEntry.ClassName;

            var item = entitySvc.GetByClassName(loadoutEntry.ClassName);

            if (item == null)
            {
                return;
            }

            var standardisedItem = itemBuilder.BuildItem(item);

            port.InstalledItem = standardisedItem;

            // Update the loadout with anything this item brings with it
            var newLoadout = loadoutLoader.Load(item);

            loadoutEntry.Entries.AddRange(newLoadout);

            InstallLoadout(standardisedItem.Ports, loadoutEntry.Entries);
        }
예제 #3
0
        public (string, string) ClassifyPort(StandardisedItemPort port)
        {
            /*
             *      The order here is very important to try and catch obscure corner cases
             */

            if (port.Types == null && port.InstalledItem == null)
            {
                return("DISABLED", "DISABLED");
            }

            // Tractor beams
            if (FuzzyNameMatch(port, "tractor"))
            {
                return("Utility", "Utility hardpoints");
            }

            // Utility hardpoints
            if (FuzzyNameMatch(port, "utility"))
            {
                return("Utility", "Utility hardpoints");
            }

            if (port.Uneditable && port.InstalledItem != null)
            {
                var guess = GuessByInstalledItem(port);
                if (guess != null)
                {
                    return(guess.Value);
                }
            }

            // Mining
            if (port.Accepts("WeaponMining.Gun"))
            {
                return("Mining", "Mining hardpoints");
            }
            if (port.Accepts("MiningArm"))
            {
                return("Mining", "Mining arm");
            }

            if (port.Accepts("Turret.*"))
            {
                return("Weapons", FuzzyNameMatch(port, "remote") ? "Remote turrets" : "Weapon hardpoints");
            }

            if (port.Accepts("TurretBase.MannedTurret"))
            {
                if (port.InstalledItem?.Ports?.Any(x => x.InstalledItem?.Type == "WeaponMining.Gun") ?? false)
                {
                    return("Mining", "Mining turrets");                                                                                                             // Argo Mole
                }
                if (FuzzyNameMatch(port, "tractor"))
                {
                    return("Utility", "Utility turrets");
                }
                else
                {
                    return("Weapons", "Manned turrets");
                }
            }

            // Weapons
            if (port.Accepts("MissileLauncher.MissileRack"))
            {
                return("Weapons", "Missile racks");
            }
            if (port.Accepts("WeaponGun"))
            {
                return("Weapons", "Weapon hardpoints");
            }
            if (port.Accepts("Missile.Missile"))
            {
                return("Weapons", "Missiles");
            }
            if (port.Accepts("EMP"))
            {
                return("Weapons", "EMP hardpoints");
            }
            if (port.Accepts("WeaponDefensive.CountermeasureLauncher"))
            {
                return("Weapons", "Countermeasures");
            }
            if (port.Accepts("QuantumInterdictionGenerator"))
            {
                return("Weapons", "QIG hardpoints");
            }

            // Systems
            if (port.Accepts("PowerPlant"))
            {
                return("Systems", "Power plants");
            }
            if (port.Accepts("Cooler"))
            {
                return("Systems", "Coolers");
            }
            if (port.Accepts("Shield"))
            {
                return("Systems", "Shield generators");
            }

            // Propulsion
            if (port.Accepts("FuelIntake"))
            {
                return("Propulsion", "Fuel intakes");
            }
            if (port.Accepts("FuelTank"))
            {
                return("Propulsion", "Fuel tanks");
            }
            if (port.Accepts("QuantumFuelTank.QuantumFuel"))
            {
                return("Propulsion", "Quantum fuel tanks");
            }
            if (port.Accepts("QuantumDrive.QDrive"))
            {
                return("Propulsion", "Quantum drives");
            }

            // Main Thrusters
            if (port.Accepts("MainThruster.*"))
            {
                if (FuzzyNameMatch(port, "retro"))
                {
                    return("Thrusters", "Retro thrusters");
                }
                else if (FuzzyNameMatch(port, "vtol"))
                {
                    return("Thrusters", "VTOL thrusters");
                }
                else
                {
                    return("Thrusters", "Main thrusters");
                }
            }

            // Maneuvering Thrusters
            if (port.Accepts("ManneuverThruster.*"))
            {
                if (FuzzyNameMatch(port, "retro"))
                {
                    return("Thrusters", "Retro thrusters");
                }
                else if (FuzzyNameMatch(port, "vtol"))
                {
                    return("Thrusters", "VTOL thrusters");
                }
                else
                {
                    return("Thrusters", "Maneuvering thrusters");
                }
            }

            // Avionics
            if (port.Accepts("Avionics.Motherboard"))
            {
                return("Avionics", "Computers");
            }
            if (port.Accepts("Radar"))
            {
                return("Avionics", "Radars");
            }
            if (port.Accepts("Radar.ShortRangeRadar"))
            {
                return("Avionics", "Radars");
            }
            if (port.Accepts("Radar.MidRangeRadar"))
            {
                return("Avionics", "Radars");
            }
            if (port.Accepts("Scanner"))
            {
                return("Avionics", "Scanners");
            }
            if (port.Accepts("Scanner.Gun"))
            {
                return("Avionics", "Scanners");
            }
            if (port.Accepts("Ping"))
            {
                return("Avionics", "Pings");
            }
            if (port.Accepts("Transponder"))
            {
                return("Avionics", "Transponders");
            }
            if (port.Accepts("SelfDestruct"))
            {
                return("Avionics", "Self destruct");
            }

            // Cargo
            if (port.Accepts("Cargo"))
            {
                return("Cargo", "Cargo grids");
            }
            if (port.Accepts("Container.Cargo"))
            {
                return("Cargo", "Cargo containers");
            }

            // Armor
            if (port.Accepts("Armor"))
            {
                return("Armor", "Armor");
            }

            // Misc
            if (port.Accepts("Usable"))
            {
                return("Misc", "Usables");
            }
            if (port.Accepts("Room"))
            {
                return("Misc", "Rooms");
            }
            if (port.Accepts("Door"))
            {
                return("Misc", "Doors");
            }
            if (port.Accepts("Paints"))
            {
                return("Misc", "Paints");
            }

            // Attachments to larger objects
            if (FuzzyNameMatch(port, "BatteryPort"))
            {
                return("Attachments", "Batteries");
            }
            if (port.Accepts("WeaponAttachment.Barrel"))
            {
                return("Attachments", "Weapon attachments");
            }
            if (port.Accepts("WeaponAttachment.FiringMechanism"))
            {
                return("Attachments", "Weapon attachments");
            }
            if (port.Accepts("WeaponAttachment.PowerArray"))
            {
                return("Attachments", "Weapon attachments");
            }
            if (port.Accepts("WeaponAttachment.Ventilation"))
            {
                return("Attachments", "Weapon attachments");
            }
            if (port.Accepts("ControlPanel.DoorPart"))
            {
                return("Attachments", "Door attachments");
            }
            if (port.Accepts("Misc.DoorPart"))
            {
                return("Attachments", "Door attachments");
            }
            if (port.Accepts("Button.DoorPart"))
            {
                return("Attachments", "Door attachments");
            }
            if (port.Accepts("Sensor.DoorPart"))
            {
                return("Attachments", "Door attachments");
            }
            if (port.Accepts("Lightgroup.DoorPart"))
            {
                return("Attachments", "Door attachments");
            }
            if (port.Accepts("Decal.DoorPart"))
            {
                return("Attachments", "Door attachments");
            }

            // Seating
            if (port.Accepts("Seat"))
            {
                return("Seating", "Seats");
            }
            if (port.Accepts("SeatAccess"))
            {
                return("Seating", "Seat access");
            }

            return("UNKNOWN", "UNKNOWN");
        }