Exemplo n.º 1
0
        void SendDwarfsToHome()
        {
            for (int index = 0; index < pathComponents.Length; index++)
            {
                PathComponent pathComponent = pathComponents[index];
                DwellingSlotIndexComponent dwellingSlotIndexComponent = dwellingSlotIndexComponents[index];
                Transform          transformComponent = dwarfsTransformComponents[index];
                InventoryComponent inventoryComponent = inventoryComponents[index];

                if (dwellingSlotIndexComponent.dwarfsSlots == null)
                {
                    continue;
                }

                if (pathComponent.index != 0 && pathComponent.dwarfsSlots[pathComponent.index - 1] != null)
                {
                    pathComponent.dwarfsSlots[pathComponent.index - 1].dwarfsAlreadyIn--;
                    pathComponent.dwarfsSlots[pathComponent.index - 1].dwarfsInside
                    .Remove(inventoryComponent);
                }

                pathComponent.nodes       = aStarSystem.GetPath(transformComponent, dwellingSlotIndexComponent.dwarfsSlots.transform);
                pathComponent.index       = 0;
                pathComponent.dwarfsSlots = new DwarfsSlots[pathComponent.nodes.Length];
                pathComponent.dwarfsSlots[pathComponent.nodes.Length - 1] = dwellingSlotIndexComponent.dwarfsSlots;
            }
        }
Exemplo n.º 2
0
        public bool AttributeDwellingToDwarf(DwellingSlotIndexComponent dwellingSlotIndexComponent)
        {
            foreach (DwarfsSlots dwellingSlot in dwellingsSlots)
            {
                if (dwellingSlot.attributedDwarfsNumber >= dwellingSlot.maxNumberSlots)
                {
                    continue;
                }

                dwellingSlot.attributedDwarfsNumber++;
                dwellingSlotIndexComponent.dwarfsSlots = dwellingSlot;

                for (int j = 0; j < dwellingSlot.maxNumberSlots; j++)
                {
                    if (dwellingSlot.attributedDwellingsSlotIndexComponent[j] != null)
                    {
                        continue;
                    }

                    dwellingSlot.attributedDwellingsSlotIndexComponent[j] = dwellingSlotIndexComponent;
                    break;
                }

                return(true);
            }

            return(false);
        }
Exemplo n.º 3
0
        private void IncreaseDwellingSlotIndexComponentsSizeAndAttribute(DwellingSlotIndexComponent dwellingSlotIndexComponent)
        {
            DwellingSlotIndexComponent[] tmpDwellingSlotIndexComponents = new DwellingSlotIndexComponent[dwellingSlotIndexComponents.Length + 1];

            for (int i = 0; i < dwellingSlotIndexComponents.Length; i++)
            {
                tmpDwellingSlotIndexComponents[i] = dwellingSlotIndexComponents[i];
            }

            tmpDwellingSlotIndexComponents[tmpDwellingSlotIndexComponents.Length - 1] = dwellingSlotIndexComponent;

            dwellingSlotIndexComponents = tmpDwellingSlotIndexComponents;;
        }
Exemplo n.º 4
0
        public bool newDwarf(DwellingSlotIndexComponent dwellingSlotIndexComponent)
        {
            IncreaseDwellingSlotIndexComponentsSizeAndAttribute(dwellingSlotIndexComponent);

            return(AttributeDwellingToDwarf(dwellingSlotIndexComponent));
        }