Sajgoniarz

Untitled

Jun 25th, 2021 (edited)
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.80 KB | None | 0 0
  1. //Jak robisz mała ilość tych extensionów to robisz sobie klase na wszystkie, lub
  2. public static class ExtensionMethods {}
  3. //dedykowane dla jakiejs klasy skads
  4. public static ClassNameExtension {}
  5. // tudziez idziesz na latwizne i jak robisz extensiony do wlasnych klas/whatever to mozesz w tym samym pliku
  6. namespace Dupa
  7. {
  8.     public enum PlayerMovementState
  9.     {
  10.         Walking,
  11.         Flying,
  12.         Sliding,
  13.         Swimming,
  14.         Standing
  15.     }
  16.  
  17.     public static class PlayerMovementStateExtensions
  18.     {
  19.         public static float GetSpeed(this PlayerMovementState movementState)
  20.         {
  21.             // mozesz zrobic Dictionary<PlayerMovementState, float> jak masz tego sporo
  22.             switch(movementState)
  23.             {
  24.                 case PlayerMovementState.Walking:
  25.                     return 0.7f;
  26.                 case PlayerMovementState.Flying:
  27.                     return 5f;
  28.                 //...
  29.             }
  30.         }
  31.     }
  32. }
Add Comment
Please, Sign In to add comment