Skip to content

feat: add CEntityKeyValues with dispatch#1146

Merged
roflmuffin merged 1 commit intomainfrom
feature/entity-kv
Dec 14, 2025
Merged

feat: add CEntityKeyValues with dispatch#1146
roflmuffin merged 1 commit intomainfrom
feature/entity-kv

Conversation

@roflmuffin
Copy link
Copy Markdown
Owner

@roflmuffin roflmuffin commented Dec 14, 2025

Example from the tests:

var light = Utilities.CreateEntityByName<CBarnLight>("light_barn")!;
using var kv = new CEntityKeyValues();

kv.SetColor("color", Color.BlanchedAlmond);
kv.SetFloat("brightness", 750.0f);
kv.SetBool("enabled", true);
kv.SetVector("size_params", new Vector(60.0f, 120.0f, 0.05f));
kv.SetInt("directlight", 3);
light.DispatchSpawn(kv);

Assert.Equal(750.0f, light.Brightness);
Assert.Equal(Color.BlanchedAlmond.ToArgb(), light.Color.ToArgb());
Assert.True(light.Enabled);
Assert.Equal(60.0f, light.SizeParams.X);
Assert.Equal(120.0f, light.SizeParams.Y);
Assert.Equal(0.05f, light.SizeParams.Z);
Assert.Equal(3, light.DirectLight);

light.Remove();

This will no doubt lead to more memory leaks if you are creating Vector3, Quaternion etc. to pass into key values; but this will be resolved in the v2 branch once I bring these changes forward (and everything becomes struct based).

@roflmuffin roflmuffin merged commit 0112853 into main Dec 14, 2025
8 checks passed
@roflmuffin roflmuffin deleted the feature/entity-kv branch December 14, 2025 04:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant