Exemplo n.º 1
0
        /// <summary>
        /// Checks to see if a cell is a natural tile, or a valid farm plot.
        /// </summary>
        /// <param name="cell">The cell to check.</param>
        /// <param name="direction">The direction which a farm plot must be facing to be valid.</param>
        /// <returns>true if it is a valid planting location, or false otherwise.</returns>
        private static bool IsPlantable(int cell, ReceptacleDirection direction)
        {
            bool          valid = false;
            PlantablePlot plot;

            if (Grid.IsSolidCell(cell))
            {
                var building = Grid.Objects[cell, BUILDINGS_LAYER];
                if (building == null)
                {
                    valid = true;
                }
                else if ((plot = building.GetComponent <PlantablePlot>()) != null)
                {
                    // Check direction
                    valid = plot.Direction == direction;
                }
            }
            return(valid);
        }
 private bool ValidRotationForDeposit(SingleEntityReceptacle.ReceptacleDirection depositDir)
 {
     return((Object)targetReceptacle.rotatable == (Object)null || depositDir == targetReceptacle.Direction);
 }
Exemplo n.º 3
0
        public static GameObject CreateCrystalPlantPrefab(string Id, string SeedId, string Name, string SeedName,
                                                          string Description, string SeedDescription, string DomesticatedDescription, string anim, SingleEntityReceptacle.ReceptacleDirection direction)
        {
            var placedEntity = EntityTemplates.CreatePlacedEntity(
                id: Id,
                name: Name,
                desc: Description,
                mass: 1f,
                anim: Assets.GetAnim(anim),
                initialAnim: "idle_empty",
                sceneLayer: Grid.SceneLayer.BuildingFront,
                width: 1,
                height: 2,
                decor: TUNING.DECOR.BONUS.TIER2,
                defaultTemperature: DefaultTemperature);

            EntityTemplates.ExtendEntityToBasicPlant(
                template: placedEntity,
                temperature_lethal_low: TemperatureLethalLow,
                temperature_warning_low: TemperatureWarningLow,
                temperature_warning_high: TemperatureWarningHigh,
                temperature_lethal_high: TemperatureLethalHigh,
                safe_elements: new[] { SimHashes.Oxygen },
                pressure_sensitive: true,
                pressure_lethal_low: 0.0f,
                pressure_warning_low: 0.15f,
                crop_id: Elements.CrystalElement.Id);

            EntityTemplates.ExtendPlantToIrrigated(
                template: placedEntity,
                info: new PlantElementAbsorber.ConsumeInfo()
            {
                tag = ElementLoader.FindElementByHash(Elements.MineralWaterElement.SimHash).tag,
                massConsumptionRate = IrrigationRate
            });

            if (direction == SingleEntityReceptacle.ReceptacleDirection.Bottom)
            {
                EntityTemplates.MakeHangingOffsets(placedEntity, 1, 2);
                placedEntity.GetComponent <UprootedMonitor>().monitorCell = new CellOffset(0, 1);
            }

            placedEntity.AddOrGet <StandardCropPlant>();

            var seed = EntityTemplates.CreateAndRegisterSeedForPlant(
                plant: placedEntity,
                productionType: SeedProducer.ProductionType.DigOnly,
                id: SeedId,
                name: SeedName,
                desc: SeedDescription,
                anim: Assets.GetAnim(anim),
                initialAnim: "object",
                numberOfSeeds: 1,
                additionalTags: new List <Tag>()
            {
                GameTags.CropSeed
            },
                planterDirection: direction,
                replantGroundTag: new Tag(),
                sortOrder: 2,
                domesticatedDescription: DomesticatedDescription,
                collisionShape: EntityTemplates.CollisionShape.CIRCLE,
                width: 0.2f,
                height: 0.2f,
                ignoreDefaultSeedTag: true);;

            EntityTemplates.CreateAndRegisterPreviewForPlant(
                seed: seed,
                id: $"{Id}_preview",
                anim: Assets.GetAnim(anim),
                initialAnim: "place",
                width: 1,
                height: 1);

            SoundEventVolumeCache.instance.AddVolume(anim, $"{Id}_grow", TUNING.NOISE_POLLUTION.CREATURES.TIER3);
            SoundEventVolumeCache.instance.AddVolume(anim, $"{Id}_harvest", TUNING.NOISE_POLLUTION.CREATURES.TIER3);
            return(placedEntity);
        }
Exemplo n.º 4
0
 /// <summary>
 /// Checks to see if a cell is a natural tile of sufficient hardness, or a valid
 /// farm plot.
 /// </summary>
 /// <param name="cell">The cell to check.</param>
 /// <param name="direction">The direction which a farm plot must be facing to be valid.</param>
 /// <returns>true if it is a valid planting location, or false otherwise.</returns>
 internal static bool IsAcceptableCell(int cell, ReceptacleDirection direction)
 {
     return(IsPlantable(cell, direction) && !IsTooHard(cell));
 }
Exemplo n.º 5
0
    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);
    }