-
-
Notifications
You must be signed in to change notification settings - Fork 132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implementing EntityKeyValues #615
base: main
Are you sure you want to change the base?
Conversation
if (type == typeof(Color)) | ||
{ | ||
var pointer = (IntPtr)GetResult(typeof(IntPtr), ptr); | ||
return Marshaling.ColorMarshaler.NativeToManaged(pointer); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one should be there since the beginning I believe haha
if (type == typeof(CEntityHandle)) | ||
{ | ||
return new CEntityHandle((uint)GetResult(typeof(uint), ptr)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hope this one fits?
|
||
case counterstrikesharp::TYPE_COLOR: | ||
{ | ||
script_context.SetResult(new Color(keyValues->GetColor(key))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
script_context.SetResult(new Vector(keyValues->GetVector(key))); | ||
break; | ||
} | ||
|
||
case counterstrikesharp::TYPE_VECTOR2D: | ||
{ | ||
script_context.SetResult(new Vector2D(keyValues->GetVector2D(key))); | ||
break; | ||
} | ||
|
||
case counterstrikesharp::TYPE_VECTOR4D: | ||
{ | ||
script_context.SetResult(new Vector4D(keyValues->GetVector4D(key))); | ||
break; | ||
} | ||
|
||
case counterstrikesharp::TYPE_QUATERNION: | ||
{ | ||
script_context.SetResult(new Quaternion(keyValues->GetQuaternion(key))); | ||
break; | ||
} | ||
|
||
case counterstrikesharp::TYPE_QANGLE: | ||
{ | ||
script_context.SetResult(new QAngle(keyValues->GetQAngle(key))); | ||
break; | ||
} | ||
|
||
case counterstrikesharp::TYPE_MATRIX3X4: | ||
{ | ||
script_context.SetResult(new matrix3x4_t(keyValues->GetMatrix3x4(key))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These should not leak with #613 because the wrapper classes will be DisposableMemory
and when its no longer used on the managed side these pointers are released
Vector2D* Vector2DNew(ScriptContext& script_context) | ||
{ | ||
return new Vector2D(); | ||
} | ||
|
||
Vector4D* Vector4DNew(ScriptContext& script_context) | ||
{ | ||
return new Vector4D(); | ||
} | ||
|
||
matrix3x4_t* Matrix3x4New(ScriptContext& script_context) | ||
{ | ||
return new matrix3x4_t(); | ||
} | ||
|
||
Quaternion* QuaternionNew(ScriptContext& script_context) | ||
{ | ||
return new Quaternion(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above!
|
||
CEntityKeyValues* EntityKeyValuesNew(ScriptContext& script_context) | ||
{ | ||
return new CEntityKeyValues(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
forgot to mention that this one is also will be released with #613
…`, `matrix3x4_t`
293a3a8
to
7d346df
Compare
Mostly based on #440 by @Yarukon
Implemented
CEntityKeyValues
, can be used like:This is also possible:
Also implemented some of the math related classes minimally, however: we need #613 in order to prevent memory leaks related to them. (changes needed later on if this one gets merged earlier, or I can make the adjustments on this if 613 is merged.)