Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

61 lines
1.2 KiB

  1. //=========================================================
  2. // An spawner on the server is getting ready to
  3. // prespawn an entity. It calls this function, sending us
  4. // the entity that it's preparing to spawn.
  5. //=========================================================
  6. function __ExecutePreSpawn( entity )
  7. {
  8. __EntityMakerResult <- {}
  9. if ( "PreSpawnInstance" in this )
  10. {
  11. local overrides = PreSpawnInstance( entity.GetClassname(), entity.GetName() );
  12. local type = typeof( overrides );
  13. if ( type == "table" )
  14. {
  15. foreach( key, value in overrides )
  16. {
  17. switch ( typeof( value ) )
  18. {
  19. case "string":
  20. {
  21. entity.__KeyValueFromString( key, value );
  22. break;
  23. }
  24. case "integer":
  25. {
  26. entity.__KeyValueFromInt( key, value );
  27. break;
  28. }
  29. case "float":
  30. case "bool":
  31. {
  32. entity.__KeyValueFromFloat( key, value.tofloat() );
  33. break;
  34. }
  35. case "Vector":
  36. {
  37. entity.__KeyValueFromVector( key, value );
  38. break
  39. }
  40. default:
  41. {
  42. printl( "Cannot use " + typeof( value ) + " as a key" );
  43. }
  44. }
  45. }
  46. }
  47. if ( type == "bool" )
  48. {
  49. return overrides;
  50. }
  51. }
  52. };
  53. function __FinishSpawn()
  54. {
  55. __EntityMakerResult <- null;
  56. }