示例#1
0
        public static ListenerAction OnObjectChanged(Event e)
        {
            Sim   a = e.Actor as Sim;
            Plant p = e.TargetObject as Plant;

            if (p != null)
            {
                //p.AddInteraction(EWPetMarkPlant.Singleton, true);
                p.AddInteraction(EWPetWatchPlant.Singleton, true);
                p.AddInteraction(EWPetHarvest.Singleton, true);
                p.AddInteraction(EWPetWeedPlant.Singleton, true);
                p.AddInteraction(EWPetWaterPlant.Singleton, true);
                p.AddInteraction(EWPetDisposePlant.Singleton, true);
            }

            // Turning this off until I can test it
            if (a.IsPet && e.TargetObject.InInventory && !(e.TargetObject.Plantable == null) && false)
            {
                bool has_plant = false;
                foreach (InteractionObjectPair pair in e.TargetObject.GetAllInventoryInteractionsForActor(a))
                {
                    if (pair.InteractionDefinition.GetType() == EWPetPlantSeed.Singleton.GetType())
                    {
                        has_plant = true;
                        break;
                    }
                }
                if (!has_plant)
                {
                    GameObject o = e.TargetObject as GameObject;
                    o.AddInventoryInteraction(EWPetPlantSeed.Singleton);
                    o.AddInventoryInteraction(EWPetTreatNausea.Singleton);
                    o.AddInteraction(EWPetPickUpPlantable.Singleton, true);
                }
            }
            else if (e.TargetObject.CatHuntingComponent != null)
            {
                if (e.TargetObject.CatHuntingComponent.mPreyData.PreyType == CatHuntingSkill.PreyType.Rodent)
                {
                    bool has_treatFleas = false;
                    foreach (InteractionObjectPair pair in e.TargetObject.GetAllInventoryInteractionsForActor(e.Actor))
                    {
                        if (pair.InteractionDefinition.GetType() == EWPetTreatFleas.Singleton.GetType())
                        {
                            has_treatFleas = true;
                            break;
                        }
                    }
                    if (!has_treatFleas)
                    {
                        GameObject o = e.TargetObject as GameObject;
                        o.AddInventoryInteraction(EWPetTreatFleas.Singleton);
                    }
                }
            }
            return(ListenerAction.Keep);
        }