public PlantableCellQuery Reset(PlantableSeed seed, int max_results) { this.seed = seed; this.max_results = max_results; result_cells.Clear(); return(this); }
private static bool CheckValidPlotCell(Instance smi, PlantableSeed seed, int cell, out PlantablePlot plot) { plot = null; if (!Grid.IsValidCell(cell)) { return(false); } int num = (seed.Direction != SingleEntityReceptacle.ReceptacleDirection.Bottom) ? Grid.CellBelow(cell) : Grid.CellAbove(cell); if (!Grid.IsValidCell(num)) { return(false); } if (!Grid.Solid[num]) { return(false); } GameObject gameObject = Grid.Objects[num, 1]; if ((bool)gameObject) { plot = gameObject.GetComponent <PlantablePlot>(); return((UnityEngine.Object)plot != (UnityEngine.Object)null); } return(seed.TestSuitableGround(cell)); }
public static GameObject CreateAndRegisterSeedForPlant(GameObject plant, SeedProducer.ProductionType productionType, string id, string name, string desc, KAnimFile anim, string initialAnim = "object", int numberOfSeeds = 1, List <Tag> additionalTags = null, SingleEntityReceptacle.ReceptacleDirection planterDirection = SingleEntityReceptacle.ReceptacleDirection.Top, Tag replantGroundTag = default(Tag), int sortOrder = 0, string domesticatedDescription = "", CollisionShape collisionShape = CollisionShape.CIRCLE, float width = 0.25f, float height = 0.25f, Recipe.Ingredient[] recipe_ingredients = null, string recipe_description = "", bool ignoreDefaultSeedTag = false) { GameObject gameObject = CreateLooseEntity(id, name, desc, 1f, true, anim, initialAnim, Grid.SceneLayer.Front, collisionShape, width, height, true, SORTORDER.SEEDS + sortOrder, SimHashes.Creature, null); gameObject.AddOrGet <EntitySplitter>(); CreateAndRegisterCompostableFromPrefab(gameObject); PlantableSeed plantableSeed = gameObject.AddOrGet <PlantableSeed>(); plantableSeed.PlantID = new Tag(plant.name); plantableSeed.replantGroundTag = replantGroundTag; plantableSeed.domesticatedDescription = domesticatedDescription; plantableSeed.direction = planterDirection; KPrefabID component = gameObject.GetComponent <KPrefabID>(); foreach (Tag additionalTag in additionalTags) { component.AddTag(additionalTag, false); } if (!ignoreDefaultSeedTag) { component.AddTag(GameTags.Seed, false); } component.AddTag(GameTags.PedestalDisplayable, false); KPrefabID component2 = gameObject.GetComponent <KPrefabID>(); Assets.AddPrefab(component2); SeedProducer seedProducer = plant.AddOrGet <SeedProducer>(); seedProducer.Configure(gameObject.name, productionType, numberOfSeeds); return(gameObject); }
public static GameObject CreateAndRegisterPreviewForPlant(GameObject seed, string id, KAnimFile anim, string initialAnim, int width, int height) { GameObject result = CreateAndRegisterPreview(id, anim, initialAnim, ObjectLayer.Building, width, height); PlantableSeed component = seed.GetComponent <PlantableSeed>(); component.PreviewID = TagManager.Create(id); return(result); }
private bool CheckValidPlotCell(PlantableSeed seed, int plant_cell) { if (!Grid.IsValidCell(plant_cell)) { return(false); } int num = (seed.Direction != SingleEntityReceptacle.ReceptacleDirection.Bottom) ? Grid.CellBelow(plant_cell) : Grid.CellAbove(plant_cell); if (!Grid.IsValidCell(num)) { return(false); } if (!Grid.Solid[num]) { return(false); } if ((bool)Grid.Objects[plant_cell, 5]) { return(false); } if ((bool)Grid.Objects[plant_cell, 1]) { return(false); } GameObject gameObject = Grid.Objects[num, 1]; if ((bool)gameObject) { PlantablePlot component = gameObject.GetComponent <PlantablePlot>(); if ((Object)component == (Object)null) { return(false); } if (component.Direction != seed.Direction) { return(false); } if ((Object)component.Occupant != (Object)null) { return(false); } } else { if (!seed.TestSuitableGround(plant_cell)) { return(false); } if (CountNearbyPlants(num, plantDetectionRadius) > maxPlantsInRadius) { return(false); } } return(true); }
protected override Sprite GetEntityIcon(Tag prefabTag) { GameObject prefab = Assets.GetPrefab(prefabTag); PlantableSeed component = prefab.GetComponent <PlantableSeed>(); if ((Object)component != (Object)null) { return(base.GetEntityIcon(new Tag(component.PlantID))); } return(base.GetEntityIcon(prefabTag)); }
private static void FindDirtPlot(Instance smi) { smi.targetDirtPlotCell = Grid.InvalidCell; PlantableSeed component = smi.targetSeed.GetComponent <PlantableSeed>(); PlantableCellQuery plantableCellQuery = PathFinderQueries.plantableCellQuery.Reset(component, 20); Navigator component2 = smi.GetComponent <Navigator>(); component2.RunQuery(plantableCellQuery); if (plantableCellQuery.result_cells.Count > 0) { smi.targetDirtPlotCell = plantableCellQuery.result_cells[UnityEngine.Random.Range(0, plantableCellQuery.result_cells.Count)]; } }
private string GetSelectedObjectCodexID() { string text = string.Empty; CellSelectionObject component = SelectTool.Instance.selected.GetComponent <CellSelectionObject>(); BuildingUnderConstruction component2 = SelectTool.Instance.selected.GetComponent <BuildingUnderConstruction>(); CreatureBrain component3 = SelectTool.Instance.selected.GetComponent <CreatureBrain>(); PlantableSeed component4 = SelectTool.Instance.selected.GetComponent <PlantableSeed>(); BudUprootedMonitor component5 = SelectTool.Instance.selected.GetComponent <BudUprootedMonitor>(); if ((UnityEngine.Object)component != (UnityEngine.Object)null) { text = CodexCache.FormatLinkID(component.element.id.ToString()); } else if ((UnityEngine.Object)component2 != (UnityEngine.Object)null) { text = CodexCache.FormatLinkID(component2.Def.PrefabID); } else if ((UnityEngine.Object)component3 != (UnityEngine.Object)null) { text = CodexCache.FormatLinkID(SelectTool.Instance.selected.PrefabID().ToString()); text = text.Replace("BABY", string.Empty); } else if ((UnityEngine.Object)component4 != (UnityEngine.Object)null) { text = CodexCache.FormatLinkID(SelectTool.Instance.selected.PrefabID().ToString()); text = text.Replace("SEED", string.Empty); } else if ((UnityEngine.Object)component5 != (UnityEngine.Object)null) { if ((UnityEngine.Object)component5.parentObject.Get() != (UnityEngine.Object)null) { text = CodexCache.FormatLinkID(component5.parentObject.Get().PrefabID().ToString()); } else if ((UnityEngine.Object)component5.GetComponent <TreeBud>() != (UnityEngine.Object)null) { text = CodexCache.FormatLinkID(component5.GetComponent <TreeBud>().buddingTrunk.Get().PrefabID().ToString()); } } else { text = CodexCache.FormatLinkID(SelectTool.Instance.selected.PrefabID().ToString()); } if (CodexCache.entries.ContainsKey(text) || CodexCache.FindSubEntry(text) != null) { return(text); } return(string.Empty); }
private static void PlantComplete(Instance smi) { PlantableSeed plantableSeed = (!(bool)smi.targetSeed) ? null : smi.targetSeed.GetComponent <PlantableSeed>(); if ((bool)plantableSeed && CheckValidPlotCell(smi, plantableSeed, smi.targetDirtPlotCell, out PlantablePlot plot)) { if ((bool)plot) { if ((UnityEngine.Object)plot.Occupant == (UnityEngine.Object)null) { plot.ForceDepositPickupable(smi.targetSeed); } } else { plantableSeed.TryPlant(true); } } smi.targetSeed = null; smi.seed_cell = Grid.InvalidCell; smi.targetPlot = null; }
protected override void SetResultDescriptions(GameObject seed_or_plant) { string text = string.Empty; GameObject gameObject = seed_or_plant; PlantableSeed component = seed_or_plant.GetComponent <PlantableSeed>(); List <Descriptor> list = new List <Descriptor>(); if ((Object)component != (Object)null) { list = component.GetDescriptors(component.gameObject); if ((Object)targetReceptacle.rotatable != (Object)null && targetReceptacle.Direction != component.direction) { if (component.direction == SingleEntityReceptacle.ReceptacleDirection.Top) { text += UI.UISIDESCREENS.PLANTERSIDESCREEN.ROTATION_NEED_FLOOR; } else if (component.direction == SingleEntityReceptacle.ReceptacleDirection.Side) { text += UI.UISIDESCREENS.PLANTERSIDESCREEN.ROTATION_NEED_WALL; } else if (component.direction == SingleEntityReceptacle.ReceptacleDirection.Bottom) { text += UI.UISIDESCREENS.PLANTERSIDESCREEN.ROTATION_NEED_CEILING; } text += "\n\n"; } gameObject = Assets.GetPrefab(component.PlantID); if (!string.IsNullOrEmpty(component.domesticatedDescription)) { text += component.domesticatedDescription; } } else { InfoDescription component2 = gameObject.GetComponent <InfoDescription>(); if ((bool)component2) { text += component2.description; } } descriptionLabel.SetText(text); List <Descriptor> plantLifeCycleDescriptors = GameUtil.GetPlantLifeCycleDescriptors(gameObject); if (plantLifeCycleDescriptors.Count > 0) { HarvestDescriptorPanel.SetDescriptors(plantLifeCycleDescriptors); HarvestDescriptorPanel.gameObject.SetActive(true); } List <Descriptor> plantRequirementDescriptors = GameUtil.GetPlantRequirementDescriptors(gameObject); if (list.Count > 0) { GameUtil.IndentListOfDescriptors(list, 1); plantRequirementDescriptors.InsertRange(plantRequirementDescriptors.Count, list); } if (plantRequirementDescriptors.Count > 0) { RequirementsDescriptorPanel.SetDescriptors(plantRequirementDescriptors); RequirementsDescriptorPanel.gameObject.SetActive(true); } List <Descriptor> plantEffectDescriptors = GameUtil.GetPlantEffectDescriptors(gameObject); if (plantEffectDescriptors.Count > 0) { EffectsDescriptorPanel.SetDescriptors(plantEffectDescriptors); EffectsDescriptorPanel.gameObject.SetActive(true); } else { EffectsDescriptorPanel.gameObject.SetActive(false); } }