Beispiel #1
0
 static bool Prefix(Player __instance, bool takeInput, float dt, PieceTable ___m_buildPieces, GameObject ___m_placementGhost)
 {
     if (!AllowByKey() || !CheckKeyHeld(pullItemsKey.Value) || !__instance.InPlaceMode() || !takeInput || Hud.IsPieceSelectionVisible())
     {
         return(true);
     }
     if (ZInput.GetButtonDown("Attack") || ZInput.GetButtonDown("JoyPlace"))
     {
         Piece selectedPiece = ___m_buildPieces.GetSelectedPiece();
         if (selectedPiece != null)
         {
             if (selectedPiece.m_repairPiece)
             {
                 return(true);
             }
             if (___m_placementGhost != null)
             {
                 int placementStatus = (int)typeof(Player).GetField("m_placementStatus", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(__instance);
                 if (placementStatus == 0)
                 {
                     Dbgl($"pulling resources to player inventory for piece {selectedPiece.name}");
                     PullResources(__instance, selectedPiece.m_resources, 0);
                 }
             }
         }
     }
     return(false);
 }