Esempio n. 1
0
        public async Task <IActionResult> CreateAsync([FromBody] InToolDTO toolDTO)
        {
            var tool = ToolMapper.Map(toolDTO);

            tool = _repositoryManager.ToolRepository.Create(tool);

            await _repositoryManager.SaveAsync();

            return(Ok(ToolMapper.Map(tool)));
        }
Esempio n. 2
0
        public static void Map(GameObject prefab)
        {
            if (prefab is null)
            {
                throw new ArgumentException("The prefab was NULL.");
            }

            ModComponent modComponent = ComponentUtils.GetModComponent(prefab);

            if (modComponent is null)
            {
                throw new ArgumentException("Prefab " + prefab.name + " does not contain a ModComponent.");
            }

            bool hasModPlaceHolder = !(ComponentUtils.GetComponent <ModPlaceHolderComponent>(prefab) is null);

            if (prefab.GetComponent <GearItem>() is null || hasModPlaceHolder)
            {
                ConfigureBehaviours(modComponent);

                EquippableMapper.Configure(modComponent);
                LiquidMapper.Configure(modComponent);
                PowderMapper.Configure(modComponent);
                FoodMapper.Configure(modComponent);
                CookableMapper.Configure(modComponent);
                CookingPotMapper.Configure(modComponent);
                RifleMapper.Configure(modComponent);
                ClothingMapper.Configure(modComponent);
                CollectibleMapper.Configure(modComponent);
                CharcoalMapper.Configure(modComponent);
                PurificationMapper.Configure(modComponent);
                ResearchMapper.Configure(modComponent);
                FirstAidMapper.Configure(modComponent);
                ToolMapper.Configure(modComponent);
                GenericEquippableMapper.Configure(modComponent);
                BedMapper.Configure(modComponent);
                BodyHarvestMapper.Configure(modComponent);

                if (hasModPlaceHolder)
                {
                    return;
                }

                InspectMapper.Configure(modComponent);
                ConfigureGearItem(modComponent);

                mappedItems.Add(modComponent);

                PostProcess(modComponent);
            }
        }
Esempio n. 3
0
        public static MappedItem Map(GameObject prefab)
        {
            if (prefab == null)
            {
                throw new ArgumentException("The prefab was NULL.");
            }

            ModComponent modComponent = ModUtils.GetModComponent(prefab);

            if (modComponent == null)
            {
                throw new ArgumentException("Prefab " + prefab.name + " does not contain a ModComponent.");
            }

            if (prefab.GetComponent <GearItem>() == null)
            {
                Implementation.Log("Mapping {0}", prefab.name);

                InspectMapper.Configure(modComponent);
                HarvestableMapper.Configure(modComponent);
                RepairableMapper.Configure(modComponent);
                FireStarterMapper.Configure(modComponent);
                ConfigureAccelerant(modComponent);
                ConfigureStackable(modComponent);
                ConfigureBurnable(modComponent);
                ScentMapper.Configure(modComponent);
                SharpenableMapper.Configure(modComponent);
                EvolveMapper.Configure(modComponent);

                ConfigureEquippable(modComponent);
                ConfigureLiquidItem(modComponent);
                ConfigureFood(modComponent);
                CookableMapper.Configure(modComponent);
                ConfigureCookingPot(modComponent);
                ConfigureRifle(modComponent);
                ClothingMapper.ConfigureClothing(modComponent);
                FirstAidMapper.Configure(modComponent);
                ToolMapper.Configure(modComponent);
                BedMapper.Configure(modComponent);

                ConfigureGearItem(modComponent);

                mappedItems.Add(modComponent);

                PostProcess(modComponent);
            }

            return(new MappedItem(prefab));
        }
Esempio n. 4
0
        public async Task <IActionResult> UpdateAsync([FromRoute] int id,
                                                      [FromBody] InToolDTO toolDTO)
        {
            var tool = await _repositoryManager.ToolRepository.GetAsync(id);

            if (tool == null)
            {
                return(NotFound());
            }

            tool.Update(toolDTO);

            _repositoryManager.ToolRepository.Update(tool);

            await _repositoryManager.SaveAsync();

            return(Ok(ToolMapper.Map(tool)));
        }
        /// <summary>
        /// Reads the analysis meta data
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        public List <Analysis> ReadMetaData(string path)
        {
            List <Analysis> metaData = new List <Analysis>();

            string [] lines = File.ReadAllLines(path);
            for (int i = 1; i < lines.Length; i++)
            {
                string    line     = lines[i];
                Analysis  data     = new Analysis();
                string [] lineData = line.Split('\t');
                if (lineData.Length != 3)
                {
                    continue;
                }

                data.Tool     = ToolMapper.ToolName(lineData[0]);
                data.Name     = lineData[1];
                data.FilePath = lineData[2];

                metaData.Add(data);
            }
            return(metaData);
        }
Esempio n. 6
0
        public async Task <IActionResult> GetAsync([FromRoute] int id)
        {
            var tool = await _repositoryManager.ToolRepository.GetAsync(id);

            return(Ok(ToolMapper.CompleteMap(tool)));
        }
Esempio n. 7
0
        public async Task <IActionResult> GetAsync()
        {
            var tools = await _repositoryManager.ToolRepository.GetAsync();

            return(Ok(tools.Select(t => ToolMapper.CompleteMap(t))));
        }