Exemplo n.º 1
0
    private SpawnItem RollForWeapon(Spawner MainSpawner, int HandID)
    {
        // Currently forces to spawn a weapon from the force orders in the main hand. Does not care whether the weapon makes sense on the character.
        if (HandID == 0 && MainSpawner.GetSpawnOrdersForce().Count > 0)
        {
            SpawnerOrder OrderForce = MainSpawner.GetSpawnOrdersForce()[0];

            SpawnItem ForcedItem = new SpawnItem
            {
                SpawnWeight = 1,
                SpawnWeapon = OrderForce.RollForWeapon()
            };

            MainSpawner.SpawnOrderForceFulfilled(OrderForce);

            return(ForcedItem);
        }

        SpawnItem[] AllowedWeaponList = Weapons(HandID);

        SpawnerOrder[] OrdersForbid = MainSpawner.GetSpawnOrderForbid();

        for (int i = 0; i < OrdersForbid.Length; i++)
        {
            AllowedWeaponList = OrdersForbid[i].RemoveWeaponsFromList(AllowedWeaponList);
        }

        int NumberOfWeapons = AllowedWeaponList.Length;
        int TotalWeight     = 0;

        for (int i = 0; i < AllowedWeaponList.Length; i++)
        {
            TotalWeight += AllowedWeaponList[i].SpawnWeight;
        }

        int RolledNumber  = Random.Range(0, TotalWeight);
        int WeightCounter = 0;

        for (int i = 0; i < AllowedWeaponList.Length; i++)
        {
            WeightCounter += AllowedWeaponList[i].SpawnWeight;

            if (RolledNumber < WeightCounter)
            {
                return(AllowedWeaponList[i]);
            }
        }

        return(new SpawnItem()); // Should not be reachable!
    }
Exemplo n.º 2
0
 public void SpawnOrderForceFulfilled(SpawnerOrder FulfilledOrder)
 {
     OrdersForce.Remove(FulfilledOrder);
 }