源代码和类结构在2.0版中的更新 (Source Code and Class Structure Changes new in version 2.0)

总览 (Overview)

虽然大多数更改都是专门针对向后兼容性而设计的,但有些更改需要涉及到从旧代码到新代码的大量修改。这可能会导致工程的代码工作不正常,具体取决于你的更改与原始源代码的偏差程度。

准备 (Preparation)

我们有一个方便的列表,来显示本插件的v1.2版本的源代码,与当前版本之间的差异。核心更改主要适用于FPEInteractionManagerScript和FPEInventoryManagerScript 文件。但对旧的Standard Assets文件夹,以及相关的Player和Input类文件,也进行了重大更改。

注意!注意!!!
如果您修改了上一版本的原始源代码,请阅读以下内容。
译者注:
此章节暂时没有翻译。以后会补上的。


  • Pre-fixed all new Class Names with 'FPE' to prevent conflicts with other asset imports, standard assets, etc.
  • Changed all previously Standard Asset-derived classes (e.g. FirstPersonController) to have 'FPE' prefix (e.g. now FPEFirstPersonController) to prevent conflicts if Standard Assets player controls are also imported.
  • Removed flipGamepadY from MouseLook, it is now controlled through FPEInputManager class
  • Removed XSensitivity and YSensitivity from MouseLook, it is now controlled through FPEInputManager class as single LookSensitivity value
  • Changed FPEFirstPersonController variable 'enableJump' to 'jumpEnabled' and be private, but still editable in the Inspector. Same with new 'enableRun' and 'enableCrouch' variables.
  • Changed FPEFirstPersonController variable 'enableMovement' to 'movementEnabled' and be strictly private
  • Removed RigidbodyFirstPersonController and associated HeadBob from the old player controller. Existing one now incorporates required functionality.


MouseLook

In FPEInteractionManagerScript.cs, the variables zoomedMouseSensitivity and highlightedMouseSensitivity have been made private. In their place, two new variables called zoomedMouseSensitivityMultiplier and highlightedMouseSensitivityFactor have been created. On start, the old values are automatically populated with a correct value based on the multiplier and current mouse sensitivity. Every time the mouse sensitivity is changed, the function refreshAlternateMouseSensitivities() must be called to keep the "regular" sensitivity correctly aligned to the relative zoom and highlight sensitivities. See FPEGameMenu functions called "changeMouseSensitivity()" and "refreshMouseSensitivityValue()" for example code.

Mouse smoothing, Y-Axis flip, and mouse sensitivity are now fully controlled by the new FPEInputManager class.


Misc.

demoScene now has an object called FPECore which replaces all previous 'core component' requirements. TODO: docs/instructions


Player

  • Added new functionality for Run, Crouch, Jump
  • Changed the way that held objects behave. They are now made children of the player which, among other benefits, reduces 'lerp jitter' in some cases.


UI

  • Added feature-rich FPEGameMenu class and prefab that includes access to game inventory, audio diaries, and notes.
  • Added new FPEMenu class that can be used to create whatever menu you want for your game
  • Added sample FPESimpleMenu class and prefab to demonstrate how to make a very basic pause/quit menu


UI Camera

The previous FPEUICamera prefab has been removed, and the FPEInteractionManager now uses "Screen Space - Overlay" Canvas Render Mode


Controls

  • Added new "Gamepad Put In Inventory" input, mapped to 'R' on Keyboard, and 'Y' on xbox gamepad
  • Added new "Gamepad Menu" input, mapped to Tab on Keyboard, and "Start" on xbox gamepad
  • Added new "Gamepad Previous Tab" and "Gamepad Next Tab" buttons for switching game menu "tabs" from gamepad
  • Adopted more consistent buttons for gamepad so that all "select/do" actions use one button and all "back/close" actions use another button
  • Changed the UI "submit" button to be the same as the examine button to allow for easier navigation and interaction when using menus
  • Added inputs for Jump, Crouch, and Run
  • Removed legacy mapping of Left Shift as alternate "Zoom/Examine", as it is now used for Run
  • Added "Gamepad Jump", "Gamepad Crouch", and "Gamepad Run" inputs


General

  • Added all legacy and new code to a namespace called "Whilefun.FPEKit", which means all scripts that need access to First Person Exploration Kit classes need to add "using Whilefun.FPEKit;" at the top of the script.
  • Added code regions to some scripts for easier reading and navigation
  • Organized Textures folder to have sub folders for Reticles, Journal, Menu, etc.
  • Modified the Journal UI to more closely match the new menu UI, removing the close button and adding a close hint to use assigned key/button for better gamepad support. Existing closeJournal() function remains for buttons if desired.
  • Core UI (for interactions, etc.) now targets 1080p resolution by default instead of 720p. As a result, images have been adjusted, graphics refreshed, and the overall UI appears more crisp.


Put Back Type Changes

In order to support saving and loading of game data, put back locations now use a string name instead of GameObject Instance ID. This is due to the fact that saving and loading game data breaks the guarantee that a given game object will have the same instance ID across play sessions. For example, if I pick up a can of demoSoup, it may have instance ID 1. If I save the game, then reload the game, the instance ID may now be 2. The put back location needs to allow for a can of demoSoup to be put back, but can no longer rely on instance ID matching the original assigned in the inspector.

Some technical details, in case you modified this code in your project(s):

Now, internally, put back locations create a match string from the GameObject's prefab assigned in the scene editor. So for example, if you assign a demoSoup prefab called "demoSoup", "demoSoup (1)", or "demoSoup(Clone)", the matching string created will simply be "demoSoup". This means that unique put back requirements must be handled with unique prefabs. So using the "demoArtifactPickupObject" object (the gold skull cube artifact in the demo) as an example, its put back location now looks for an object called "demoArtifactPickupObject". Given that there is only ever exactly one of these in our scene, the uniqueness of the behaviour is guaranteed. It also means that saving and loading the game at any state of the "Idol Trap Sequence" in the demo will always yield a successful result, even if the player picks up and drops the idol a bunch of times before returning it to the idol "artifact missing" put back location.

Automatically generated put back locations will also continue to work as expected, and all changes to matching logic are internal to FPEPutBackScript.


Activation Type Changes

  • Enhanced FPEInteractableActivateScript to include 3 modes: Once, Every Time, and Toggle. These types all allow for other events to be fired on activation (and in the case of Toggle, deactivation). They can also optionally require the player have an inventory item in their hand or stored in their inventory. This item can be optionally consumed upon activation.
  • Updated the following demo objects from previous version: demoSwitch, demoCabinet demoUnlockableDoor (renamed to demoComplexDoor), demoIdol, demoRadioSimple, and demoRadioComplex

All of the above to use the new Activate and Pickup type features. Namely, the events available in the Inspector are now hooked up to the correct functions, rather than requiring each of these have their own Activate or Pickup type sub classes.

Note: Depending on the nature of any implemented Activate subclasses you made, you may want to use the new features as well. For example, the demoUnlockableDoor was changed from having one large function that talked to InventoryManager in code, it now uses two smaller specific functions: "attemptDoor()" and "cardError()". These functions are assigned in the Inspector for Activation and Activation Failure, respectively. Inventory requirements are now handled in the Inspector too, with much better granularity. In this case, the player must have 1 keycard in their inventory, and they get to keep it after they open the door. Changing this to require the keycard is in the player's hand, and that they lose it when they use it would be as simple as checking two checkboxes in the Inspector.


Audio Diaries

  • Added option to require manual playback (look at object, press 'Play' via interact button)
  • Added additional optional "during playback" interaction string, so that you can indicate to the player near the reticle that the tape is being played right now
  • Audio Diaries can now be added to the inventory when played, allowing for player to re-play previously heard diaries if desired.
  • All audio diary AudioClip files must now be located in the "Resources/AudioDiaryAudioClips" folder so they can be restored from saved game data. To change the sub folder, you must rename the existing folder and update the name inside the "FPEAudioDiarySaveData" class in FPESaveDataTypes.cs script file.


Audio Diary Entry

  • Added new "FPE Passive Audio Diary" that can be attached to any Interactable object and "collected" as part of base interaction.
  • Existing Audio Diary type will remain, and can be used for more elaborate diary content, with support for events, custome interaction strings, and so on.
  • Note: Passive audio diaries that are attached to regular audio diaries will be ignored.


Note Entries

  • Added new "FPE Attached Note" component that allows for any Interactable object to have a note entry associated with it. The note is "collected" and added to the inventory automatically when the interaction takes place.

results matching ""

    No results matching ""