Ejemplo n.º 1
0
    public void NewHouseBuilt(House house)
    {
        houses.Add(house);

        if (house.GetType() == typeof(HomelessHouse))
        {
            return;
        }
        AddBelowPrefOccupants(house.GetHashVal(), house);
        GameManager.GetInstance().AddHousing(house.GetMaxOccupancy()); // TODO: This needs to be replaced when refactoring UI to look better

        // If there are any homeless, fill this house as full as possible,
        // because even overcrowded housing is better than being homeless
        if (homeless.Count > 0)
        {
            while (homeless.Count > 0 && house.GetMaxOccupancy() > house.GetOccupantCount())
            {
                Refugee _r = homeless.Dequeue();
                homelessHouse.RemoveOccupant(_r);
                house.AddOccupant(_r);
            }
        }

        // if there's still any preferred space, take some people out of overcrowded houses
        while (house.GetPrefOccupancy() > house.GetOccupantCount())
        {
            bool allHousingAtPreferredLevels = true;

            foreach (House h in houses)
            {
                // Take them out one by one so crowding levels lower uniformly across houses
                if (h.GetPrefOccupancy() < h.GetOccupantCount())
                {
                    house.AddOccupant(h.RemoveOccupant());
                    // See if we need to keep looping (so no infinite while loop)
                    if (h.GetPrefOccupancy() < h.GetOccupantCount())
                    {
                        allHousingAtPreferredLevels = false;
                    }
                }
            }
            // Stop looping because even though this house isn't full, there are no other refugees in overcrowded houses
            if (allHousingAtPreferredLevels)
            {
                return;
            }
        }
    }
Ejemplo n.º 2
0
 /// <summary>
 /// Makes character to enter a house
 /// </summary>
 /// <param name="character">Character who enters the house</param>
 /// <param name="house">House to which enter</param>
 /// <param name="teleport">Teleport used to enter the house</param>
 private void EnterHouse(Character character, House house, Teleport teleport)
 {
     SetTimerForCharacter(character);
     teleport.UseTeleport(character, house.templateId);
     character.owner.client.dimension = house.id;
     house.AddOccupant(character);
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Makes character to enter a house
 /// </summary>
 /// <param name="c">Character who enters the house</param>
 /// <param name="h">House to which enter</param>
 /// <param name="t">Teleport used to enter the house</param>
 private void EnterHouse(Character c, House h, Teleport t)
 {
     // Add dimension change!
     SetTimerForCharacter(c);
     t.UseTeleport(c, h.templateId);
     c.owner.client.dimension = h.id;
     h.AddOccupant(c);
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Adds character inside a house with a certain ID
        /// </summary>
        /// <param name="id">House id</param>
        /// <param name="character">Character</param>
        public void AddCharacterToHouseWithId(int id, Character character)
        {
            House house = GetHouseForId(id);

            house.AddOccupant(character);
        }