Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes/Refactoring #172

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open

Fixes/Refactoring #172

wants to merge 15 commits into from

Conversation

WhiteSpike
Copy link

@WhiteSpike WhiteSpike commented Feb 6, 2025

LoadAllBundlesRequest: Changed LoadAllBundles method signature to accept as parameter the collection of strings which represent the files retrieved from the Directory.GetFiles callback, reducing the number of callbacks of Directory.GetFiles from two to one.

OnInitialBundlesProcessed: Fixed the loop always skipping the remaining elements of newGroup.GetAssetBundleInfos() after the first iteration.

RegisterExtendedMod: Changed the loop iteration to stop once it has a found matching extended mod and used switch case statement for extendedMod.ModMergeSetting to know what needs to be checked for matching.

TryGetExtendedDungeonFlow: Used switch case statement to define what collection to use for iteration and stopped the iteration once an extended dungeonflow has been found.

InjectCustomItemsIntoLevelViaDynamicRarity: Loop iteration on extendedLevel.SelectableLevel.spawnableScrap is stopped once it has found an already injected item.

TryGetExtendedLevel: Used switch case statement to define the collection for iteration and stopped the iteration loop once an extended level has been found.

GetExtendedLevel: Stopped the iteration loop once an extended level has been found.

FilterMoonsCataloguePage: Merged two iterations into one, used switch case statement to define the criteria to wether it is shown or not in the catalogue. Also changed the filter to include the check of wether the moon is hidden or not (any defined filter would ignore the route hidden check)

GetMoonCatalogDisplayListings: Removed if statement related to string replacement as it was both not being used in the end result of the message and it didn't seem to produce the desired result as it would make the catalogue unreadable. Changed string construction to use interpolation instead for easier understanding. Used switch case statement to define the contents of tagString

NetworkRegisterCustomContent: Added null check on BuyableVehicle.secondaryPrefab to avoid registering a null prefab. This is safe to do because ItemDropship checks if the selected BuyableVehicle has a non-null secondaryPrefab to spawn it in DeliverVehicleOnServer. (fixes #173)

  • MatchingProperties takes a type parameter which is ExtendedContent. This means:

    • LevelMatchingProperties is a MatchingProperties<ExtendedLevel>
    • DungeonMatchingProperties is a MatchingProperties<ExtendedDungeonFlow>
  • Turned GetDynamicRarity() to virtual which takes as parameter the extended content. This is then overriden with respective derived classes to include additional rarities.

  • Changed RegisterExtendedContent to not have a series of if statements checking the explicit type of the ExtendedContent parameter and instead just made a Register method which is overriden by all its derived classes and it calls this method instead, removing the need for explicit type checks.

  • Same logic with UnregisterExtendedContent

- After later reading ``LoadAllBundles`` and seeing that the ``GetFiles`` callback is exactly the same as the one prior to calling the method, I just made the method receive it as argument, turning two callbacks to one.
- Loop iteration now uses switch case statement instead of explicit value checks in the mod's merge settings.
- Loop iteration stops once a matching extended mod is found.
- Changed series of if statements to switch case statement to pick the collection.
- Loop iteration is stopped once a dungeon flow is found.
- Changed check in if statement to reduce identation for readibility only.
- Loop iteration in ``extendedLevel.SelectableLevel.spawnableScrap`` is stopped once it has found an already injected item.
- Changed series of if statements to switch case statement to pick the collection.
- Loop iteration is stopped once a dungeon flow is found.
- Loop iteration stops once a level is found
- Changed from two iterations to one.
- Changed series of if statements to switch case statement.
- Changed logic of removing the level to include the check of the route being hidden (previously it would only consider it if there was no filter selected, I don't think a filter should decide to make this visible suddenly)
- Removed if statement related to replacing the content between the last newline and to the end of the string with nothing.
  - Tried making it actually replace the string but it didn't produce a readable result so I don't believe the logic was correct either.
- Changed string construction to use interpolation, more readable and less confusing.
- Used switch case statement to define the contents of ``tagString``
- Removed the ``ServerRpc`` attribute from the method. The reasoning being that this method, while it is meant to be executed only by the server, it doesn't seem desired to be able to be called by clients as all callbacks to this method has either performed a ``IsServer`` check or it is called inside a ``ServerRpc`` attributed method.

I believe this would solve the issue with people failing to leave the lobby due to this method trying to be called on clients while they are leaving at the same time.
- Added null check on ``BuyableVehicle.secondaryPrefab`` to avoid registering a null prefab. This is safe to do because ``ItemDropship`` checks if the selected ``BuyableVehicle`` has a non-null ``secondaryPrefab`` to spawn it in ``DeliverVehicleOnServer``.
- ``MatchingProperties`` takes a type parameter which is ``ExtendedContent``. This means:
  - ``LevelMatchingProperties`` is a ``MatchingProperties<ExtendedLevel>``
  - ``DungeonMatchingProperties`` is a ``MatchingProperties<ExtendedDungeonFlow>``
- Turned ``GetDynamicRarity()`` to virtual which takes as parameter the extended content. This is then overriden with respective derived classes to include additional rarities.

- Changed ``RegisterExtendedContent`` to not have a series of if statements checking the explicit type of the ``ExtendedContent`` parameter and instead just made a ``Register`` method which is overriden by all its derived classes and it calls this method instead, removing the need for explicit type checks.
- Same logic with ``UnregisterExtendedContent``
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Issue,1.4.8] ExtendedBuyableVehicle throws NullReferenceException if secondaryPrefab is left blank.
1 participant