| 
									
										
										
										
											2021-07-17 12:07:45 -04:00
										 |  |  | import logging | 
					
						
							| 
									
										
										
										
											2021-10-05 23:07:03 +02:00
										 |  |  | import typing | 
					
						
							| 
									
										
										
										
											2021-07-17 12:07:45 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | logger = logging.getLogger("Subnautica") | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | from .Locations import lookup_name_to_id as locations_lookup_name_to_id | 
					
						
							| 
									
										
										
										
											2021-09-17 04:32:36 +02:00
										 |  |  | from .Items import item_table, lookup_name_to_item, advancement_item_names | 
					
						
							| 
									
										
										
										
											2021-07-17 12:07:45 -04:00
										 |  |  | from .Items import lookup_name_to_id as items_lookup_name_to_id | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | from .Regions import create_regions | 
					
						
							|  |  |  | from .Rules import set_rules | 
					
						
							| 
									
										
										
										
											2021-09-17 04:32:36 +02:00
										 |  |  | from .Options import options | 
					
						
							| 
									
										
										
										
											2021-07-17 12:07:45 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-11 13:05:53 -05:00
										 |  |  | from BaseClasses import Region, Entrance, Location, MultiWorld, Item, Tutorial | 
					
						
							|  |  |  | from ..AutoWorld import World, WebWorld | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class SubnaticaWeb(WebWorld): | 
					
						
							|  |  |  |     tutorials = [Tutorial( | 
					
						
							|  |  |  |         "Multiworld Setup Guide", | 
					
						
							|  |  |  |         "A guide to setting up the Subnautica randomizer connected to an Archipelago Multiworld", | 
					
						
							|  |  |  |         "English", | 
					
						
							|  |  |  |         "setup_en.md", | 
					
						
							|  |  |  |         "setup/en", | 
					
						
							|  |  |  |         ["Berserker"] | 
					
						
							|  |  |  |     )] | 
					
						
							| 
									
										
										
										
											2021-07-17 12:07:45 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class SubnauticaWorld(World): | 
					
						
							| 
									
										
										
										
											2021-08-31 17:28:46 -04:00
										 |  |  |     """
 | 
					
						
							|  |  |  |     Subnautica is an undersea exploration game. Stranded on an alien world, you become infected by | 
					
						
							|  |  |  |     an unknown bacteria. The planet's automatic quarantine will shoot you down if you try to leave. | 
					
						
							|  |  |  |     You must find a cure for yourself, build an escape rocket, and leave the planet. | 
					
						
							|  |  |  |     """
 | 
					
						
							| 
									
										
										
										
											2021-07-17 12:07:45 -04:00
										 |  |  |     game: str = "Subnautica" | 
					
						
							| 
									
										
										
										
											2022-05-11 13:05:53 -05:00
										 |  |  |     web = SubnaticaWeb() | 
					
						
							| 
									
										
										
										
											2021-07-17 12:07:45 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |     item_name_to_id = items_lookup_name_to_id | 
					
						
							|  |  |  |     location_name_to_id = locations_lookup_name_to_id | 
					
						
							| 
									
										
										
										
											2021-09-17 04:32:36 +02:00
										 |  |  |     options = options | 
					
						
							| 
									
										
										
										
											2021-07-17 12:07:45 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-05 23:07:03 +02:00
										 |  |  |     data_version = 2 | 
					
						
							| 
									
										
										
										
											2022-04-08 11:16:36 +02:00
										 |  |  |     required_client_version = (0, 1, 9) | 
					
						
							| 
									
										
										
										
											2021-10-05 23:07:03 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-07-17 12:07:45 -04:00
										 |  |  |     def generate_basic(self): | 
					
						
							|  |  |  |         # Link regions | 
					
						
							|  |  |  |         self.world.get_entrance('Lifepod 5', self.player).connect(self.world.get_region('Planet 4546B', self.player)) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         # Generate item pool | 
					
						
							|  |  |  |         pool = [] | 
					
						
							|  |  |  |         neptune_launch_platform = None | 
					
						
							| 
									
										
										
										
											2021-09-17 04:32:36 +02:00
										 |  |  |         extras = 0 | 
					
						
							| 
									
										
										
										
											2021-10-05 23:07:03 +02:00
										 |  |  |         valuable = self.world.item_pool[self.player] == "valuable" | 
					
						
							| 
									
										
										
										
											2021-07-17 12:07:45 -04:00
										 |  |  |         for item in item_table: | 
					
						
							|  |  |  |             for i in range(item["count"]): | 
					
						
							| 
									
										
										
										
											2021-09-01 16:46:44 +02:00
										 |  |  |                 subnautica_item = self.create_item(item["name"]) | 
					
						
							| 
									
										
										
										
											2021-07-17 12:07:45 -04:00
										 |  |  |                 if item["name"] == "Neptune Launch Platform": | 
					
						
							|  |  |  |                     neptune_launch_platform = subnautica_item | 
					
						
							| 
									
										
										
										
											2021-10-05 23:07:03 +02:00
										 |  |  |                 elif valuable and not item["progression"]: | 
					
						
							| 
									
										
										
										
											2021-09-17 04:32:36 +02:00
										 |  |  |                     self.world.push_precollected(subnautica_item) | 
					
						
							|  |  |  |                     extras += 1 | 
					
						
							| 
									
										
										
										
											2021-07-17 12:07:45 -04:00
										 |  |  |                 else: | 
					
						
							|  |  |  |                     pool.append(subnautica_item) | 
					
						
							| 
									
										
										
										
											2021-10-05 23:07:03 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-17 04:32:36 +02:00
										 |  |  |         for item_name in self.world.random.choices(sorted(advancement_item_names - {"Neptune Launch Platform"}), | 
					
						
							|  |  |  |                                                    k=extras): | 
					
						
							| 
									
										
										
										
											2021-10-05 23:07:03 +02:00
										 |  |  |             item = self.create_item(item_name) | 
					
						
							|  |  |  |             item.advancement = False  # as it's an extra, just fast-fill it somewhere | 
					
						
							|  |  |  |             pool.append(item) | 
					
						
							| 
									
										
										
										
											2021-09-17 04:32:36 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-07-17 12:07:45 -04:00
										 |  |  |         self.world.itempool += pool | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         # Victory item | 
					
						
							| 
									
										
										
										
											2021-09-01 16:46:44 +02:00
										 |  |  |         self.world.get_location("Aurora - Captain Data Terminal", self.player).place_locked_item( | 
					
						
							|  |  |  |             neptune_launch_platform) | 
					
						
							|  |  |  |         self.world.get_location("Neptune Launch", self.player).place_locked_item( | 
					
						
							|  |  |  |             SubnauticaItem("Victory", True, None, player=self.player)) | 
					
						
							| 
									
										
										
										
											2021-07-17 12:07:45 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |     def set_rules(self): | 
					
						
							|  |  |  |         set_rules(self.world, self.player) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def create_regions(self): | 
					
						
							|  |  |  |         create_regions(self.world, self.player) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-31 17:28:46 -04:00
										 |  |  |     def fill_slot_data(self): | 
					
						
							| 
									
										
										
										
											2021-07-17 12:07:45 -04:00
										 |  |  |         slot_data = {} | 
					
						
							|  |  |  |         return slot_data | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-01 16:46:44 +02:00
										 |  |  |     def create_item(self, name: str) -> Item: | 
					
						
							|  |  |  |         item = lookup_name_to_item[name] | 
					
						
							|  |  |  |         return SubnauticaItem(name, item["progression"], item["id"], player=self.player) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-07-17 12:07:45 -04:00
										 |  |  | def create_region(world: MultiWorld, player: int, name: str, locations=None, exits=None): | 
					
						
							|  |  |  |     ret = Region(name, None, name, player) | 
					
						
							|  |  |  |     ret.world = world | 
					
						
							|  |  |  |     if locations: | 
					
						
							|  |  |  |         for location in locations: | 
					
						
							|  |  |  |             loc_id = locations_lookup_name_to_id.get(location, 0) | 
					
						
							|  |  |  |             location = SubnauticaLocation(player, location, loc_id, ret) | 
					
						
							|  |  |  |             ret.locations.append(location) | 
					
						
							|  |  |  |     if exits: | 
					
						
							|  |  |  |         for exit in exits: | 
					
						
							|  |  |  |             ret.exits.append(Entrance(player, exit, ret)) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return ret | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class SubnauticaLocation(Location): | 
					
						
							|  |  |  |     game: str = "Subnautica" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class SubnauticaItem(Item): | 
					
						
							|  |  |  |     game = "Subnautica" |