public void Notify_ApparelAdded(Apparel apparel)
        {
            SortWornApparelIntoDrawOrder();
            ApparelChanged();
            List <Verb> list = apparel.GetComp <CompReloadable>()?.AllVerbs;

            if (list != null)
            {
                foreach (Verb item in list)
                {
                    item.caster = pawn;
                    item.Notify_PickedUp();
                }
            }
            if (!apparel.def.equippedStatOffsets.NullOrEmpty())
            {
                pawn.health.capacities.Notify_CapacityLevelsDirty();
            }
        }
        public List <VerbEntry> GetUpdatedAvailableVerbsList()
        {
            Pawn_MeleeVerbs.meleeVerbs.Clear();
            List <Verb> allVerbs = this.pawn.verbTracker.AllVerbs;

            for (int i = 0; i < allVerbs.Count; i++)
            {
                if (allVerbs[i].IsStillUsableBy(this.pawn))
                {
                    Pawn_MeleeVerbs.meleeVerbs.Add(new VerbEntry(allVerbs[i], this.pawn, null));
                }
            }
            if (this.pawn.equipment != null)
            {
                List <ThingWithComps> allEquipmentListForReading = this.pawn.equipment.AllEquipmentListForReading;
                for (int j = 0; j < allEquipmentListForReading.Count; j++)
                {
                    ThingWithComps thingWithComps = allEquipmentListForReading[j];
                    CompEquippable comp           = thingWithComps.GetComp <CompEquippable>();
                    if (comp != null)
                    {
                        List <Verb> allVerbs2 = comp.AllVerbs;
                        if (allVerbs2 != null)
                        {
                            for (int k = 0; k < allVerbs2.Count; k++)
                            {
                                Pawn_MeleeVerbs.meleeVerbs.Add(new VerbEntry(allVerbs2[k], this.pawn, thingWithComps));
                            }
                        }
                    }
                }
            }
            if (this.pawn.apparel != null)
            {
                List <Apparel> wornApparel = this.pawn.apparel.WornApparel;
                for (int l = 0; l < wornApparel.Count; l++)
                {
                    Apparel        apparel = wornApparel[l];
                    CompEquippable comp2   = apparel.GetComp <CompEquippable>();
                    if (comp2 != null)
                    {
                        List <Verb> allVerbs3 = comp2.AllVerbs;
                        if (allVerbs3 != null)
                        {
                            for (int m = 0; m < allVerbs3.Count; m++)
                            {
                                Pawn_MeleeVerbs.meleeVerbs.Add(new VerbEntry(allVerbs3[m], this.pawn, apparel));
                            }
                        }
                    }
                }
            }
            foreach (Verb hediffsVerb in this.pawn.health.hediffSet.GetHediffsVerbs())
            {
                if (hediffsVerb.IsStillUsableBy(this.pawn))
                {
                    Pawn_MeleeVerbs.meleeVerbs.Add(new VerbEntry(hediffsVerb, this.pawn, null));
                }
            }
            return(Pawn_MeleeVerbs.meleeVerbs);
        }
示例#3
0
        public List <VerbEntry> GetUpdatedAvailableVerbsList()
        {
            Profiler.BeginSample("GetUpdatedAvailableVerbsList");
            Pawn_MeleeVerbs.meleeVerbs.Clear();
            List <Verb> allVerbs = this.pawn.verbTracker.AllVerbs;

            for (int i = 0; i < allVerbs.Count; i++)
            {
                if (allVerbs[i].IsStillUsableBy(this.pawn))
                {
                    Pawn_MeleeVerbs.meleeVerbs.Add(new VerbEntry(allVerbs[i], this.pawn, null));
                }
            }
            if (this.pawn.equipment != null)
            {
                List <ThingWithComps> allEquipmentListForReading = this.pawn.equipment.AllEquipmentListForReading;
                for (int j = 0; j < allEquipmentListForReading.Count; j++)
                {
                    ThingWithComps thingWithComps = allEquipmentListForReading[j];
                    CompEquippable comp           = thingWithComps.GetComp <CompEquippable>();
                    if (comp != null)
                    {
                        List <Verb> allVerbs2 = comp.AllVerbs;
                        if (allVerbs2 != null)
                        {
                            for (int k = 0; k < allVerbs2.Count; k++)
                            {
                                if (allVerbs2[k].IsStillUsableBy(this.pawn))
                                {
                                    Pawn_MeleeVerbs.meleeVerbs.Add(new VerbEntry(allVerbs2[k], this.pawn, thingWithComps));
                                }
                            }
                        }
                    }
                }
            }
            if (this.pawn.apparel != null)
            {
                List <Apparel> wornApparel = this.pawn.apparel.WornApparel;
                for (int l = 0; l < wornApparel.Count; l++)
                {
                    Apparel        apparel = wornApparel[l];
                    CompEquippable comp2   = apparel.GetComp <CompEquippable>();
                    if (comp2 != null)
                    {
                        List <Verb> allVerbs3 = comp2.AllVerbs;
                        if (allVerbs3 != null)
                        {
                            for (int m = 0; m < allVerbs3.Count; m++)
                            {
                                if (allVerbs3[m].IsStillUsableBy(this.pawn))
                                {
                                    Pawn_MeleeVerbs.meleeVerbs.Add(new VerbEntry(allVerbs3[m], this.pawn, apparel));
                                }
                            }
                        }
                    }
                }
            }
            foreach (Verb verb in this.pawn.health.hediffSet.GetHediffsVerbs())
            {
                if (verb.IsStillUsableBy(this.pawn))
                {
                    Pawn_MeleeVerbs.meleeVerbs.Add(new VerbEntry(verb, this.pawn, null));
                }
            }
            if (this.pawn.Spawned)
            {
                TerrainDef terrainDef = this.pawn.Map.terrainGrid.TerrainAt(this.pawn.Position);
                if (this.terrainVerbs == null || this.terrainVerbs.def != terrainDef)
                {
                    this.terrainVerbs = Pawn_MeleeVerbs_TerrainSource.Create(this, terrainDef);
                }
                List <Verb> allVerbs4 = this.terrainVerbs.tracker.AllVerbs;
                for (int n = 0; n < allVerbs4.Count; n++)
                {
                    Verb verb2 = allVerbs4[n];
                    if (verb2.IsStillUsableBy(this.pawn))
                    {
                        Pawn_MeleeVerbs.meleeVerbs.Add(new VerbEntry(verb2, this.pawn, null));
                    }
                }
            }
            Profiler.EndSample();
            return(Pawn_MeleeVerbs.meleeVerbs);
        }
示例#4
0
 public List <VerbEntry> GetUpdatedAvailableVerbsList(bool terrainTools)
 {
     meleeVerbs.Clear();
     if (!terrainTools)
     {
         List <Verb> allVerbs = pawn.verbTracker.AllVerbs;
         for (int i = 0; i < allVerbs.Count; i++)
         {
             if (allVerbs[i].IsStillUsableBy(pawn))
             {
                 meleeVerbs.Add(new VerbEntry(allVerbs[i], pawn));
             }
         }
         if (pawn.equipment != null)
         {
             List <ThingWithComps> allEquipmentListForReading = pawn.equipment.AllEquipmentListForReading;
             for (int j = 0; j < allEquipmentListForReading.Count; j++)
             {
                 ThingWithComps thingWithComps = allEquipmentListForReading[j];
                 CompEquippable comp           = thingWithComps.GetComp <CompEquippable>();
                 if (comp != null)
                 {
                     List <Verb> allVerbs2 = comp.AllVerbs;
                     if (allVerbs2 != null)
                     {
                         for (int k = 0; k < allVerbs2.Count; k++)
                         {
                             if (allVerbs2[k].IsStillUsableBy(pawn))
                             {
                                 meleeVerbs.Add(new VerbEntry(allVerbs2[k], pawn));
                             }
                         }
                     }
                 }
             }
         }
         if (pawn.apparel != null)
         {
             List <Apparel> wornApparel = pawn.apparel.WornApparel;
             for (int l = 0; l < wornApparel.Count; l++)
             {
                 Apparel        apparel = wornApparel[l];
                 CompEquippable comp2   = apparel.GetComp <CompEquippable>();
                 if (comp2 != null)
                 {
                     List <Verb> allVerbs3 = comp2.AllVerbs;
                     if (allVerbs3 != null)
                     {
                         for (int m = 0; m < allVerbs3.Count; m++)
                         {
                             if (allVerbs3[m].IsStillUsableBy(pawn))
                             {
                                 meleeVerbs.Add(new VerbEntry(allVerbs3[m], pawn));
                             }
                         }
                     }
                 }
             }
         }
         foreach (Verb hediffsVerb in pawn.health.hediffSet.GetHediffsVerbs())
         {
             if (hediffsVerb.IsStillUsableBy(pawn))
             {
                 meleeVerbs.Add(new VerbEntry(hediffsVerb, pawn));
             }
         }
     }
     else if (pawn.Spawned)
     {
         TerrainDef terrain = pawn.Position.GetTerrain(pawn.Map);
         if (terrainVerbs == null || terrainVerbs.def != terrain)
         {
             terrainVerbs = Pawn_MeleeVerbs_TerrainSource.Create(this, terrain);
         }
         List <Verb> allVerbs4 = terrainVerbs.tracker.AllVerbs;
         for (int n = 0; n < allVerbs4.Count; n++)
         {
             Verb verb = allVerbs4[n];
             if (verb.IsStillUsableBy(pawn))
             {
                 meleeVerbs.Add(new VerbEntry(verb, pawn));
             }
         }
     }
     return(meleeVerbs);
 }