Ejemplo n.º 1
0
    private void UpdateBuildState(Chore chore)
    {
        KSelectable component = GetComponent <KSelectable>();

        if (chore.InProgress())
        {
            component.SetStatusItem(Db.Get().StatusItemCategories.Main, Db.Get().BuildingStatusItems.UnderConstruction, null);
        }
        else
        {
            component.SetStatusItem(Db.Get().StatusItemCategories.Main, Db.Get().BuildingStatusItems.UnderConstructionNoWorker, null);
        }
    }
 private void OnSolidChanged(object data)
 {
     if (!((UnityEngine.Object) this == (UnityEngine.Object)null) && !((UnityEngine.Object)base.gameObject == (UnityEngine.Object)null))
     {
         GameScenePartitioner.Instance.Free(ref unstableEntry);
         int num  = Grid.PosToCell(this);
         int num2 = -1;
         UpdateColor(isReachable);
         if (Grid.Element[num].hardness >= 200)
         {
             bool flag = false;
             foreach (Chore.PreconditionInstance precondition in chore.GetPreconditions())
             {
                 Chore.PreconditionInstance current = precondition;
                 if (current.id == ChorePreconditions.instance.HasSkillPerk.id)
                 {
                     flag = true;
                     break;
                 }
             }
             if (!flag)
             {
                 chore.AddPrecondition(ChorePreconditions.instance.HasSkillPerk, Db.Get().SkillPerks.CanDigSupersuperhard);
             }
             requiredSkillPerk = Db.Get().SkillPerks.CanDigSupersuperhard.Id;
             materialDisplay.sharedMaterial = materials[3];
         }
         else if (Grid.Element[num].hardness >= 150)
         {
             bool flag2 = false;
             foreach (Chore.PreconditionInstance precondition2 in chore.GetPreconditions())
             {
                 Chore.PreconditionInstance current2 = precondition2;
                 if (current2.id == ChorePreconditions.instance.HasSkillPerk.id)
                 {
                     flag2 = true;
                     break;
                 }
             }
             if (!flag2)
             {
                 chore.AddPrecondition(ChorePreconditions.instance.HasSkillPerk, Db.Get().SkillPerks.CanDigNearlyImpenetrable);
             }
             requiredSkillPerk = Db.Get().SkillPerks.CanDigNearlyImpenetrable.Id;
             materialDisplay.sharedMaterial = materials[2];
         }
         else if (Grid.Element[num].hardness >= 50)
         {
             bool flag3 = false;
             foreach (Chore.PreconditionInstance precondition3 in chore.GetPreconditions())
             {
                 Chore.PreconditionInstance current3 = precondition3;
                 if (current3.id == ChorePreconditions.instance.HasSkillPerk.id)
                 {
                     flag3 = true;
                     break;
                 }
             }
             if (!flag3)
             {
                 chore.AddPrecondition(ChorePreconditions.instance.HasSkillPerk, Db.Get().SkillPerks.CanDigVeryFirm);
             }
             requiredSkillPerk = Db.Get().SkillPerks.CanDigVeryFirm.Id;
             materialDisplay.sharedMaterial = materials[1];
         }
         else
         {
             requiredSkillPerk = null;
             chore.GetPreconditions().Remove(chore.GetPreconditions().Find((Chore.PreconditionInstance o) => o.id == ChorePreconditions.instance.HasSkillPerk.id));
         }
         UpdateStatusItem(null);
         bool flag4 = false;
         if (!Grid.Solid[num])
         {
             num2 = GetUnstableCellAbove(num);
             if (num2 == -1)
             {
                 flag4 = true;
             }
             else
             {
                 StartCoroutine("PeriodicUnstableFallingRecheck");
             }
         }
         else if (Grid.Foundation[num])
         {
             flag4 = true;
         }
         if (flag4)
         {
             isDigComplete = true;
             if (chore == null || !chore.InProgress())
             {
                 Util.KDestroyGameObject(base.gameObject);
             }
             else
             {
                 GetComponentInChildren <MeshRenderer>().enabled = false;
             }
         }
         else if (num2 != -1)
         {
             Extents extents = default(Extents);
             Grid.CellToXY(num, out extents.x, out extents.y);
             extents.width  = 1;
             extents.height = (num2 - num + Grid.WidthInCells - 1) / Grid.WidthInCells + 1;
             unstableEntry  = GameScenePartitioner.Instance.Add("Diggable.OnSolidChanged", base.gameObject, extents, GameScenePartitioner.Instance.solidChangedLayer, OnSolidChanged);
         }
     }
 }