private bool IsCorrectEnvironment(FCSDNA plantable) { if (_currentEnvironment == FCSEnvironment.Water && plantable.Environment == FCSEnvironment.Water) { return(true); } if (_currentEnvironment == FCSEnvironment.Air && plantable.Environment == FCSEnvironment.Air) { return(true); } return(false); }
private bool TryPlant(FCSDNA plantable, InventoryItem item) { bool result = false; if (IsCorrectEnvironment(plantable)) { if (GetContainerFreeSpace >= 1) { var freeslot = GetFreeSlotID(); AddItem(plantable, freeslot, item.item.GetTechType()); result = true; } } if (result) { Destroy(item.item); } return(result); }
private void AddItem(FCSDNA plantable, int slotID, TechType dnaTechType) { var slotByID = this.GetSlotByID(slotID); if (slotByID == null) { return; } if (slotByID.IsOccupied) { return; } QuickLogger.Debug($"Adding DNa with TechType {plantable.TechType}", true); SetSlotOccupiedState(slotID, true); slotByID.Plantable = plantable; slotByID.PlantModel = Spawn(slotByID.Slot, plantable.TechType, plantable.Model); if (_dna.ContainsKey(plantable.GiveItem)) { _dna[plantable.GiveItem].Amount += 1; } else { _dna.Add(plantable.GiveItem, new StoredDNAData { Amount = 1, TechType = dnaTechType }); } if (!_fromLoad) { if (!_mono.HydroHarvContainer.Items.ContainsKey(plantable.GiveItem)) { _mono.HydroHarvContainer.AddItemToContainer(plantable.GiveItem, true); } } _mono.DisplayManager.UpdateDnaCounter(); }