示例#1
0
    public OrbitalEntityPack GenerateTurretLoadout()
    {
        var hull   = ItemManager.CreateInstance(RandomHull(HullType.Turret)) as EquippableItem;
        var entity = new OrbitalEntity(ItemManager, null, hull, Guid.Empty, ItemManager.GameplaySettings.DefaultEntitySettings);

        entity.Faction = Faction;
        OutfitEntity(entity);
        return(EntitySerializer.Pack(entity) as OrbitalEntityPack);
    }
示例#2
0
    public EntityPack GenerateShipLoadout(Predicate <HullData> hullFilter = null)
    {
        var hullData = RandomHull(HullType.Ship, hullFilter);
        var hull     = ItemManager.CreateInstance(hullData) as EquippableItem;

        if (hull == null)
        {
            ItemManager.Log("WHAT???");
        }
        var entity = new Ship(ItemManager, null, hull, ItemManager.GameplaySettings.DefaultEntitySettings);

        entity.Faction = Faction;
        OutfitEntity(entity);
        return(EntitySerializer.Pack(entity));
    }
示例#3
0
    public OrbitalEntityPack GenerateStationLoadout()
    {
        var hullData = RandomHull(HullType.Station);
        var hull     = ItemManager.CreateInstance(hullData) as EquippableItem;
        var entity   = new OrbitalEntity(ItemManager, null, hull, Guid.Empty, ItemManager.GameplaySettings.DefaultEntitySettings);

        entity.Faction = Faction;
        OutfitEntity(entity);

        var emptyShape = entity.UnoccupiedSpace;

        var dockingBayData = RandomItem <DockingBayData>(2, item => item.Shape.FitsWithin(emptyShape, out _, out _));

        if (dockingBayData == null)
        {
            throw new InvalidLoadoutException("No compatible docking bay found for station!");
        }

        dockingBayData.Shape.FitsWithin(emptyShape, out var cargoRotation, out var cargoPosition);
        var dockingBay = ItemManager.CreateInstance(dockingBayData) as EquippableItem;

        dockingBay.Rotation = cargoRotation;
        if (!entity.TryEquip(dockingBay, cargoPosition))
        {
            throw new InvalidLoadoutException("Failed to equip selected docking bay!");
        }

        var cargo = entity.CargoBays.First();
        IEnumerable <EquippableItemData> inventory = RandomItems <EquippableItemData>(16, 1,
                                                                                      data => !(data is HullData hull && hull.HullType != HullType.Ship) && !(data is CargoBayData));

        inventory = inventory
                    .OrderByDescending(item => item.Shape.Coordinates.Length);
        foreach (var item in inventory)
        {
            var instance = ItemManager.CreateInstance(item);
            cargo.TryStore(instance);
        }

        return(EntitySerializer.Pack(entity) as OrbitalEntityPack);
    }