Пример #1
0
 // determines if within scanner crosshair. code copied from Pathea.TreasureRevealerNs.TreasureRevealerItem::FreshLock()
 static Pathea.TreasureRevealerNs.TreasureRevealerItem treasureInCrosshair()
 {
     try
     {
         // Main.mod.Logger.Log(string.Format("treasure revealed count {0}", revealedTreasure.Count));
         if (revealedTreasure == null || revealedTreasure.Count == 0)
         {
             return(null);
         }
         Pathea.TreasureRevealerNs.TreasureRevealerItem result = null;
         float num = 25f;
         // Main.mod.Logger.Log(string.Format("treasure count {0}", revealedTreasure.Count));
         for (int i = 0; i < revealedTreasure.Count; i++)
         {
             if (!(revealedTreasure[i] == null))
             {
                 Vector3 v = Pathea.UISystemNs.UIUtils.WorldToScreenWithZ(revealedTreasure[i].pos, Vector2.zero);
                 //Main.mod.Logger.Log(string.Format("vector v {0}",v.ToString()));
                 Vector2 screenCoords = Pathea.UISystemNs.UIStateComm.Instance.canvas.GetComponent <RectTransform>().sizeDelta / 2f;
                 //Main.mod.Logger.Log(string.Format("vector vector {0}", vector.ToString()));
                 bool inscreen = v.x <= screenCoords.x && v.x >= -screenCoords.x && v.y <= screenCoords.y && v.y >= -screenCoords.y;
                 // Main.mod.Logger.Log(string.Format("inscreen {0}", inscreen));
                 if (inscreen && v.z >= 0f)
                 {
                     float num2 = Vector2.Distance(Vector2.zero, new Vector2(v.x, v.y));
                     //Main.mod.Logger.Log(string.Format("distance {0}", num2));
                     if (num2 < num)
                     {
                         result = revealedTreasure[i];
                         break;
                     }
                 }
             }
         }
         return(result);
     }
     catch (Exception e)
     {
         Main.mod.Logger.Error("altFreshLock");
         Main.mod.Logger.LogException(e);
     }
     return(null);
 }
Пример #2
0
        static void PostfixUpdate(
            ref Pathea.UISystemNs.TreasureRevealerUICtr __instance,
            ref Pathea.TreasureRevealerNs.TreasureRevealerItem ___curLock
            )
        {
            try
            {
                // keeptrack of last fresh lock
                // maybe transpiler later.
                if (
                    null != ___curLock &&
                    !revealedTreasure.Contains(___curLock) &&
                    null != ___curLock.transf.GetComponent <Pathea.ItemDropNs.ItemDrop>()
                    )
                {
                    revealedTreasure.Add(___curLock);
                }

                if (Main.modSettings.DigLongDistanceLoot && Pathea.InputSolutionNs.PlayerActionModule.Self.IsAcionPressed(ActionType.ActionInteract))
                {
                    Pathea.TreasureRevealerNs.TreasureRevealerItem result = treasureInCrosshair();
                    if (
                        null != result
                        )
                    {
                        //Main.mod.Logger.Log(string.Format("lastFreshLock {0}", result.GetInstanceID()));
                        //result.transf.position = Player.Self.GamePos;
                        // move to player and let autopickup do it's thing.
                        Pathea.ItemDropNs.ItemDrop itm = result.transf.GetComponent <Pathea.ItemDropNs.ItemDrop>();
                        itm.transform.position = Player.Self.GamePos;
                        revealedTreasure.Remove(result);
                    }
                }
            }
            catch (Exception e)
            {
                Main.mod.Logger.LogException(e);
            }
        }