Advertisement
Guest User

Untitled

a guest
Sep 10th, 2019
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1. public abstract class ReceiveableMonobehaviour : RegisterableMonobehaviour {
  2.  
  3. /// <summary>
  4. /// Should return the accepted CMD for packets.
  5. /// </summary>
  6. /// <returns></returns>
  7. protected virtual String validCMD() { return "null"; }
  8.  
  9. /// <summary>
  10. /// Should return the valid message/key in the receiving packet.
  11. /// </summary>
  12. /// <returns></returns>
  13. protected virtual String validMessage() { return "null"; }
  14. }
  15.  
  16.  
  17.  
  18.  
  19. public abstract class MultiReceivableMonobehaviour : ReceiveableMonobehaviour {
  20.  
  21.  
  22.  
  23. /// <summary>
  24. /// This method overrides the original Receiver.received(); method to make it execute the actions instead of the process method.
  25. /// </summary>
  26. /// <param name="cmd"></param>
  27. /// <param name="msg"></param>
  28. /// <param name="packet"></param>
  29. protected override void received(String cmd, ISFSObject packet) {
  30.  
  31. UnityEngine.Debug.Log("<INCOMING : CMD -> "+cmd+" CMD 2 -> "+validCMD()+ " Packet -> "+inPacket(packet));
  32.  
  33. if (!validCMD().Equals(cmd)) return;
  34. if (!inPacket(packet)) return;
  35.  
  36. string msg = getFromPacket(packet);
  37.  
  38. if (bypass(msg)) {
  39.  
  40. // DO Stuff
  41. }
  42.  
  43. // DO OTHER STUFF
  44. }
  45.  
  46. protected override string validMessage() { throw new System.NotImplementedException(); }
  47. }
  48.  
  49.  
  50.  
  51. public abstract class GameScreen : MultiReceivableMonobehaviour, Transferable { // MORE STUFF }
  52.  
  53. public class LeaderboardsScreen : GameScreen {
  54.  
  55. // THIS never gets overriden somehow... calling this.received(cmd, packet) calls validCMD(); which return "null"...
  56. protected override String validCMD() { return "LeaderboardManager_Fire"; }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement