Advertisement
Guest User

ProtoBuf DataModel Example Project

a guest
Nov 4th, 2012
542
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.29 KB | None | 0 0
  1. using ProtoBuf;
  2. using System;
  3. using System.Collections.Generic;
  4.  
  5. namespace DataModels
  6. {
  7.     [ProtoContract]
  8.     public class EntityState
  9.     {
  10.         [ProtoMember(1)]
  11.         public int id;
  12.         [ProtoMember(2)]
  13.         public string name;
  14.         [ProtoMember(3)]
  15.         public float hp;
  16.         [ProtoMember(4)]
  17.         public MyVector3 position;
  18.         [ProtoMember(5)]
  19.         public MyQuaternion rotation;
  20.     }
  21.  
  22.     [ProtoContract]
  23.     public class EntityStateList
  24.     {
  25.         [ProtoMember(1)]
  26.         public Dictionary<int, EntityState> serializableItems;
  27.     }
  28.  
  29.     [ProtoContract]
  30.     public class MyVector3
  31.     {
  32.         [ProtoMember(1)]
  33.         public float x;
  34.         [ProtoMember(2)]
  35.         public float y;
  36.         [ProtoMember(3)]
  37.         public float z;
  38.  
  39.         public MyVector3()
  40.         {
  41.             this.x = 0f;
  42.             this.y = 0f;
  43.             this.z = 0f;
  44.         }
  45.  
  46.         public MyVector3(float x, float y, float z)
  47.         {
  48.             this.x = x;
  49.             this.y = y;
  50.             this.z = z;
  51.         }
  52.     }
  53.  
  54.     [ProtoContract]
  55.     public class MyQuaternion
  56.     {
  57.         [ProtoMember(1)]
  58.         public float x;
  59.         [ProtoMember(2)]
  60.         public float y;
  61.         [ProtoMember(3)]
  62.         public float z;
  63.         [ProtoMember(4)]
  64.         public float w;
  65.  
  66.         public MyQuaternion()
  67.         {
  68.             this.x = 0f;
  69.             this.y = 0f;
  70.             this.z = 0f;
  71.             this.w = 0f;
  72.         }
  73.  
  74.         public MyQuaternion(float x, float y, float z, float w)
  75.         {
  76.             this.x = x;
  77.             this.y = y;
  78.             this.z = z;
  79.             this.w = w;
  80.         }
  81.     }
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement