全站通知:

Modding/Coding standard

阅读

    

2023-12-14更新

    

最新编辑:丸丸辣

阅读:

  

更新日期:2023-12-14

  

最新编辑:丸丸辣

来自UnturnedWIKI_BWIKI_哔哩哔哩
跳到导航 跳到搜索

模板:Guide

To keep things consistent with UE4 and Unturned II your code should adhere to Epic's Coding Standard wherever possible. Here are some additional code styles to follow that aren't covered in that article at the time of writing:

Class Layout

Classes should first be organized by visibility:

  1. public
  2. protected
  3. private

Within each category members should be sorted by:

  1. Constructors
  2. Properties
  3. Operators
  4. Functions
  5. Interfaces

Delegate Naming

Delegate names should be past tense and suffixed with Signature e.g. FItemAddedSignature. Event dispatchers should be prefixed with On and functions bound to them prefixed with Handle. For example HandleItemAdded would be bound to OnItemAdded.

Documentation

Functions should be documented for doxygen in this format:

/**
 * Explain what the method does.
 * @param NumAttempts - Explain this parameter.
 * @return Was the attempt succesful? Explain the returned value.
 */
UFUNCTION(BlueprintCallable)
bool TryToDoSomething(int32 NumAttempts);

Parameter Naming

Inputs should be prefixed with "In" and outputs with "Out". The exception is setter functions in which case "New" should be prefixed. For example:

bool DoSomething(UPARAM(Ref) const FInputData& InData, FOutputData& OutData);
UStaticMesh* Mesh;
void SetMesh(UStaticMesh* NewMesh);

模板:Navbox content (U4)