Beispiel #1
0
 public static ListenerAction OnObjectChanged(Event e)
 {
     try
     {
         if (e.TargetObject.CatHuntingComponent != null)
         {
             if (e.TargetObject.InInventory)
             {
                 bool       hasDrop = false;
                 GameObject g       = e.TargetObject as GameObject;
                 foreach (InteractionObjectPair pair in g.GetAllInventoryInteractionsForActor(e.Actor))
                 {
                     if (pair.InteractionDefinition.GetType() == EWCatDropHere.Singleton.GetType())
                     {
                         hasDrop = true;
                         break;
                     }
                 }
                 if (!hasDrop)
                 {
                     g.AddInventoryInteraction(EWCatDropHere.Singleton);
                 }
             }
             Fish newFish = e.TargetObject as Fish;
             if (newFish != null)
             {
                 bool hasEat = false;
                 foreach (InteractionObjectPair pair in newFish.Interactions)
                 {
                     if (pair.InteractionDefinition.GetType() == EWCatEatFish.Singleton.GetType())
                     {
                         hasEat = true;
                         break;
                     }
                 }
                 if (!hasEat)
                 {
                     newFish.RemoveInteractionByType(PetEatPrey.Singleton);
                     newFish.AddInteraction(EWCatEatFish.Singleton, true);
                 }
             }
         }
     }
     catch (Exception ex)
     {
         StyledNotification.Show(new StyledNotification.Format("ERROR assigning EWCatEatFish interaction: " + ex.Message,
                                                               StyledNotification.NotificationStyle.kDebugAlert));
     }
     return(ListenerAction.Keep);
 }