@LabelIndex 420779
@StringIndex 0
class 1 child_spawn_all : default_maker {
parameter:
	int	on_start_spawn = 0;
	string	maker_name = "child_spawn_all_default";

handler:
	EventHandler ON_START(i0,def0) {
		super;
		myself.i_ai0 = 0;
	}

	EventHandler ON_NPC_DELETED(deleted_def,deleted_npc,i0,i1,maker0) {
		if( myself.i_ai0 == 1 ) {
			if( myself::AtomicIncreaseTotal(deleted_def,1,1) ) {
				deleted_def::Spawn2(1,deleted_def.respawn_time,deleted_def.respawn_rand);
			}
		}
	}

	EventHandler ON_NPC_CREATED(created_def,created_npc,maker0,i0) {
		if( myself.i_ai0 == 0 ) {
			created_npc::Despawn();
		}
	}

	EventHandler ON_SCRIPT_EVENT(script_event_arg1,script_event_arg2,script_event_arg3,def0,i0,i1,maker0) {
		switch(script_event_arg1) {
			case 1000: {
				myself.i_ai0 = 0;
				for(i0 = 0; i0 < myself.def_count; i0++) {
					def0 = myself::GetSpawnDefine(i0);
					if( gg::IsNull(def0) == 0 ) {
						def0::Despawn();
					}
				}
				maker0 = gg::GetNpcMaker(maker_name);
				if( gg::IsNull(maker0) ) {
					gg::SendMakerScriptEvent(maker0,1000,0,0);
				}
				break;
			}
			case 1001: {
				myself.i_ai0 = 1;
				for(i0 = 0; i0 < myself.def_count; i0++) {
					def0 = myself::GetSpawnDefine(i0);
					if( gg::IsNull(def0) == 0 ) {
						i1 = ( def0.total - def0.npc_count );
						if( i1 > 0 ) {
							if( myself::AtomicIncreaseTotal(def0,i1,1) ) {
								def0::Spawn2(i1,script_event_arg2,0);
							}
						}
					}
				}
				maker0 = gg::GetNpcMaker(maker_name);
				if( gg::IsNull(maker0) ) {
					gg::SendMakerScriptEvent(maker0,1001,0,0);
				}
				break;
			}
		}
	}

}
