EddiSpeechResponder.ScriptResolver.findShip C# (CSharp) Method

findShip() private static method

private static findShip ( int localId, string model ) : Ship
localId int
model string
return EddiDataDefinitions.Ship
        private static Ship findShip(int? localId, string model)
        {
            Ship ship = null;
            if (localId == null)
            {
                // No local ID so take the current ship
                ship = EDDI.Instance.Ship;
            }
            else
            {
                // Find the ship with the given local ID
                if (EDDI.Instance.Ship != null && EDDI.Instance.Ship.LocalId == localId)
                {
                    ship = EDDI.Instance.Ship;
                }
                else
                {
                    ship = EDDI.Instance.Shipyard.FirstOrDefault(v => v.LocalId == localId);
                }
            }

            if (ship == null)
            {
                // Provide a basic ship based on the model template
                ship = ShipDefinitions.FromModel(model);
                if (ship == null)
                {
                    ship = ShipDefinitions.FromEDModel(model);
                }
            }
            return ship;
        }
    }