Jump to content

DebugHandler.cs


gabberworld
  • Branch: Live Branch Version: Windows Pending

not really a bug but more like little performance .

inside DebugHandler.cs you have there the

  public static int GetMouseCell()
  {
    Vector3 mousePos = KInputManager.GetMousePos();
    mousePos.z = -Camera.main.transform.GetPosition().z - Grid.CellSizeInMeters;
    return Grid.PosToCell(Camera.main.ScreenToWorldPoint(mousePos));
  }

  public static Vector3 GetMousePos()
  {
    Vector3 mousePos = KInputManager.GetMousePos();
    mousePos.z = -Camera.main.transform.GetPosition().z - Grid.CellSizeInMeters;
    return Camera.main.ScreenToWorldPoint(mousePos);
  }

i would add there also the

  public static int GetMouseCell(Vector3 _mousepos)
  {
    return Grid.PosToCell(_mousepos);
  }

then after that you could use that at inside SpawnMinion, OnKeyDown

    Vector3 mousePos = GetMousePos();
    int mouseCell = DebugHandler.GetMouseCell(mousePos);

    if (!Grid.IsValidBuildingCell(mouseCell))
    {
      PopFXManager.Instance.SpawnFX(PopFXManager.Instance.sprite_Negative, (string) UI.DEBUG_TOOLS.INVALID_LOCATION, (Transform) null, mousePos, force_spawn: true);
    }else{
      ...
         Vector3 posCbc = Grid.CellToPosCBC(mouseCell, Grid.SceneLayer.Move);
      ...
    }

that would avoid double call for function

    Vector3 mousePos = KInputManager.GetMousePos();
    mousePos.z = -Camera.main.transform.GetPosition().z - Grid.CellSizeInMeters;
    Camera.main.ScreenToWorldPoint(mousePos);

 

not sure but it feels like inside InterfaceTool.cs

there is some double calls as well with this two

      this.GetSelectablesUnderCursor(this.hits);
      KSelectable objectUnderCursor = this.GetObjectUnderCursor<KSelectable>(false, (Func<KSelectable, bool>) (s => s.GetComponent<KSelectable>().IsSelectable));

 


Steps to Reproduce

whatever




User Feedback


There are no comments to display.



Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
  • Create New...