예제 #1
0
 [HarmonyPriority(-10000)] // Extremely low priority. We want this to happen last, since this will only overwrite RotatablePump results
 public static void Postfix(Pump __instance, ref bool __result, Element.State expected_state)
 {
     if (__instance is RotatablePump)
     {
         Rotatable rotatable = __instance.GetComponent <Rotatable>();
         RotatableElementConsumer consumer = __instance.GetComponent <RotatableElementConsumer>();
         //Debug.Log("IsPumpable call " + consumer.rotatableCellOffset + ", " + consumer.sampleCellOffset);
         // Basically a copy of vanilla Pump IsPumpable, but with different initial
         int num = Grid.PosToCell(__instance.transform.GetPosition() + Rotatable.GetRotatedOffset(consumer.rotatableCellOffset, rotatable.GetOrientation()));
         for (int i = 0; i < consumer.consumptionRadius; i++)
         {
             for (int j = 0; j < consumer.consumptionRadius; j++)
             {
                 int  num2 = num + j + Grid.WidthInCells * i;
                 bool flag = Grid.Element[num2].IsState(expected_state);
                 if (flag)
                 {
                     __result = true;
                     return;
                 }
             }
         }
         __result = false;
         return;
     }
 }
예제 #2
0
    private void OnMouseDown()
    {
        if (!hasTower && canHaveTower)
        {
            if (inv.Current_Stone_Total >= inv.Basic_Tower_Price_Int)
            {
                GameObject BasicTower;
                BasicTower             = Instantiate(Tower, new Vector3(transform.position.x, transform.position.y + 5, transform.position.z), new Quaternion(0, 0, 0, 0));
                currentTower           = BasicTower.GetComponent <TowerBehaviour>();
                currentTower.towerName = "BasicTower";
                currentTower.PosOnGrid = new Vector2(PosX, PosY);

                hasTower = true;
                inv.Current_Stone_Total -= inv.Basic_Tower_Price_Int;
            }
        }
        else if (!hasTower && TileType == Type.Water)
        {
            if (inv.Current_Stone_Total >= inv.Pump_Price_Int)
            {
                GameObject Pump;
                Pump         = Instantiate(Tower, new Vector3(transform.position.x, transform.position.y + 5, transform.position.z), new Quaternion(0, 0, 0, 0));
                currentTower = Pump.GetComponent <TowerBehaviour>();

                currentTower.towerName = "Pump";
                currentTower.PosOnGrid = new Vector2(PosX, PosY);

                hasTower = true;
                inv.Current_Stone_Total -= inv.Pump_Price_Int;
            }
        }
        else if (!hasTower && TileType == Type.Stone)
        {
            if (inv.Current_Stone_Total >= inv.Drill_Price_Int)
            {
                GameObject Drill;
                Drill        = Instantiate(Tower, new Vector3(transform.position.x, transform.position.y + 5, transform.position.z), new Quaternion(0, 0, 0, 0));
                currentTower = Drill.GetComponent <TowerBehaviour>();

                currentTower.towerName = "Drill";
                currentTower.PosOnGrid = new Vector2(PosX, PosY);
                hasTower = true;
                inv.Current_Stone_Total -= inv.Drill_Price_Int;
            }
        }
    }