Exemple #1
0
 private DeviceData(DeviceSerializable serializable, Database database)
 {
     ItemId                   = new ItemId <DeviceData>(serializable.Id, serializable.FileName);
     DeviceClass              = serializable.DeviceClass;
     EnergyConsumption        = new NumericValue <float>(serializable.EnergyConsumption, 0f, 1000f);
     PassiveEnergyConsumption = new NumericValue <float>(serializable.PassiveEnergyConsumption, 0f, 1000f);
     Power             = new NumericValue <float>(serializable.Power, 0f, 1000f);
     Range             = new NumericValue <float>(serializable.Range, 0f, 1000f);
     Size              = new NumericValue <float>(serializable.Size, 0f, 1000f);
     Cooldown          = new NumericValue <float>(serializable.Cooldown, 0f, 1000f);
     Offset            = serializable.Offset;
     ActivationType    = serializable.ActivationType;
     Color             = Utils.ColorUtils.ColorFromString(serializable.Color);
     Sound             = new AudioClipId(serializable.Sound);
     EffectPrefab      = serializable.EffectPrefab;
     ObjectPrefab      = serializable.ObjectPrefab;
     ControlButtonIcon = serializable.ControlButtonIcon;
 }
 public void Save(DeviceSerializable serializable)
 {
     serializable.DeviceClass              = DeviceClass;
     serializable.EnergyConsumption        = EnergyConsumption.Value;
     serializable.PassiveEnergyConsumption = PassiveEnergyConsumption.Value;
     serializable.Power             = Power.Value;
     serializable.Range             = Range.Value;
     serializable.Size              = Size.Value;
     serializable.Cooldown          = Cooldown.Value;
     serializable.Lifetime          = Lifetime.Value;
     serializable.Offset            = Offset;
     serializable.ActivationType    = ActivationType;
     serializable.Color             = Helpers.ColorToString(Color);
     serializable.Sound             = Sound;
     serializable.EffectPrefab      = EffectPrefab;
     serializable.ObjectPrefab      = ObjectPrefab;
     serializable.ControlButtonIcon = ControlButtonIcon;
     OnDataSerialized(ref serializable);
 }
Exemple #3
0
        public DeviceStats(DeviceSerializable serializable, Database.Loader loader)
        {
            DeviceClass              = serializable.DeviceClass;
            EnergyConsumption        = UnityEngine.Mathf.Clamp(serializable.EnergyConsumption, 0f, 1E+09f);
            PassiveEnergyConsumption = UnityEngine.Mathf.Clamp(serializable.PassiveEnergyConsumption, 0f, 1E+09f);
            Power             = UnityEngine.Mathf.Clamp(serializable.Power, 0f, 1000f);
            Range             = UnityEngine.Mathf.Clamp(serializable.Range, 0f, 1000f);
            Size              = UnityEngine.Mathf.Clamp(serializable.Size, 0f, 1000f);
            Cooldown          = UnityEngine.Mathf.Clamp(serializable.Cooldown, 0f, 1000f);
            Lifetime          = UnityEngine.Mathf.Clamp(serializable.Lifetime, 0f, 1000f);
            Offset            = serializable.Offset;
            ActivationType    = serializable.ActivationType;
            Color             = new ColorData(serializable.Color);
            Sound             = new AudioClipId(serializable.Sound);
            EffectPrefab      = new PrefabId(serializable.EffectPrefab, PrefabId.Type.Effect);
            ObjectPrefab      = new PrefabId(serializable.ObjectPrefab, PrefabId.Type.Object);
            ControlButtonIcon = new SpriteId(serializable.ControlButtonIcon, SpriteId.Type.ActionButton);

            OnDataDeserialized(serializable, loader);
        }
        public Device(DeviceSerializable serializable, Database database)
        {
            Id                       = new ItemId <Device>(serializable.Id, serializable.FileName);
            DeviceClass              = serializable.DeviceClass;
            EnergyConsumption        = new NumericValue <float>(serializable.EnergyConsumption, 0f, 1E+09f);
            PassiveEnergyConsumption = new NumericValue <float>(serializable.PassiveEnergyConsumption, 0f, 1E+09f);
            Power                    = new NumericValue <float>(serializable.Power, 0f, 1000f);
            Range                    = new NumericValue <float>(serializable.Range, 0f, 1000f);
            Size                     = new NumericValue <float>(serializable.Size, 0f, 1000f);
            Cooldown                 = new NumericValue <float>(serializable.Cooldown, 0f, 1000f);
            Lifetime                 = new NumericValue <float>(serializable.Lifetime, 0f, 1000f);
            Offset                   = serializable.Offset;
            ActivationType           = serializable.ActivationType;
            Color                    = Helpers.ColorFromString(serializable.Color);
            Sound                    = serializable.Sound;
            EffectPrefab             = serializable.EffectPrefab;
            ObjectPrefab             = serializable.ObjectPrefab;
            ControlButtonIcon        = serializable.ControlButtonIcon;

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

            serializable.Id                       = ItemId.Id;
            serializable.FileName                 = ItemId.Name;
            serializable.ItemType                 = (int)ItemType.Device;
            serializable.DeviceClass              = DeviceClass;
            serializable.EnergyConsumption        = EnergyConsumption.Value;
            serializable.PassiveEnergyConsumption = PassiveEnergyConsumption.Value;
            serializable.Power                    = Power.Value;
            serializable.Range                    = Range.Value;
            serializable.Size                     = Size.Value;
            serializable.Cooldown                 = Cooldown.Value;
            serializable.Offset                   = Offset;
            serializable.ActivationType           = ActivationType;
            serializable.Color                    = Utils.ColorUtils.ColorToString(Color);
            serializable.Sound                    = Sound.ToString();
            serializable.EffectPrefab             = EffectPrefab;
            serializable.ObjectPrefab             = ObjectPrefab;
            serializable.ControlButtonIcon        = ControlButtonIcon;
            return(serializable);
        }
Exemple #6
0
 partial void OnDataDeserialized(DeviceSerializable serializable, Database.Loader loader);
Exemple #7
0
 private Device(DeviceSerializable serializable, Database.Loader loader)
 {
     Id = new ItemId <Device>(serializable.Id);
     loader.AddDevice(serializable.Id, this);
     Stats = new DeviceStats(serializable, loader);
 }
Exemple #8
0
 public static Device Create(DeviceSerializable serializable, Database.Loader loader)
 {
     return(new Device(serializable, loader));
 }
 partial void OnDataSerialized(ref DeviceSerializable serializable);
Exemple #10
0
 partial void OnDataDeserialized(DeviceSerializable serializable, Database database);
Exemple #11
0
 public static DeviceData Deserialize(DeviceSerializable serializable, Database database)
 {
     return(new DeviceData(serializable, database));
 }