Example #1
0
        public CompanyComponent Create(MapComponent mapComponent)
        {
            Component.HiringCost        = TypeObject.HiringCost;
            Component.CartCost          = TypeObject.CartCost;
            Component.WagePerHour       = TypeObject.WagePerHour;
            Component.EmployeeTemplates = TypeObject.Employees;
            Component.CartTemplates     = TypeObject.Carts;

            var locationFactory   = new LocationFactory(TypeObject.Location.Value, GameObject);
            var locationComponent = locationFactory.Create();

            var buildingComponent = GameObject.GetComponent <BuildingComponent>();

            var companyEntryCell = mapComponent.MapLayout.PlaceBuilding(buildingComponent.Building);

            if (!companyEntryCell.HasValue)
            {
                this.Log($"Could not create company: No build space available.", LogType.Warning);
                Object.Destroy(GameObject);
                return(null);
            }

            locationComponent.EntityArrived += Component.OnEntityArrived;
            locationComponent.EntityLeft    += Component.OnEntityLeft;
            if (Locator.Time)
            {
                Locator.Time.WorkingHourTicked += Component.OnWorkingHourTicked;
            }

            mapComponent.Register(locationComponent);
            locationComponent.EntryCell = companyEntryCell.Value;

            if (TypeObject.Production.Value)
            {
                var productionFactory = new ProductionFactory(TypeObject.Production.Value, GameObject);
                productionFactory.Create();
            }

            Component.HireEmployee();
            Component.HireCart();

            if (TypeObject.Master.Value)
            {
                var masterFactory = new MasterFactory(TypeObject.Master.Value, GameObject);
                masterFactory.Create();
            }

            return(Component);
        }
Example #2
0
        public override MarketComponent Create()
        {
            Locator.Market = Component;

            var locationFactory = new LocationFactory(TypeObject.Location.Value, GameObject);

            locationFactory.Create();

            foreach (var exchange in TypeObject.Exchanges)
            {
                var exchangeFactory = new ExchangeFactory(exchange.Value, parentObject: GameObject);
                exchangeFactory.Create();
            }

            return(Component);
        }
        public WorkerHomeComponent Create(MapComponent mapComponent)
        {
            var locationFactory = new LocationFactory(TypeObject.Location.Value, GameObject);

            locationFactory.Create();

            var locationComponent = GameObject.GetComponent <LocationComponent>();
            var buildingComponent = GameObject.GetComponent <BuildingComponent>();

            var workerHomeEntryCell = mapComponent.MapLayout.PlaceBuilding(buildingComponent.Building);

            if (!workerHomeEntryCell.HasValue)
            {
                this.Log($"Could not create worker home: No build space available.", LogType.Warning);
                Object.Destroy(GameObject);
                return(null);
            }

            mapComponent.Register(locationComponent);
            locationComponent.EntryCell = workerHomeEntryCell.Value;

            return(Component);
        }