(SubgameEntity creator, List<String> args, GameExportsImpl gameExports)
| 1035 | } |
| 1036 | |
| 1037 | static void SpawnNewEntity(SubgameEntity creator, List<String> args, GameExportsImpl gameExports) { |
| 1038 | String className; |
| 1039 | if (args.size() >= 2) |
| 1040 | className = args.get(1); |
| 1041 | else { |
| 1042 | gameExports.gameImports.dprintf("usage: spawn <classname>\n"); |
| 1043 | return; |
| 1044 | } |
| 1045 | |
| 1046 | if (gameExports.gameCvars.deathmatch.value != 0 && gameExports.gameCvars.sv_cheats.value == 0) { |
| 1047 | gameExports.gameImports.cprintf(creator, Defines.PRINT_HIGH, |
| 1048 | "You must run the server with '+set cheats 1' to enable this command.\n"); |
| 1049 | return; |
| 1050 | } |
| 1051 | |
| 1052 | gameExports.gameImports.dprintf("Spawning " + className + " at " + Lib.vtofs(creator.s.origin) + ", " + Lib.vtofs(creator.s.angles) + "\n"); |
| 1053 | |
| 1054 | var spawn = spawns.get(className); |
| 1055 | GameItem gitem_t = GameItems.FindItemByClassname(className, gameExports); |
| 1056 | if (spawn != null || gitem_t != null) { |
| 1057 | SubgameEntity newThing = gameExports.G_Spawn(); |
| 1058 | |
| 1059 | putInFrontOfCreator(creator, newThing); |
| 1060 | |
| 1061 | newThing.classname = className; |
| 1062 | gameExports.gameImports.linkentity(newThing); |
| 1063 | if (spawn != null) |
| 1064 | spawn.spawn(newThing, gameExports); |
| 1065 | else |
| 1066 | GameItems.SpawnItem(newThing, gitem_t, gameExports); |
| 1067 | |
| 1068 | gameExports.gameImports.dprintf("Spawned!\n"); |
| 1069 | } |
| 1070 | } |
| 1071 | |
| 1072 | private static void putInFrontOfCreator(SubgameEntity creator, SubgameEntity newThing) { |
| 1073 | float[] location = creator.s.origin; |
no test coverage detected