Exemple #1
0
        static void Postfix(CastleBlock __instance)
        {
            Cell     c    = __instance.GetComponent <Building>().GetCell();
            CellMark mark = ElevationManager.GetCellMark(c);

            if (mark != null)
            {
                Cell[] neighborCells = new Cell[4];

                Building b = __instance.GetComponent <Building>();
                World.inst.GetNeighborCells(c, ref neighborCells);


                int idx = -1;
                for (int n = 0; n < c.OccupyingStructure.Count; n++)
                {
                    if (c.OccupyingStructure[n] == b)
                    {
                        idx = n;
                        break;
                    }
                }

                float selfHeight = BuildingPlacePatch.GetAbsoluteStackHeightOfBuildingAtIndex(c, idx);
                DebugExt.dLog(" -- " + idx.ToString() + " -- ");
                DebugExt.dLog(selfHeight.ToString());

                typeof(CastleBlock).GetMethod("ClearDoors", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(__instance, new object[] { });
                for (int m = 0; m < neighborCells.Length; m++)
                {
                    float otherHeight = BuildingPlacePatch.GetAbsoluteStackHeightTotal(neighborCells[m]);

                    if (otherHeight > 0f)
                    {
                        DebugExt.dLog(otherHeight.ToString());
                    }

                    Cell cell = neighborCells[m];
                    if (cell != null)
                    {
                        if (Mathf.Approximately(selfHeight - 0.5f, otherHeight) && otherHeight > 0)
                        {
                            DebugExt.dLog("Connection!");
                            typeof(CastleBlock).GetMethod("VisibleDoors", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(__instance, new object[] { true });
                        }
                    }
                }
            }
        }
Exemple #2
0
 static void Postfix(Building PendingObj, ref PlacementValidationResult __result)
 {
     if (__result == PlacementValidationResult.Valid)
     {
         if (BuildingPlacePatch.UnevenTerrain(PendingObj))
         {
             __result = PlacementValidationResult.MustBeOnFlatLand;
         }
         if (PathingManager.BlockedCompletely(World.inst.GetCellData(PendingObj.transform.position)))
         {
             __result = PlacementValidationResult.OutsideOfTerritory;
             CurrentPlacementOnBlockedCell = true;
         }
         else
         {
             CurrentPlacementOnBlockedCell = false;
         }
     }
 }