Пример #1
0
 public CompositeIterator(CompanyComponent component)
 {
     inner = component;
     inner.NodeDisplay();
     _stack.Push(inner.CreateIterator());
     current = 0;
 }
Пример #2
0
        /// <summary>
        /// Sets the <see cref = "EmployeeComponent">Employee's</see> company,
        /// sets its worker home to the one closest to the company
        /// and spawns it at that worker home.
        /// </summary>
        /// <param name="company">The <see cref = "CompanyComponent">Company</see> hiring the <see cref = "EmployeeComponent">Employee</see>.</param>
        public void SetCompany(CompanyComponent company)
        {
            Company = company;
            this.Log($"Employee was hired for company {Company} at {Company.Location.EntryCell}");

            if (Locator.City)
            {
                var nearestHome = Locator.City.GetNearestHome(company.Location);

                Home = nearestHome;

                if (Home)
                {
                    this.Log($"Employee chose home {Home.name} at {Home.Location.EntryCell}");
                }
                else
                {
                    this.Log($"Employee could not find a valid home.", LogType.Warning);
                }
            }

            var startLocation = Home ? Home.Location : Company.Location;

            this.Log($"Employee is spawning at {startLocation}");
            Travel.TravelTo(startLocation);
        }
Пример #3
0
        public void SetCompany(CompanyComponent company)
        {
            this.Log($"Cart setting company to {company}");

            Company = company;

            Exchange.Owner = company.Owner;
            Travel.TravelTo(company.Location);
        }
Пример #4
0
        /// <summary>
        /// Registers a new <see cref = "CompanyComponent"/> to be owned by this <see cref = "WealthComponent"/>.
        /// </summary>
        /// <param name="company">The CompanyComponent to register.</param>
        public void RegisterCompany(CompanyComponent company)
        {
            if (!company)
            {
                return;
            }

            Companies.Add(company);

            company.EmployeeHired += OnEmployeeHired;
            company.CartHired     += OnCartHired;
            company.WagePaid      += OnWagePaid;

            foreach (var cart in company.Carts)
            {
                cart.Exchange.ItemBought += OnItemBought;
                cart.Exchange.ItemSold   += OnItemSold;
            }
        }
 public CompanyCompositeVisitor(CompanyComponent component)
 {
     component.Accept(this);
 }
Пример #6
0
 public override void Remove(CompanyComponent e)
 {
     _components.Remove(e);
 }
Пример #7
0
 public override void Add(CompanyComponent e)
 {
     _components.Add(e);
 }
Пример #8
0
 public EmployeeVisitor(CompanyComponent component)
 {
     component.Accept(this);
 }