Example: Enemy Outlines#
A walkthrough of examples/enemy_outlines.cpp — a plugin that applies in-game outlines/glow to players with configurable per-visibility colors.
Full Source#
#include <xenon/SDK.hpp>
using namespace xenon;
// ── Configuration ────────────────────────────────────────
static bool g_enabled = true;
// Enemy
static bool g_enemyVisible = true;
static Color g_enemyVisColor(255, 0, 0);
static bool g_enemyOccluded = true;
static Color g_enemyOccColor(255, 100, 0);
// Team
static bool g_teamVisible = false;
static Color g_teamVisColor(0, 255, 0);
static bool g_teamOccluded = false;
static Color g_teamOccColor(0, 150, 255);
// ── Plugin Info ──────────────────────────────────────────
XENON_PLUGIN_INFO(
"Outlines", "Outlines", "Xenon",
"Configurable outline/glow for enemies and teammates.", "1.0",
0, PluginFlags::HasMenu
)
// ── Load / Unload ────────────────────────────────────────
extern "C" void on_load()
{
g_enabled = Config::GetBool("enabled", true);
g_enemyVisible = Config::GetBool("enemyVisible", true);
g_enemyVisColor = Config::GetColor("enemyVis", Color(255, 0, 0));
g_enemyOccluded = Config::GetBool("enemyOccluded", true);
g_enemyOccColor = Config::GetColor("enemyOcc", Color(255, 100, 0));
g_teamVisible = Config::GetBool("teamVisible", false);
g_teamVisColor = Config::GetColor("teamVis", Color(0, 255, 0));
g_teamOccluded = Config::GetBool("teamOccluded", false);
g_teamOccColor = Config::GetColor("teamOcc", Color(0, 150, 255));
Log("Outlines v1.0 loaded");
}
extern "C" void on_unload()
{
Config::SetBool("enabled", g_enabled);
Config::SetBool("enemyVisible", g_enemyVisible);
Config::SetColor("enemyVis", g_enemyVisColor);
Config::SetBool("enemyOccluded", g_enemyOccluded);
Config::SetColor("enemyOcc", g_enemyOccColor);
Config::SetBool("teamVisible", g_teamVisible);
Config::SetColor("teamVis", g_teamVisColor);
Config::SetBool("teamOccluded", g_teamOccluded);
Config::SetColor("teamOcc", g_teamOccColor);
Config::Save();
}
// ── Frame Logic ──────────────────────────────────────────
extern "C" void on_frame(float dt)
{
if (!g_enabled) return;
for (Entity player : Players())
{
if (!player.IsAlive() || player.IsLocal()) continue;
bool visible = player.IsVisible();
if (player.IsEnemy())
{
if (visible && g_enemyVisible)
player.SetOutlineVisible(g_enemyVisColor);
else if (!visible && g_enemyOccluded)
player.SetOutlineOccluded(g_enemyOccColor);
}
else if (player.IsAlly())
{
if (visible && g_teamVisible)
player.SetOutlineVisible(g_teamVisColor);
else if (!visible && g_teamOccluded)
player.SetOutlineOccluded(g_teamOccColor);
}
}
}
// ── Menu ─────────────────────────────────────────────────
extern "C" void on_menu()
{
if (ImGui::CollapsingHeader("Outlines"))
{
ImGui::Checkbox("Enable", &g_enabled);
ImGui::Separator();
ImGui::Text("Enemy");
ImGui::Checkbox("Enemy Visible", &g_enemyVisible);
if (g_enemyVisible)
ImGui::ColorSliders("EV", &g_enemyVisColor);
ImGui::Checkbox("Enemy Occluded", &g_enemyOccluded);
if (g_enemyOccluded)
ImGui::ColorSliders("EO", &g_enemyOccColor);
ImGui::Separator();
ImGui::Text("Team");
ImGui::Checkbox("Team Visible", &g_teamVisible);
if (g_teamVisible)
ImGui::ColorSliders("TV", &g_teamVisColor);
ImGui::Checkbox("Team Occluded", &g_teamOccluded);
if (g_teamOccluded)
ImGui::ColorSliders("TO", &g_teamOccColor);
}
}
Breakdown#
No Overlay Flag#
This plugin only has HasMenu — it doesn't draw overlay primitives. Outlines are applied via SetOutlineVisible / SetOutlineOccluded during on_frame, not on_render.
Outline API#
The outline system applies in-game glow effects to entities:
player.SetOutlineVisible(color); // Outline when in line of sight
player.SetOutlineOccluded(color); // Outline through walls (wallhack)
These map to OutlineType constants (1 = visible, 2 = occluded).
Color Config with ColorSliders#
Colors are persisted using Config::GetColor / Config::SetColor, which store each color as 4 integer keys (key_r, key_g, key_b, key_a). The menu uses ImGui::ColorSliders for RGBA editing:
Conditional UI#
Color sliders only appear when the corresponding outline is enabled:
ImGui::Checkbox("Enemy Visible", &g_enemyVisible);
if (g_enemyVisible)
ImGui::ColorSliders("EV", &g_enemyVisColor);
Build#
Output: output/enemy_outlines.wasm
See Also#
- Entity API — Outline —
SetOutlinemethods - Config API — Colors —
GetColor/SetColor - ImGui API — ColorSliders — RGBA color picker widget