コード例 #1
0
 public bool Any()
 {
     for (int i = 0; i < 3; i++)
     {
         ResourceDispenser.GatherPropertyEntry fromIndex = this.GetFromIndex(i);
         if (fromIndex.gatherDamage > 0f || fromIndex.conditionLost > 0f)
         {
             return(true);
         }
     }
     return(false);
 }
コード例 #2
0
 public bool Any()
 {
     for (int index = 0; index < 3; ++index)
     {
         ResourceDispenser.GatherPropertyEntry fromIndex = this.GetFromIndex(index);
         if ((double)fromIndex.gatherDamage > 0.0 || (double)fromIndex.conditionLost > 0.0)
         {
             return(true);
         }
     }
     return(false);
 }
コード例 #3
0
        public float GetProficiency()
        {
            float single = 0f;

            for (int i = 0; i < 3; i++)
            {
                ResourceDispenser.GatherPropertyEntry fromIndex = this.GetFromIndex(i);
                float single1 = fromIndex.gatherDamage * fromIndex.destroyFraction;
                if (single1 > 0f)
                {
                    single = single + fromIndex.gatherDamage / single1;
                }
            }
            return(single);
        }
コード例 #4
0
        public float GetProficiency()
        {
            float num1 = 0.0f;

            for (int index = 0; index < 3; ++index)
            {
                ResourceDispenser.GatherPropertyEntry fromIndex = this.GetFromIndex(index);
                float num2 = fromIndex.gatherDamage * fromIndex.destroyFraction;
                if ((double)num2 > 0.0)
                {
                    num1 += fromIndex.gatherDamage / num2;
                }
            }
            return(num1);
        }
コード例 #5
0
    public void DoGather(HitInfo info)
    {
        BaseMelee component;

        if (!base.baseEntity.isServer)
        {
            return;
        }
        if (!info.CanGather || info.DidGather)
        {
            return;
        }
        if (this.gatherType == ResourceDispenser.GatherType.UNSET)
        {
            Debug.LogWarning(string.Concat("Object :", base.gameObject.name, ": has unset gathertype!"));
            return;
        }
        float single  = 0f;
        float single1 = 0f;

        if (info.Weapon == null)
        {
            component = null;
        }
        else
        {
            component = info.Weapon.GetComponent <BaseMelee>();
        }
        BaseMelee baseMelee = component;

        if (baseMelee == null)
        {
            single  = info.damageTypes.Total();
            single1 = 0.5f;
        }
        else
        {
            ResourceDispenser.GatherPropertyEntry gatherInfoFromIndex = baseMelee.GetGatherInfoFromIndex(this.gatherType);
            single  = gatherInfoFromIndex.gatherDamage * info.gatherScale;
            single1 = gatherInfoFromIndex.destroyFraction;
            if (single == 0f)
            {
                return;
            }
            baseMelee.SendPunch((new Vector3(UnityEngine.Random.Range(0.5f, 1f), UnityEngine.Random.Range(-0.25f, -0.5f), 0f) * -30f) * (gatherInfoFromIndex.conditionLost / 6f), 0.05f);
            baseMelee.LoseCondition(gatherInfoFromIndex.conditionLost);
            if (!baseMelee.IsValid() || baseMelee.IsBroken())
            {
                return;
            }
            info.DidGather = true;
        }
        float single2 = this.fractionRemaining;

        this.GiveResources(info.Initiator, single, single1, info.Weapon);
        this.UpdateFraction();
        float single3 = 0f;

        if (this.fractionRemaining > 0f)
        {
            single3 = (single2 - this.fractionRemaining) * base.baseEntity.MaxHealth();
        }
        else
        {
            single3 = base.baseEntity.MaxHealth();
            if (info.DidGather && single1 < this.maxDestroyFractionForFinishBonus)
            {
                this.AssignFinishBonus(info.InitiatorPlayer, 1f - single1);
            }
        }
        HitInfo hitInfo = new HitInfo(info.Initiator, base.baseEntity, DamageType.Generic, single3, base.transform.position)
        {
            gatherScale = 0f,
            PointStart  = info.PointStart,
            PointEnd    = info.PointEnd
        };

        base.baseEntity.OnAttacked(hitInfo);
    }
コード例 #6
0
 private void UpdateGatherPropertyEntry(ResourceDispenser.GatherPropertyEntry entry, JSONObject obj)
 {
     entry.conditionLost   = obj.GetFloat("conditionLost", 0);
     entry.destroyFraction = obj.GetFloat("destroyFraction", 0);
     entry.gatherDamage    = obj.GetFloat("gatherDamage", 0);
 }
コード例 #7
0
 public void DoGather(HitInfo info)
 {
     if (!this.baseEntity.isServer || !info.CanGather || info.DidGather)
     {
         return;
     }
     if (this.gatherType == ResourceDispenser.GatherType.UNSET)
     {
         Debug.LogWarning((object)("Object :" + ((Object)((Component)this).get_gameObject()).get_name() + ": has unset gathertype!"));
     }
     else
     {
         BaseMelee ent = Object.op_Equality((Object)info.Weapon, (Object)null) ? (BaseMelee)null : (BaseMelee)((Component)info.Weapon).GetComponent <BaseMelee>();
         float     gatherDamage;
         float     destroyFraction;
         if (Object.op_Inequality((Object)ent, (Object)null))
         {
             ResourceDispenser.GatherPropertyEntry gatherInfoFromIndex = ent.GetGatherInfoFromIndex(this.gatherType);
             gatherDamage    = gatherInfoFromIndex.gatherDamage * info.gatherScale;
             destroyFraction = gatherInfoFromIndex.destroyFraction;
             if ((double)gatherDamage == 0.0)
             {
                 return;
             }
             ent.SendPunch(Vector3.op_Multiply(Vector3.op_Multiply(new Vector3(Random.Range(0.5f, 1f), Random.Range(-0.25f, -0.5f), 0.0f), -30f), gatherInfoFromIndex.conditionLost / 6f), 0.05f);
             ent.LoseCondition(gatherInfoFromIndex.conditionLost);
             if (!ent.IsValid() || ent.IsBroken())
             {
                 return;
             }
             info.DidGather = true;
         }
         else
         {
             gatherDamage    = info.damageTypes.Total();
             destroyFraction = 0.5f;
         }
         float fractionRemaining = this.fractionRemaining;
         this.GiveResources(info.Initiator, gatherDamage, destroyFraction, info.Weapon);
         this.UpdateFraction();
         float damageAmount;
         if ((double)this.fractionRemaining <= 0.0)
         {
             damageAmount = this.baseEntity.MaxHealth();
             if (info.DidGather && (double)destroyFraction < (double)this.maxDestroyFractionForFinishBonus)
             {
                 this.AssignFinishBonus(info.InitiatorPlayer, 1f - destroyFraction);
             }
         }
         else
         {
             damageAmount = (fractionRemaining - this.fractionRemaining) * this.baseEntity.MaxHealth();
         }
         this.baseEntity.OnAttacked(new HitInfo(info.Initiator, this.baseEntity, DamageType.Generic, damageAmount, ((Component)this).get_transform().get_position())
         {
             gatherScale = 0.0f,
             PointStart  = info.PointStart,
             PointEnd    = info.PointEnd
         });
     }
 }