public static Dictionary <DamageType, float> MergeProtectionAmounts(ProtectionProperties protection)
        {
            var protectionAmounts = new Dictionary <DamageType, float>();

            for (int i = 0; i < protection.amounts.Length; ++i)
            {
                var damageType = (DamageType)i;

                if (protection.amounts[i] <= 0)
                {
                    continue;
                }

                if (protectionAmounts.ContainsKey(damageType))
                {
                    protectionAmounts[damageType] += protection.amounts[i];
                }
                else
                {
                    protectionAmounts.Add(damageType, protection.amounts[i]);
                }
            }

            return(protectionAmounts);
        }
Exemple #2
0
 public void CollectProtection(Item item, ProtectionProperties protection)
 {
     if (!(protectionProperties == null))
     {
         protection.Add(protectionProperties, ConditionProtectionScale(item));
     }
 }
 public void Add(ProtectionProperties other, float scale)
 {
     for (int index = 0; index < Mathf.Min(other.amounts.Length, this.amounts.Length); ++index)
     {
         this.amounts[index] += other.amounts[index] * scale;
     }
 }
 public void Add(ProtectionProperties other, float scale)
 {
     for (int i = 0; i < Mathf.Min((int)other.amounts.Length, (int)this.amounts.Length); i++)
     {
         ref float singlePointer = ref this.amounts[i];
         singlePointer = singlePointer + other.amounts[i] * scale;
     }
 public void CollectProtection(Item item, ProtectionProperties protection)
 {
     if (Object.op_Equality((Object)this.protectionProperties, (Object)null))
     {
         return;
     }
     protection.Add(this.protectionProperties, this.ConditionProtectionScale(item));
 }
Exemple #6
0
 public void CollectProtection(Item item, ProtectionProperties protection)
 {
     if (this.protectionProperties == null)
     {
         return;
     }
     protection.Add(this.protectionProperties, this.ConditionProtectionScale(item));
 }
Exemple #7
0
        public void DeleteProtection()
        {
            TestUtils.Upload(c_fileName, c_folderName + "/" + c_fileName);
            ProtectionProperties protectionProperties = TestUtils.SlidesApi.DeleteProtection(c_fileName, c_password, c_folderName);

            Assert.IsFalse(protectionProperties.ReadOnlyRecommended.Value);
            Assert.IsFalse(protectionProperties.IsEncrypted.Value);
            Assert.IsNull(protectionProperties.ReadPassword);
        }
Exemple #8
0
        public void ProtectOnline()
        {
            Stream document          = File.OpenRead(Path.Combine(TestUtils.TestDataPath, c_fileName));
            ProtectionProperties dto = new ProtectionProperties {
                ReadPassword = "******"
            };
            Stream outputDocument = TestUtils.SlidesApi.SetProtectionOnline(document, dto, c_password);

            Assert.AreNotEqual(document.Length, outputDocument.Length);
        }
        private void WriteDamageTypes(ProtectionProperties properties)
        {
            var damages = new Dictionary <DamageType, float>();

            for (int i = 0; i < (int)DamageType.LAST; ++i)
            {
                damages.Add((DamageType)i, properties.amounts[i]);
            }

            Debug.Log(String.Join("\n", damages.Select(d => d.Key.ToString() + ": " + d.Value).ToArray()));
        }
Exemple #10
0
        public void Protection()
        {
            TestUtils.Upload(c_fileName, c_folderName + "/" + c_fileName);
            ProtectionProperties protectionProperties = TestUtils.SlidesApi.GetProtectionProperties(c_fileName, c_password, c_folderName);
            ProtectionProperties dto = new ProtectionProperties {
                ReadOnlyRecommended = !protectionProperties.ReadOnlyRecommended
            };
            ProtectionProperties updatedProperties = TestUtils.SlidesApi.SetProtection(c_fileName, dto, c_password, c_folderName);

            Assert.AreNotEqual(protectionProperties.ReadOnlyRecommended, updatedProperties.ReadOnlyRecommended);
            Assert.AreEqual(protectionProperties.EncryptDocumentProperties, updatedProperties.EncryptDocumentProperties);
        }
Exemple #11
0
        private void OnServerInitialized()
        {
            ImmortalProtection      = ScriptableObject.CreateInstance <ProtectionProperties>();
            ImmortalProtection.name = "DroneLightsProtection";
            ImmortalProtection.Add(1);

            foreach (var entity in BaseNetworkable.serverEntities)
            {
                var drone = entity as Drone;
                if (drone == null || !IsDroneEligible(drone))
                {
                    continue;
                }

                AddOrUpdateSearchLight(drone);
            }

            Subscribe(nameof(OnEntitySpawned));
        }