-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcs2-CustomIO.cs
More file actions
648 lines (607 loc) · 30.8 KB
/
Copy pathcs2-CustomIO.cs
File metadata and controls
648 lines (607 loc) · 30.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
using System.Collections.Concurrent;
using System.Runtime.InteropServices;
using Microsoft.Extensions.Logging;
using SwiftlyS2.Shared;
using SwiftlyS2.Shared.Convars;
using SwiftlyS2.Shared.Events;
using SwiftlyS2.Shared.GameEventDefinitions;
using SwiftlyS2.Shared.Memory;
using SwiftlyS2.Shared.Misc;
using SwiftlyS2.Shared.GameHooks;
using SwiftlyS2.Shared.Natives;
using SwiftlyS2.Shared.Plugins;
using SwiftlyS2.Shared.SchemaDefinitions;
namespace CustomIO;
[PluginMetadata(Id = "CS2 CustomIO For SW2", Version = "1.6", Name = "CustomIO SW2", Author = "DarkerZ & LynchMus", Description = "Fixes missing keyvalues from CSS/CS:GO", Website = "https://github.com/himenekocn/CS2-CustomIO-For-SW2")]
public partial class CustomIO(ISwiftlyCore core) : BasePlugin(core)
{
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate void CEntityIdentity_SetEntityName_Delegate(nint a1, string a2);
private static IUnmanagedFunction<CEntityIdentity_SetEntityName_Delegate>? CEntityIdentity_SetEntityName_Func;
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate void CBaseEntity_SetGravityScale_Delegate(nint a1, float a2);
private static IUnmanagedFunction<CBaseEntity_SetGravityScale_Delegate>? CBaseEntity_SetGravityScale_Func;
private Guid? SpawnEvent_HookId;
private IConVar<bool>? sw_iodebug;
private ConcurrentDictionary<int, float> pflSpeedMod = [];
public override void Load(bool hotReload)
{
sw_iodebug = Core.ConVar.CreateOrFind("sw_iodebug", "Enable IO Debug", false);
CEntityIdentity_SetEntityName_Func = Core.Memory.GetUnmanagedFunctionByAddress<CEntityIdentity_SetEntityName_Delegate>(Core.GameData.GetSignature("CEntityInstance::SetEntityName"));
CBaseEntity_SetGravityScale_Func = Core.Memory.GetUnmanagedFunctionByAddress<CBaseEntity_SetGravityScale_Delegate>(Core.GameData.GetSignature("CBaseEntity::SetGravityScale"));
Core.GameHooks.Movement.ProcessMovement.Pre += OnProcessMovementPre;
Core.GameHooks.Movement.ProcessMovement.Post += OnProcessMovementPost;
Core.GameHooks.Entities.AcceptInput.Pre += OnAcceptInputPre;
Core.Event.OnClientPutInServer += OnClientPutInServer;
Core.Event.OnClientDisconnected += OnClientDisconnected;
SpawnEvent_HookId = Core.GameEvent.HookPost<EventPlayerSpawn>(OnPlayerSpawn);
pflSpeedMod.Clear();
}
public override void Unload()
{
Core.GameHooks.Movement.ProcessMovement.Pre -= OnProcessMovementPre;
Core.GameHooks.Movement.ProcessMovement.Post -= OnProcessMovementPost;
Core.GameHooks.Entities.AcceptInput.Pre -= OnAcceptInputPre;
Core.Event.OnClientPutInServer -= OnClientPutInServer;
Core.Event.OnClientDisconnected -= OnClientDisconnected;
if (SpawnEvent_HookId != null)
Core.GameEvent.Unhook(SpawnEvent_HookId.Value);
pflSpeedMod.Clear();
}
private float _storedFrameTime;
private void OnProcessMovementPre(ref ProcessMovementMovementPreContext ctx)
{
var player = ctx.Params.Player;
if (player == null || !player.IsValid)
return;
if (!pflSpeedMod.TryGetValue(player.UserID, out var speedMod))
return;
if (speedMod == 1.0f)
return;
_storedFrameTime = Core.Engine.GlobalVars.FrameTime;
Core.Engine.GlobalVars.FrameTime *= speedMod;
}
private void OnProcessMovementPost(ref ProcessMovementMovementPostContext ctx)
{
var player = ctx.Params.Player;
if (player == null || !player.IsValid)
return;
if (!pflSpeedMod.TryGetValue(player.UserID, out var speedMod))
return;
if (speedMod == 1.0f)
return;
Core.Engine.GlobalVars.FrameTime = _storedFrameTime;
}
private void OnClientDisconnected(IOnClientDisconnectedEvent @event)
{
var slot = @event.PlayerId;
var player = Core.PlayerManager.GetPlayer(slot);
if (player == null || !player.Controller.IsValid)
{
return;
}
pflSpeedMod.TryRemove(player.UserID, out _);
}
private void OnClientPutInServer(IOnClientPutInServerEvent @event)
{
var slot = @event.PlayerId;
var player = Core.PlayerManager.GetPlayer(slot);
if (player == null || !player.IsValid)
{
return;
}
pflSpeedMod.TryAdd(player.UserID, 1.0f);
}
private HookResult OnPlayerSpawn(EventPlayerSpawn @event)
{
var player = @event.UserIdPlayer;
if (player == null || !player.IsValid)
{
return HookResult.Continue;
}
pflSpeedMod[player.UserID] = 1.0f;
return HookResult.Continue;
}
public void OnAcceptInputPre(ref AcceptInputEntityPreContext ctx)
{
var input = ctx.Params.InputName;
if (string.IsNullOrEmpty(input))
{
return;
}
var ceid = ctx.Params.Identity;
if (ceid == null || !ceid.IsValid)
{
return;
}
var cei = ctx.Params.EntityInstance;
if (cei == null || !cei.IsValid)
{
return;
}
var activator = ctx.Params.Activator;
var value = TryToString(ctx.Params.VariantValue);
try
{
if (input.StartsWith("keyvalue", StringComparison.OrdinalIgnoreCase))
{
if (!string.IsNullOrEmpty(value))
{
if (sw_iodebug?.Value == true)
Core.Logger.LogInformation($"[CustomIO]: {input} {value}");
string[] keyvalue = value.Split([' ']);
if (keyvalue.Length >= 2 && !string.IsNullOrEmpty(keyvalue[0]))
{
switch (keyvalue[0].ToLower())
{
case "targetname":
{
if (keyvalue.Length >= 2 && !string.IsNullOrEmpty(keyvalue[1]))
{
CEntityIdentity_SetEntityName_Func?.Call(ceid.Address, keyvalue[1]);
}
}
break;
case "origin":
{
if (keyvalue.Length >= 4 && !string.IsNullOrEmpty(keyvalue[1]) && !string.IsNullOrEmpty(keyvalue[2]) && !string.IsNullOrEmpty(keyvalue[3]))
{
if (float.TryParse(keyvalue[1], out float x) && float.TryParse(keyvalue[2], out float y) && float.TryParse(keyvalue[3], out float z))
{
x = Math.Clamp(x, -16384.0f, 16384.0f);
y = Math.Clamp(y, -16384.0f, 16384.0f);
z = Math.Clamp(z, -16384.0f, 16384.0f);
cei.As<CBaseEntity>().Teleport(new(x, y, z), null, null);
}
}
}
break;
case "angles":
{
if (keyvalue.Length >= 4 && !string.IsNullOrEmpty(keyvalue[1]) && !string.IsNullOrEmpty(keyvalue[2]) && !string.IsNullOrEmpty(keyvalue[3]))
{
if (float.TryParse(keyvalue[1], out float x) && float.TryParse(keyvalue[2], out float y) && float.TryParse(keyvalue[3], out float z))
{
x = Math.Clamp(x, -360.0f, 360.0f);
y = Math.Clamp(y, -360.0f, 360.0f);
z = Math.Clamp(z, -360.0f, 360.0f);
cei.As<CBaseEntity>().Teleport(null, new(x, y, z), null);
}
}
}
break;
case "max_health":
{
int iMaxHealth = 100;
if (keyvalue.Length >= 2 && !string.IsNullOrEmpty(keyvalue[1]) && int.TryParse(keyvalue[1], out iMaxHealth))
{
var entity = cei.As<CBaseEntity>();
if (entity != null && entity.IsValid)
{
entity.MaxHealth = iMaxHealth;
entity.MaxHealthUpdated();
}
}
}
break;
case "health":
{
int iHealth = 100;
if (keyvalue.Length >= 2 && !string.IsNullOrEmpty(keyvalue[1]) && int.TryParse(keyvalue[1], out iHealth))
{
var entity = cei.As<CBaseEntity>();
if (entity != null && entity.IsValid)
{
entity.Health = iHealth;
entity.HealthUpdated();
}
}
}
break;
case "movetype":
{
var player = EntityToPlayer(cei);
if (player != null && player.IsValid && player.PlayerPawn.Value != null && player.PlayerPawn.Value.IsValid && keyvalue.Length >= 2 && !string.IsNullOrEmpty(keyvalue[1]))
{
if (byte.TryParse(keyvalue[1], out byte iMovetype))
{
iMovetype = Math.Clamp(iMovetype, (byte)MoveType_t.MOVETYPE_NONE, (byte)MoveType_t.MOVETYPE_LAST);
player.PlayerPawn.Value.MoveType = (MoveType_t)iMovetype;
player.PlayerPawn.Value.ActualMoveType = (MoveType_t)iMovetype;
player.PlayerPawn.Value.MoveTypeUpdated();
}
}
}
break;
case "entitytemplate":
{
if (keyvalue.Length >= 2 && !string.IsNullOrEmpty(keyvalue[1]) && string.Equals(cei.DesignerName, "env_entity_maker"))
{
cei.As<CEnvEntityMaker>()?.Template = keyvalue[1];
}
}
break;
case "basevelocity":
{
if (keyvalue.Length >= 4 && !string.IsNullOrEmpty(keyvalue[1]) && !string.IsNullOrEmpty(keyvalue[2]) && !string.IsNullOrEmpty(keyvalue[3]))
{
if (float.TryParse(keyvalue[1], out float x) && float.TryParse(keyvalue[2], out float y) && float.TryParse(keyvalue[3], out float z))
{
x = Math.Clamp(x, -4096.0f, 4096.0f);
y = Math.Clamp(y, -4096.0f, 4096.0f);
z = Math.Clamp(z, -4096.0f, 4096.0f);
var entity = cei.As<CBaseEntity>();
if (entity != null && entity.IsValid)
{
entity.BaseVelocity.X = x;
entity.BaseVelocity.Y = y;
entity.BaseVelocity.Z = z;
entity.BaseVelocityUpdated();
}
}
}
}
break;
case "absvelocity":
{
if (keyvalue.Length >= 4 && !string.IsNullOrEmpty(keyvalue[1]) && !string.IsNullOrEmpty(keyvalue[2]) && !string.IsNullOrEmpty(keyvalue[3]))
{
if (float.TryParse(keyvalue[1], out float x) && float.TryParse(keyvalue[2], out float y) && float.TryParse(keyvalue[3], out float z))
{
x = Math.Clamp(x, -4096.0f, 4096.0f);
y = Math.Clamp(y, -4096.0f, 4096.0f);
z = Math.Clamp(z, -4096.0f, 4096.0f);
var entity = cei.As<CBaseEntity>();
if (entity != null && entity.IsValid)
{
entity.Teleport(null, null, new(x, y, z));
}
}
}
}
break;
case "target":
{
if (keyvalue.Length >= 2 && !string.IsNullOrEmpty(keyvalue[1]) && FindEntityByName(keyvalue[1]) is CEntityInstance gettarget && gettarget.IsValid)
{
var entity = cei.As<CBaseEntity>();
if (entity != null && entity.IsValid)
{
entity.Target = gettarget.Entity!.Name;
}
}
}
break;
case "filtername":
{
if (cei.DesignerName.StartsWith("trigger_") && keyvalue.Length >= 2 && !string.IsNullOrEmpty(keyvalue[1]) && FindEntityByName(keyvalue[1]) is CEntityInstance gettarget && gettarget.IsValid && gettarget.DesignerName.StartsWith("filter_"))
{
var trigger = cei.As<CBaseTrigger>();
trigger?.FilterName = gettarget.Entity!.Name;
trigger?.Filter.Raw = gettarget.Entity!.EntityHandle.Raw;
}
}
break;
case "force":
{
if (keyvalue.Length >= 2 && !string.IsNullOrEmpty(keyvalue[1]) && string.Equals(cei.DesignerName, "phys_thruster"))
{
if (float.TryParse(keyvalue[1], out float fForce))
{
cei.As<CPhysThruster>()?.Force = fForce;
}
}
}
break;
case "gravity":
{
if (keyvalue.Length >= 2 && !string.IsNullOrEmpty(keyvalue[1]))
{
if (float.TryParse(keyvalue[1], out float fGravity))
{
var entity = cei.As<CBaseEntity>();
if (entity != null && entity.IsValid)
{
entity.GravityScale = fGravity;
entity.GravityScaleUpdated();
entity.ActualGravityScale = fGravity;
CBaseEntity_SetGravityScale_Func?.Call(entity.Address, fGravity);
}
}
}
}
break;
case "timescale":
{
if (keyvalue.Length >= 2 && !string.IsNullOrEmpty(keyvalue[1]))
{
if (float.TryParse(keyvalue[1], out float fTimeScale))
{
var entity = cei.As<CBaseEntity>();
if (entity != null && entity.IsValid)
{
entity.TimeScale = fTimeScale;
entity.TimeScaleUpdated();
}
}
}
}
break;
case "friction":
{
if (keyvalue.Length >= 2 && !string.IsNullOrEmpty(keyvalue[1]))
{
if (float.TryParse(keyvalue[1], out float fFriction))
{
var entity = cei.As<CBaseEntity>();
if (entity != null && entity.IsValid)
{
entity.Friction = fFriction;
entity.FrictionUpdated();
}
}
}
}
break;
case "speed":
{
var player = EntityToPlayer(cei);
if (player != null && player.IsValid && keyvalue.Length >= 2 && !string.IsNullOrEmpty(keyvalue[1]))
{
if (float.TryParse(keyvalue[1], out float fSpeed))
{
if (fSpeed <= 0.0f) fSpeed = 0.001f;
var iplayer = Core.PlayerManager.GetPlayerFromController(player);
if (iplayer != null && iplayer.IsValid)
pflSpeedMod[iplayer.UserID] = fSpeed;
}
}
}
break;
case "runspeed":
{
var pawn = EntityToPawn(cei);
if (pawn != null && pawn.IsValid && keyvalue.Length >= 2 && !string.IsNullOrEmpty(keyvalue[1]))
{
if (float.TryParse(keyvalue[1], out float fRunSpeed))
{
if (fRunSpeed <= 0.0f) fRunSpeed = 0.001f;
pawn.VelocityModifier = fRunSpeed;
pawn.VelocityModifierUpdated();
}
}
}
break;
case "damage":
{
if (string.Equals(cei.DesignerName, "point_hurt"))
{
if (keyvalue.Length >= 2 && !string.IsNullOrEmpty(keyvalue[1]) && int.TryParse(keyvalue[1], out int iDamage))
{
cei.As<CPointHurt>()?.Damage = iDamage;
}
}
}
break;
case "damagetype":
{
if (string.Equals(cei.DesignerName, "point_hurt"))
{
if (keyvalue.Length >= 2 && !string.IsNullOrEmpty(keyvalue[1]) && int.TryParse(keyvalue[1], out int iBitsDamageType))
{
cei.As<CPointHurt>()?.BitsDamageType = (DamageTypes_t)iBitsDamageType;
}
}
}
break;
case "damageradius":
{
if (string.Equals(cei.DesignerName, "point_hurt"))
{
if (keyvalue.Length >= 2 && !string.IsNullOrEmpty(keyvalue[1]) && int.TryParse(keyvalue[1], out int iDamageRadius))
{
cei.As<CPointHurt>()?.Radius = iDamageRadius;
}
}
}
break;
case "case":
{
if (string.Equals(cei.DesignerName, "logic_case"))
{
if (keyvalue.Length >= 3 && !string.IsNullOrEmpty(keyvalue[1]) && !string.IsNullOrEmpty(keyvalue[2]) && int.TryParse(keyvalue[1], out int iCase))
{
string sArgs = keyvalue[2];
for (int i = 3; i < keyvalue.Length; i++)
{
if (!string.IsNullOrEmpty(keyvalue[i]))
sArgs += " " + keyvalue[i];
}
if (iCase >= 1 && iCase <= 32)
{
cei.As<CLogicCase>()?.Case[iCase - 1] = sArgs;
}
}
}
}
break;
}
}
}
}
else if (Equals(input.ToLower(), "addscore"))
{
var player = EntityToPlayer(activator);
if (player != null && player.IsValid && int.TryParse(value, out int iscore))
{
player.Score += iscore;
player.ScoreUpdated();
}
}
else if (Equals(input.ToLower(), "setmessage") && string.Equals(cei.DesignerName, "env_hudhint"))
{
if (!string.IsNullOrEmpty(value))
{
cei.As<CEnvHudHint>()?.Message = value;
}
}
else if (Equals(input.ToLower(), "setmodel"))
{
if (!string.IsNullOrEmpty(value))
{
var pawn = EntityToPawn(activator);
if (pawn != null && pawn.IsValid)
{
pawn.SetModel(value);
if (pawn.ActualMoveType > MoveType_t.MOVETYPE_OBSOLETE)
{
var originalVelocity = pawn.AbsVelocity;
pawn.Teleport(null, null, Vector.Zero);
pawn.ActualMoveType = MoveType_t.MOVETYPE_OBSOLETE;
pawn.MoveType = MoveType_t.MOVETYPE_OBSOLETE;
pawn.MoveTypeUpdated();
var cHandle = pawn.Entity!.EntityHandle;
Core.Scheduler.DelayBySeconds(0.02f, () =>
{
if (cHandle.IsValid)
{
if (cHandle.Value is CCSPlayerPawn pawn && pawn.IsValid)
{
pawn.ActualMoveType = MoveType_t.MOVETYPE_WALK;
pawn.MoveType = MoveType_t.MOVETYPE_WALK;
pawn.MoveTypeUpdated();
pawn.Teleport(null, null, originalVelocity);
}
}
});
}
}
}
}
}
catch (Exception ex)
{
Core.Logger.LogError("OnAcceptInputPre: {0} - {1}", ex.Message, ex.Source);
}
}
private CEntityInstance? FindEntityByName(string eName)
{
return Core.EntitySystem.GetAllEntities().FirstOrDefault(e => e.IsValid && e.Entity != null && e.Entity.Name.Equals(eName, StringComparison.OrdinalIgnoreCase));
}
private static CCSPlayerController? EntityToPlayer(CEntityInstance? entity)
{
if (entity != null && entity.IsValid && string.Equals(entity.DesignerName, "player"))
{
var pawn = entity.As<CCSPlayerPawn>();
if (pawn is not null && pawn.IsValid)
{
var player = pawn.ToPlayer();
if (player is not null && player.IsValid && player.Controller is not null && player.Controller.IsValid)
{
return player.Controller;
}
}
}
return null;
}
private static CCSPlayerPawn? EntityToPawn(CEntityInstance? entity)
{
if (entity != null && entity.IsValid && string.Equals(entity.DesignerName, "player"))
{
var pawn = entity.As<CCSPlayerPawn>();
if (pawn is not null && pawn.IsValid)
{
return pawn;
}
}
return null;
}
public string? TryToString(CVariant<CVariantDefaultAllocator> cVariant)
{
if (cVariant.TryGetBool(out var boolValue))
{
return $"{boolValue}";
}
else if (cVariant.TryGetChar(out var charValue))
{
return $"{charValue}";
}
else if (cVariant.TryGetInt16(out var int16Value))
{
return $"{int16Value}";
}
else if (cVariant.TryGetUInt16(out var uint16Value))
{
return $"{uint16Value}";
}
else if (cVariant.TryGetInt32(out var int32Value))
{
return $"{int32Value}";
}
else if (cVariant.TryGetUInt32(out var uint32Value))
{
return $"{uint32Value}";
}
else if (cVariant.TryGetInt64(out var int64Value))
{
return $"{int64Value}";
}
else if (cVariant.TryGetUInt64(out var uint64Value))
{
return $"{uint64Value}";
}
else if (cVariant.TryGetFloat(out var floatValue))
{
return $"{floatValue}";
}
else if (cVariant.TryGetDouble(out var doubleValue))
{
return $"{doubleValue}";
}
else if (cVariant.TryGetResourceHandle(out var resourceHandleValue))
{
return $"{resourceHandleValue}";
}
else if (cVariant.TryGetUtlStringToken(out var utlStringTokenValue))
{
return $"{utlStringTokenValue}";
}
else if (cVariant.TryGetHScript(out var hscriptValue))
{
return $"{hscriptValue}";
}
else if (cVariant.TryGetCHandle<CBaseEntity>(out var handleValue))
{
return $"{handleValue.Raw}";
}
else if (cVariant.TryGetVector2D(out var vector2DValue))
{
return $"{vector2DValue}";
}
else if (cVariant.TryGetVector(out var vectorValue))
{
return $"{vectorValue}";
}
else if (cVariant.TryGetVector4D(out var vector4DValue))
{
return $"{vector4DValue}";
}
else if (cVariant.TryGetQAngle(out var qAngleValue))
{
return $"{qAngleValue}";
}
else if (cVariant.TryGetQuaternion(out var quaternionValue))
{
return $"{quaternionValue}";
}
else if (cVariant.TryGetColor(out var colorValue))
{
return $"{colorValue}";
}
else if (cVariant.TryGetString(out var stringValue))
{
return $"{stringValue}";
}
return string.Empty;
}
}