コード例 #1
0
 public static bool TrySwitchToolTo(
     NPCHumanContext c,
     NPCPlayerApex.ToolTypeEnum toolDay,
     NPCPlayerApex.ToolTypeEnum toolNight)
 {
     if (c != null)
     {
         Item obj            = (Item)null;
         uint svActiveItemId = c.Human.svActiveItemID;
         if (Object.op_Inequality((Object)TOD_Sky.get_Instance(), (Object)null))
         {
             obj = !TOD_Sky.get_Instance().get_IsDay() ? SwitchToolOperator.FindTool(c, toolNight) : SwitchToolOperator.FindTool(c, toolDay);
         }
         if (obj != null)
         {
             c.Human.UpdateActiveItem(obj.uid);
             if ((int)svActiveItemId != (int)c.Human.svActiveItemID)
             {
                 c.Human.NextToolSwitchTime = Time.get_realtimeSinceStartup() + c.Human.ToolSwitchFrequency;
                 c.SetFact(NPCPlayerApex.Facts.CurrentWeaponType, (byte)0, true, true);
                 c.SetFact(NPCPlayerApex.Facts.CurrentToolType, (byte)c.Human.GetCurrentToolTypeEnum(), true, true);
             }
             return(true);
         }
     }
     return(false);
 }
コード例 #2
0
 public static Item FindTool(NPCHumanContext c, NPCPlayerApex.ToolTypeEnum tool)
 {
     foreach (Item allItem in c.Human.inventory.AllItems())
     {
         if (allItem.info.category == ItemCategory.Tool)
         {
             HeldEntity heldEntity = allItem.GetHeldEntity() as HeldEntity;
             if (Object.op_Inequality((Object)heldEntity, (Object)null) && heldEntity.toolType == tool)
             {
                 return(allItem);
             }
         }
     }
     return((Item)null);
 }
コード例 #3
0
 public static Item FindTool(NPCHumanContext c, NPCPlayerApex.ToolTypeEnum tool)
 {
     Item[] itemArray = c.Human.inventory.AllItems();
     for (int i = 0; i < (int)itemArray.Length; i++)
     {
         Item item = itemArray[i];
         if (item.info.category == ItemCategory.Tool)
         {
             HeldEntity heldEntity = item.GetHeldEntity() as HeldEntity;
             if (heldEntity != null && heldEntity.toolType == tool)
             {
                 return(item);
             }
         }
     }
     return(null);
 }
コード例 #4
0
 public static bool TrySwitchToolTo(NPCHumanContext c, NPCPlayerApex.ToolTypeEnum toolDay, NPCPlayerApex.ToolTypeEnum toolNight)
 {
     if (c != null)
     {
         Item item  = null;
         uint human = c.Human.svActiveItemID;
         if (TOD_Sky.Instance != null)
         {
             item = (!TOD_Sky.Instance.IsDay ? SwitchToolOperator.FindTool(c, toolNight) : SwitchToolOperator.FindTool(c, toolDay));
         }
         if (item != null)
         {
             c.Human.UpdateActiveItem(item.uid);
             if (human != c.Human.svActiveItemID)
             {
                 c.Human.NextToolSwitchTime = UnityEngine.Time.realtimeSinceStartup + c.Human.ToolSwitchFrequency;
                 c.SetFact(NPCPlayerApex.Facts.CurrentWeaponType, 0, true, true);
                 c.SetFact(NPCPlayerApex.Facts.CurrentToolType, (byte)c.Human.GetCurrentToolTypeEnum(), true, true);
             }
             return(true);
         }
     }
     return(false);
 }