Esempio n. 1
0
 public void Wear(Apparel newApparel, bool dropReplacedApparel = true)
 {
     if (newApparel.Spawned)
     {
         newApparel.DeSpawn(DestroyMode.Vanish);
     }
     if (!ApparelUtility.HasPartsToWear(this.pawn, newApparel.def))
     {
         Log.Warning(string.Concat(new object[]
         {
             this.pawn,
             " tried to wear ",
             newApparel,
             " but he has no body parts required to wear it."
         }), false);
     }
     else
     {
         for (int i = this.wornApparel.Count - 1; i >= 0; i--)
         {
             Apparel apparel = this.wornApparel[i];
             if (!ApparelUtility.CanWearTogether(newApparel.def, apparel.def, this.pawn.RaceProps.body))
             {
                 if (dropReplacedApparel)
                 {
                     bool    forbid = this.pawn.Faction != null && this.pawn.Faction.HostileTo(Faction.OfPlayer);
                     Apparel apparel2;
                     if (!this.TryDrop(apparel, out apparel2, this.pawn.PositionHeld, forbid))
                     {
                         Log.Error(this.pawn + " could not drop " + apparel, false);
                         return;
                     }
                 }
                 else
                 {
                     this.Remove(apparel);
                 }
             }
         }
         if (newApparel.Wearer != null)
         {
             Log.Warning(string.Concat(new object[]
             {
                 this.pawn,
                 " is trying to wear ",
                 newApparel,
                 " but this apparel already has a wearer (",
                 newApparel.Wearer,
                 "). This may or may not cause bugs."
             }), false);
         }
         this.wornApparel.TryAdd(newApparel, false);
     }
 }
Esempio n. 2
0
 public void Wear(Apparel newApparel, bool dropReplacedApparel = true, bool locked = false)
 {
     if (newApparel.Spawned)
     {
         newApparel.DeSpawn();
     }
     if (!ApparelUtility.HasPartsToWear(pawn, newApparel.def))
     {
         Log.Warning(pawn + " tried to wear " + newApparel + " but he has no body parts required to wear it.");
         return;
     }
     if (EquipmentUtility.IsBiocoded(newApparel) && !EquipmentUtility.IsBiocodedFor(newApparel, pawn))
     {
         CompBiocodable compBiocodable = newApparel.TryGetComp <CompBiocodable>();
         Log.Warning(pawn + " tried to wear " + newApparel + " but it is biocoded for " + compBiocodable.CodedPawnLabel + " .");
         return;
     }
     for (int num = wornApparel.Count - 1; num >= 0; num--)
     {
         Apparel apparel = wornApparel[num];
         if (!ApparelUtility.CanWearTogether(newApparel.def, apparel.def, pawn.RaceProps.body))
         {
             if (dropReplacedApparel)
             {
                 bool forbid = pawn.Faction != null && pawn.Faction.HostileTo(Faction.OfPlayer);
                 if (!TryDrop(apparel, out Apparel _, pawn.PositionHeld, forbid))
                 {
                     Log.Error(pawn + " could not drop " + apparel);
                     return;
                 }
             }
             else
             {
                 Remove(apparel);
             }
         }
     }
     if (newApparel.Wearer != null)
     {
         Log.Warning(pawn + " is trying to wear " + newApparel + " but this apparel already has a wearer (" + newApparel.Wearer + "). This may or may not cause bugs.");
     }
     wornApparel.TryAdd(newApparel, canMergeWithExistingStacks: false);
     if (locked)
     {
         Lock(newApparel);
     }
 }
Esempio n. 3
0
 public void Wear(Apparel newApparel, bool dropReplacedApparel = true)
 {
     if (newApparel.Spawned)
     {
         newApparel.DeSpawn();
     }
     if (!ApparelUtility.HasPartsToWear(this.pawn, newApparel.def))
     {
         Log.Warning(this.pawn + " tried to wear " + newApparel + " but he has no body parts required to wear it.");
     }
     else
     {
         for (int num = this.wornApparel.Count - 1; num >= 0; num--)
         {
             Apparel apparel = this.wornApparel[num];
             if (!ApparelUtility.CanWearTogether(newApparel.def, apparel.def, this.pawn.RaceProps.body))
             {
                 if (dropReplacedApparel)
                 {
                     bool    forbid   = this.pawn.Faction.HostileTo(Faction.OfPlayer);
                     Apparel apparel2 = default(Apparel);
                     if (!this.TryDrop(apparel, out apparel2, this.pawn.Position, forbid))
                     {
                         Log.Error(this.pawn + " could not drop " + apparel);
                         return;
                     }
                 }
                 else
                 {
                     this.Remove(apparel);
                 }
             }
         }
         if (newApparel.Wearer != null)
         {
             Log.Warning(this.pawn + " is trying to wear " + newApparel + " but this apparel already has a wearer (" + newApparel.Wearer + "). This may or may not cause bugs.");
         }
         this.wornApparel.TryAdd(newApparel, false);
     }
 }