Пример #1
0
 public MemoryInstance HasAnyMemoryOf(Verb verb, CONSUMPTION_TYPE consumptionType, bool invertVerb)
 {
     for (int count = 0; count < shortTermMemory.Length; count++)
     {
         if (shortTermMemory[count] == null)
         {
             continue;
         }
         if (shortTermMemory[count].verb == Verb.SAW &&
             shortTermMemory[count].subject.GetThing().matchesConsumptionType(consumptionType))
         {
             return(shortTermMemory[count]);
         }
     }
     for (int count = 0; count < longTermMemory.Count; count++)
     {
         if (longTermMemory[count].verb == Verb.SAW &&
             longTermMemory[count].subject.GetThing().matchesConsumptionType(consumptionType))
         {
             Debug.LogWarning("I remember food - " + longTermMemory[count].subject.GetThing().thingName);
             return(longTermMemory[count]);
         }
     }
     return(null);
 }
Пример #2
0
        public MemoryInstance[] HasAnyMemoriesOf(Verb verb, CONSUMPTION_TYPE consumptionType)
        {
            List <MemoryInstance> memories = new List <MemoryInstance>();

            for (int count = 0; count < shortTermMemory.Length; count++)
            {
                if (shortTermMemory[count] != null)
                {
                    if (shortTermMemory[count].verb == verb &&
                        shortTermMemory[count].subject.GetThing().matchesConsumptionType(consumptionType))
                    {
                        memories.Add(shortTermMemory[count]);
                    }
                }
                for (count = 0; count < longTermMemory.Count; count++)
                {
                    if (longTermMemory[count].verb == verb &&
                        longTermMemory[count].subject.GetThing().matchesConsumptionType(consumptionType))
                    {
                        memories.Add(longTermMemory[count]);
                    }
                }
            }
            return(memories.ToArray());
        }
Пример #3
0
 public bool matchesConsumptionType(CONSUMPTION_TYPE consumptionType)
 {
     if (consumptionType == CONSUMPTION_TYPE.OMNIVORE)
     {
         if (consumeable && available)
         {
             if (baseType == Base_Types.PLANT)
             {
                 return(true);
             }
         }
     }
     return(false);
 }
Пример #4
0
        public Thing[] findConsumeable(CONSUMPTION_TYPE consumptionType)
        {
            List <Thing> things         = new List <Thing>();
            List <Thing> allThingsLocal = GetAllThingsSync();

            {
                foreach (Thing thing in allThingsLocal)
                {
                    if (thing.matchesConsumptionType(consumptionType))
                    {
                        things.Add(thing);
                    }
                }
            }
            return(things.ToArray());
        }
Пример #5
0
 private void Initialize(char gender, string speciesName, bool intelligent, BASE_SPECIES baseSpecies,
                         CONSUMPTION_TYPE consumptionType, Creature creature)
 {
     this.memory          = new Memory();
     this.speciesName     = speciesName;
     this.gender          = gender;
     this.intelligent     = intelligent;
     this.baseSpecies     = baseSpecies;
     this.consumptionType = consumptionType;
     if (intelligent)
     {
         personality = new Personality(memory, creature);
     }
     else
     {
         personality = null;
     }
 }
Пример #6
0
        private Thing[] GetFoodFromMemory(CONSUMPTION_TYPE consumptionType)
        {
            List <Thing> memoriesOfFood = new List <Thing>();

            for (int count = 0; count < shortTermMemory.Length; count++)
            {
                MemoryInstance memory = shortTermMemory[count];
                if (memory == null)
                {
                    continue;
                }
                if (memory.verb == Verb.SAW && memory.invertVerb == false &&
                    memory.subject.GetThing() != null && memory.subject.GetThing()
                    .matchesConsumptionType(consumptionType))
                {
                    memoriesOfFood.Add(memory.subject.GetThing());
                }
            }
            return(memoriesOfFood.ToArray());
        }
Пример #7
0
 public Species(char gender, string speciesName, bool intelligent, BASE_SPECIES baseSpecies,
                CONSUMPTION_TYPE consumptionType, Creature creature)
 {
     Initialize(gender, speciesName, intelligent, baseSpecies, consumptionType, creature);
 }
Пример #8
0
        public Thing GetClosestFoodFromMemory(bool filterOutMoveToFailuresFromShortTerm, CONSUMPTION_TYPE cType,
                                              Vector3 originPosition)
        {
            Thing closest     = null;
            float closestDist = float.MaxValue;

            Thing[] food = GetFoodFromMemory(cType);
            for (int count = 0; count < food.Length; count++)
            {
                // We remember not being able to access this previously //
                if (HasRecentMemoryOf(Verb.MOVEDTO, food[count], true) && filterOutMoveToFailuresFromShortTerm)
                {
                    continue;
                }
                // Object has since been destroyed //
                if (food[count] == null)
                {
                    continue;
                }
                float thisDist = Vector3.Distance(originPosition, food[count].transform.position);
                if (thisDist < closestDist)
                {
                    closestDist = thisDist;
                    closest     = food[count];
                }
            }
            return(closest);
        }
Пример #9
0
 public MemoryInstance HasAnyMemoryOf(Verb verb, CONSUMPTION_TYPE consumptionType, bool invertVerb)
 {
     return(species.memory.HasAnyMemoryOf(verb, consumptionType, invertVerb));
 }
Пример #10
0
 public MemoryInstance[] HasAnyMemoriesOf(Verb verb, CONSUMPTION_TYPE consumptionType)
 {
     return(species.memory.HasAnyMemoriesOf(verb, consumptionType));
 }