Exemple #1
0
 private BulletBodyData(BulletBodySerializable serializable, Database database)
 {
     Type          = serializable.Type;
     Size          = new NumericValue <float>(serializable.Size, 0f, 1000f);
     Velocity      = new NumericValue <float>(serializable.Velocity, 0f, 1000f);
     Range         = new NumericValue <float>(serializable.Range, 0f, 1000f);
     Lifetime      = new NumericValue <float>(serializable.Lifetime, 0f, 1000f);
     Weight        = new NumericValue <float>(serializable.Weight, 0f, 1000f);
     HitPoints     = new NumericValue <int>(serializable.HitPoints, 0, 1000);
     Color         = Utils.ColorUtils.ColorFromString(serializable.Color);
     BulletPrefab  = database.GetBulletPrefabId(serializable.BulletPrefab);
     EnergyCost    = new NumericValue <float>(serializable.EnergyCost, 0f, 1000f);
     CanBeDisarmed = serializable.CanBeDisarmed;
     FriendlyFire  = serializable.FriendlyFire;
 }
Exemple #2
0
        private BulletBody(BulletBodySerializable serializable, Database.Loader loader)
        {
            Type          = serializable.Type;
            Size          = UnityEngine.Mathf.Clamp(serializable.Size, 0f, 1000f);
            Velocity      = UnityEngine.Mathf.Clamp(serializable.Velocity, 0f, 1000f);
            Range         = UnityEngine.Mathf.Clamp(serializable.Range, 0f, 1E+09f);
            Lifetime      = UnityEngine.Mathf.Clamp(serializable.Lifetime, 0f, 1E+09f);
            Weight        = UnityEngine.Mathf.Clamp(serializable.Weight, 0f, 1E+09f);
            HitPoints     = UnityEngine.Mathf.Clamp(serializable.HitPoints, 0, 999999999);
            Color         = new ColorData(serializable.Color);
            BulletPrefab  = loader.GetBulletPrefab(new ItemId <BulletPrefab>(serializable.BulletPrefab));
            EnergyCost    = UnityEngine.Mathf.Clamp(serializable.EnergyCost, 0f, 1E+09f);
            CanBeDisarmed = serializable.CanBeDisarmed;
            FriendlyFire  = serializable.FriendlyFire;

            OnDataDeserialized(serializable, loader);
        }
Exemple #3
0
        public BulletBody(BulletBodySerializable serializable, Database database)
        {
            Type          = serializable.Type;
            Size          = new NumericValue <float>(serializable.Size, 0f, 1000f);
            Velocity      = new NumericValue <float>(serializable.Velocity, 0f, 1000f);
            Range         = new NumericValue <float>(serializable.Range, 0f, 1E+09f);
            Lifetime      = new NumericValue <float>(serializable.Lifetime, 0f, 1E+09f);
            Weight        = new NumericValue <float>(serializable.Weight, 0f, 1E+09f);
            HitPoints     = new NumericValue <int>(serializable.HitPoints, 0, 999999999);
            Color         = Helpers.ColorFromString(serializable.Color);
            BulletPrefab  = database.GetBulletPrefabId(serializable.BulletPrefab);
            EnergyCost    = new NumericValue <float>(serializable.EnergyCost, 0f, 1E+09f);
            CanBeDisarmed = serializable.CanBeDisarmed;
            FriendlyFire  = serializable.FriendlyFire;

            OnDataDeserialized(serializable, database);
        }
Exemple #4
0
        public BulletBodySerializable Serialize()
        {
            var serializable = new BulletBodySerializable();

            serializable.Type          = Type;
            serializable.Size          = Size.Value;
            serializable.Velocity      = Velocity.Value;
            serializable.Range         = Range.Value;
            serializable.Lifetime      = Lifetime.Value;
            serializable.Weight        = Weight.Value;
            serializable.HitPoints     = HitPoints.Value;
            serializable.Color         = Utils.ColorUtils.ColorToString(Color);
            serializable.BulletPrefab  = BulletPrefab.Id;
            serializable.EnergyCost    = EnergyCost.Value;
            serializable.CanBeDisarmed = CanBeDisarmed;
            serializable.FriendlyFire  = FriendlyFire;
            return(serializable);
        }
Exemple #5
0
 public static BulletBody Create(BulletBodySerializable serializable, Database.Loader loader)
 {
     return(new BulletBody(serializable, loader));
 }
Exemple #6
0
 partial void OnDataDeserialized(BulletBodySerializable serializable, Database.Loader loader);
Exemple #7
0
 partial void OnDataSerialized(ref BulletBodySerializable serializable);
Exemple #8
0
 partial void OnDataDeserialized(BulletBodySerializable serializable, Database database);
Exemple #9
0
 public static BulletBodyData Deserialize(BulletBodySerializable serializable, Database database)
 {
     return(new BulletBodyData(serializable, database));
 }