Solved Debug graphics?

Discussion in 'Rust Development' started by rotten, Aug 22, 2017.

  1. Working on a plugin that relies a lot on various entities and relationships between them, so I need to be able to visualize it to make sure it works as intended.

    I'm pretty new to plugin development - anyone know how I can utilize the arrows/spheres/boxes etc. that I keep seeing?
     
  2. ddraw.text, ddraw.sphere, ddraw.arrow, ddraw.box

    All of which are console commands. So you’d need to send the debug client those commands with valid arguments. Decompile some dlls or look into AdminRadar for examples of arguments of the commands.

    For a non auth 2 player to see the debug graphics you’d need to temporarily grant them the admin flag. You can see how you can do that in AdminRadar also.
     
  3. Code:
    void OnOvenToggle(BaseOven oven, BasePlayer player)
            {
                List<BuildingBlock> warmFoundations = new List<BuildingBlock>();
                List<BuildingBlock> campfireFoundations = new List<BuildingBlock>();
                Puts(oven.IsOn().ToString());
                RaycastHit hit;
                Vector3 raycastPosition = new Vector3(oven.GetEstimatedWorldPosition().x, oven.GetEstimatedWorldPosition().y+0.1f, oven.GetEstimatedWorldPosition().z);
                if (Physics.Raycast(raycastPosition, -Vector3.up, out hit))
                Puts("Found an object! Object: " +hit.GetEntity()+" - distance: " + hit.distance);
                BuildingBlock supportingBlock = hit.GetEntity() as BuildingBlock;
                if (supportingBlock != null)
                {
                    campfireFoundations = findFoundations(supportingBlock);
                }
               
                foreach (BuildingBlock foundation in campfireFoundations)
                {
                    //global::Effect.server.Run("assets/prefabs/misc/orebonus/effects/bonus_finish.prefab", foundation.GetEstimatedWorldPosition());
                   
                    player.SendConsoleCommand("ddraw.sphere", 15, Color.yellow, foundation.GetEstimatedWorldPosition(), 1f);
                }
               
               
            }
    Thanks for the reply!

    Any idea what could be wrong here? I tried doing it the way you described, but it doesn't draw the spheres in question. I'm auth level 2.
     
  4. Try looking in your F1 console to see if the command wasn’t run etc. You may have wrong arguments or something. Maybe try with a different ddraw such as text. The sphere may not be called ddraw.sphere tbh. Maybe ddraw.circle (cant remember from the top of my head)
     
  5. I'm 100% certain the arguments are correct. That's why I'm so confused.
     
  6. Are you sure that the player.SendConsoleCommand is running? Maybe try debugging that foreach(as in a PrintWarning or whatever)
     
  7. I've attempted the foreach with effects, spawning a water splash on every foundation, etc - so the issue lies with the actual drawing of the sphere.
     
  8. Code:
            public void CreateSphere(Vector3 position, float distance, float speed, float duration){
                BaseEntity sphere;
                Vector3 pos = new Vector3(0, 0, 0);
                Quaternion rot = new Quaternion();
                string strPrefab = "assets/prefabs/visualization/sphere.prefab";
                sphere = GameManager.server.CreateEntity(strPrefab, pos, rot, true);            SphereEntity ball = sphere.GetComponent<SphereEntity>();
                ball.currentRadius = 1f;
                ball.lerpRadius = 2.0f*distance;
                ball.lerpSpeed = speed;            sphere.SetParent(entity, "");
                sphere?.Spawn();            timer.Once(duration, () =>
                {
                    if(sphere == null) return;
                    sphere.Kill(BaseNetworkable.DestroyMode.None);
                });
            }  
    This is an old function I used, probably not the best might not work. Found it laying around.
     
  9. Thank you! I'll try it out.
    [DOUBLEPOST=1503371424][/DOUBLEPOST]
    It worked! Any idea how to increase the opacity of the spheres?
     
  10. Not sure, you would have to look into the SphereEntity class
     
  11. Yeah, I've done so hence why I was confused. I know on Battle Royale, for example, the sphere is really rather opaque, but the class itself seems to have nothing to adjust the sphere's opacity.
     
  12. Everything but ddraw.text has been broken for a week or so, maybe longer.

    If you want to make the spheres more opaque/dark, spawn multiple on top of each other.
     
  13. Oh shit, I see. Thanks, man.