public bool TestSuitableGround(int cell)
    {
        if (!Grid.IsValidCell(cell))
        {
            return(false);
        }
        int num = (Direction != SingleEntityReceptacle.ReceptacleDirection.Bottom) ? Grid.CellBelow(cell) : Grid.CellAbove(cell);

        if (!Grid.IsValidCell(num))
        {
            return(false);
        }
        if (Grid.Foundation[num])
        {
            return(false);
        }
        if (Grid.Element[num].hardness >= 150)
        {
            return(false);
        }
        if (replantGroundTag.IsValid && !Grid.Element[num].HasTag(replantGroundTag))
        {
            return(false);
        }
        GameObject       prefab    = Assets.GetPrefab(PlantID);
        EntombVulnerable component = prefab.GetComponent <EntombVulnerable>();

        if ((Object)component != (Object)null && !component.IsCellSafe(cell))
        {
            return(false);
        }
        DrowningMonitor component2 = prefab.GetComponent <DrowningMonitor>();

        if ((Object)component2 != (Object)null && !component2.IsCellSafe(cell))
        {
            return(false);
        }
        TemperatureVulnerable component3 = prefab.GetComponent <TemperatureVulnerable>();

        if ((Object)component3 != (Object)null && !component3.IsCellSafe(cell))
        {
            return(false);
        }
        UprootedMonitor component4 = prefab.GetComponent <UprootedMonitor>();

        if ((Object)component4 != (Object)null && !component4.IsCellSafe(cell))
        {
            return(false);
        }
        OccupyArea component5 = prefab.GetComponent <OccupyArea>();

        if ((Object)component5 != (Object)null && !component5.CanOccupyArea(cell, ObjectLayer.Building))
        {
            return(false);
        }
        return(true);
    }
Example #2
0
            /// <summary>
            /// Checks a potential item and updates the best found if it is closer and
            /// suitable.
            /// </summary>
            /// <param name="item">The item to be eaten.</param>
            public void CheckUpdate(KMonoBehaviour item)
            {
                var go = item.gameObject;
                // Was already null checked
                int cell = Grid.PosToCell(item.transform.position);

                if (drowning == null || !drowning.canDrownToDeath || drowning.
                    livesUnderWater || drowning.IsCellSafe(cell))
                {
                    // Is it closer?
                    int cost = navigator.GetNavigationCost(cell);
                    if (cost >= 0 && cost < distance)
                    {
                        distance = cost;
                        target   = go;
                    }
                }
            }
 public override bool IsMatch(int cell, int parent_cell, int cost)
 {
     return(monitor.IsCellSafe(cell));
 }