Exemplo n.º 1
0
        /// <summary>
        /// Render this in a short descriptive style
        /// </summary>
        /// <param name="viewer">The entity looking</param>
        /// <returns>the output strings</returns>
        public override ILexicalParagraph GetFullDescription(IEntity viewer, MessagingType[] sensoryTypes = null)
        {
            if (sensoryTypes == null || sensoryTypes.Count() == 0)
            {
                sensoryTypes = new MessagingType[] { MessagingType.Audible, MessagingType.Olefactory, MessagingType.Psychic, MessagingType.Tactile, MessagingType.Taste, MessagingType.Visible };
            }

            LexicalContext collectiveContext = new LexicalContext(viewer)
            {
                Determinant = true,
                Perspective = NarrativePerspective.SecondPerson,
                Plural      = false,
                Position    = LexicalPosition.None,
                Tense       = LexicalTense.Present
            };

            LexicalContext discreteContext = new LexicalContext(viewer)
            {
                Determinant = false,
                Perspective = NarrativePerspective.ThirdPerson,
                Plural      = false,
                Position    = LexicalPosition.Far,
                Tense       = LexicalTense.Present
            };

            //Self becomes the first sense in the list
            List <ISensoryEvent> sensoryOutput = new List <ISensoryEvent>();

            foreach (MessagingType sense in sensoryTypes)
            {
                ISensoryEvent me = GetSelf(sense);
                switch (sense)
                {
                case MessagingType.Audible:
                    me.Strength = GetAudibleDelta(viewer);

                    IEnumerable <ISensoryEvent> aDescs = GetAudibleDescriptives(viewer);

                    if (aDescs.Count() == 0)
                    {
                        continue;
                    }

                    me.TryModify(aDescs.Where(adesc => adesc.Event.Role == GrammaticalType.Descriptive));

                    ILexica uberSounds = new Lexica(LexicalType.Verb, GrammaticalType.Verb, "hear", collectiveContext);
                    uberSounds.TryModify(aDescs.Where(adesc => adesc.Event.Role == GrammaticalType.DirectObject).Select(adesc => adesc.Event));

                    foreach (ISensoryEvent desc in aDescs.Where(adesc => adesc.Event.Role == GrammaticalType.Subject))
                    {
                        Lexica newDesc = new Lexica(desc.Event.Type, GrammaticalType.DirectObject, desc.Event.Phrase, discreteContext);
                        newDesc.TryModify(desc.Event.Modifiers);

                        uberSounds.TryModify(newDesc);
                    }

                    if (uberSounds.Modifiers.Any())
                    {
                        me.TryModify(uberSounds);
                    }

                    break;

                case MessagingType.Olefactory:
                    me.Strength = GetOlefactoryDelta(viewer);

                    IEnumerable <ISensoryEvent> oDescs = GetOlefactoryDescriptives(viewer);

                    if (oDescs.Count() == 0)
                    {
                        continue;
                    }

                    me.TryModify(oDescs.Where(adesc => adesc.Event.Role == GrammaticalType.Descriptive));

                    ILexica uberSmells = new Lexica(LexicalType.Verb, GrammaticalType.Verb, "smell", collectiveContext);
                    uberSmells.TryModify(oDescs.Where(adesc => adesc.Event.Role == GrammaticalType.DirectObject).Select(adesc => adesc.Event));

                    foreach (ISensoryEvent desc in oDescs.Where(adesc => adesc.Event.Role == GrammaticalType.Subject))
                    {
                        Lexica newDesc = new Lexica(desc.Event.Type, GrammaticalType.DirectObject, desc.Event.Phrase, discreteContext);
                        newDesc.TryModify(desc.Event.Modifiers);

                        uberSmells.TryModify(newDesc);
                    }

                    if (uberSmells.Modifiers.Any())
                    {
                        me.TryModify(uberSmells);
                    }

                    break;

                case MessagingType.Psychic:
                    me.Strength = GetPsychicDelta(viewer);

                    IEnumerable <ISensoryEvent> pDescs = GetPsychicDescriptives(viewer);

                    if (pDescs.Count() == 0)
                    {
                        continue;
                    }

                    me.TryModify(pDescs.Where(adesc => adesc.Event.Role == GrammaticalType.Descriptive));

                    Lexica collectivePsy = new Lexica(LexicalType.Pronoun, GrammaticalType.Subject, "you", collectiveContext);

                    ILexica uberPsy = collectivePsy.TryModify(LexicalType.Verb, GrammaticalType.Verb, "sense");
                    uberPsy.TryModify(pDescs.Where(adesc => adesc.Event.Role == GrammaticalType.DirectObject).Select(adesc => adesc.Event));

                    foreach (ISensoryEvent desc in pDescs.Where(adesc => adesc.Event.Role == GrammaticalType.Subject))
                    {
                        Lexica newDesc = new Lexica(desc.Event.Type, GrammaticalType.DirectObject, desc.Event.Phrase, discreteContext);
                        newDesc.TryModify(desc.Event.Modifiers);

                        uberPsy.TryModify(newDesc);
                    }

                    if (uberPsy.Modifiers.Any())
                    {
                        me.TryModify(collectivePsy);
                    }

                    break;

                case MessagingType.Taste:
                    continue;

                case MessagingType.Tactile:
                    me.Strength = GetTactileDelta(viewer);

                    //Add the temperature
                    me.TryModify(LexicalType.Verb, GrammaticalType.Verb, "feels").TryModify(new Lexica[] {
                        new Lexica(LexicalType.Adjective, GrammaticalType.Descriptive, MeteorologicalUtilities.ConvertHumidityToType(EffectiveHumidity()).ToString(), collectiveContext),
                        new Lexica(LexicalType.Adjective, GrammaticalType.Descriptive, MeteorologicalUtilities.ConvertTemperatureToType(EffectiveTemperature()).ToString(), collectiveContext)
                    });

                    break;

                case MessagingType.Visible:
                    me.Strength = GetVisibleDelta(viewer);

                    IEnumerable <ISensoryEvent> vDescs = GetVisibleDescriptives(viewer);

                    if (vDescs.Count() > 0)
                    {
                        me.TryModify(vDescs.Where(adesc => adesc.Event.Role == GrammaticalType.Descriptive));

                        Lexica collectiveSight = new Lexica(LexicalType.Pronoun, GrammaticalType.Subject, "you", collectiveContext);

                        ILexica uberSight = collectiveSight.TryModify(LexicalType.Verb, GrammaticalType.Verb, "see");
                        uberSight.TryModify(vDescs.Where(adesc => adesc.Event.Role == GrammaticalType.DirectObject).Select(adesc => adesc.Event));

                        foreach (ISensoryEvent desc in vDescs.Where(adesc => adesc.Event.Role == GrammaticalType.Subject))
                        {
                            Lexica newDesc = new Lexica(desc.Event.Type, GrammaticalType.DirectObject, desc.Event.Phrase, discreteContext);
                            newDesc.TryModify(desc.Event.Modifiers);

                            uberSight.TryModify(newDesc);
                        }

                        if (uberSight.Modifiers.Any())
                        {
                            me.TryModify(collectiveSight);
                        }
                    }

                    //Describe the size and population of this zone
                    DimensionalSizeDescription zoneSize = GeographicalUtilities.ConvertSizeToType(GetModelDimensions(), GetType());

                    me.TryModify(LexicalType.Adjective, GrammaticalType.Descriptive, zoneSize.ToString());

                    //Render people in the zone
                    CrowdSizeDescription populationSize = GeographicalUtilities.GetCrowdSize(GetContents <IMobile>().Count());

                    string crowdSize = "abandoned";
                    if ((short)populationSize > (short)zoneSize)
                    {
                        crowdSize = "crowded";
                    }
                    else if (populationSize > CrowdSizeDescription.Intimate)
                    {
                        crowdSize = "sparsely populated";
                    }

                    me.TryModify(LexicalType.Adjective, GrammaticalType.Descriptive, crowdSize);

                    break;
                }

                if (me != null)
                {
                    sensoryOutput.Add(me);
                }
            }

            foreach (ICelestial celestial in GetVisibileCelestials(viewer))
            {
                sensoryOutput.AddRange(celestial.RenderAsContents(viewer, sensoryTypes).Events);
            }

            foreach (IWeatherEvent wEvent in WeatherEvents)
            {
                sensoryOutput.AddRange(wEvent.RenderAsContents(viewer, sensoryTypes).Events);
            }

            foreach (INaturalResourceSpawn <IFlora> resource in FloraNaturalResources)
            {
                sensoryOutput.AddRange(resource.Resource.RenderResourceCollection(viewer, resource.RateFactor).Events);
            }

            foreach (INaturalResourceSpawn <IFauna> resource in FaunaNaturalResources)
            {
                sensoryOutput.AddRange(resource.Resource.RenderResourceCollection(viewer, resource.RateFactor).Events);
            }

            foreach (INaturalResourceSpawn <IMineral> resource in MineralNaturalResources)
            {
                sensoryOutput.AddRange(resource.Resource.RenderResourceCollection(viewer, resource.RateFactor).Events);
            }

            //render our locales out
            foreach (ILocale locale in LiveCache.GetAll <ILocale>().Where(loc => loc.ParentLocation?.TemplateId == TemplateId))
            {
                sensoryOutput.AddRange(locale.RenderAsContents(viewer, sensoryTypes).Events);
            }

            //render our locales out
            foreach (IPathway path in GetPathways())
            {
                sensoryOutput.AddRange(path.RenderAsContents(viewer, sensoryTypes).Events);
            }

            return(new LexicalParagraph(sensoryOutput));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Render this in a short descriptive style
        /// </summary>
        /// <param name="viewer">The entity looking</param>
        /// <returns>the output strings</returns>
        public override ILexicalParagraph GetFullDescription(IEntity viewer, MessagingType[] sensoryTypes = null)
        {
            if (sensoryTypes == null || sensoryTypes.Count() == 0)
            {
                sensoryTypes = new MessagingType[] { MessagingType.Audible, MessagingType.Olefactory, MessagingType.Psychic, MessagingType.Tactile, MessagingType.Taste, MessagingType.Visible };
            }

            LexicalContext collectiveContext = new LexicalContext(viewer)
            {
                Determinant = true,
                Perspective = NarrativePerspective.SecondPerson,
                Plural      = false,
                Position    = LexicalPosition.Around,
                Tense       = LexicalTense.Present
            };

            LexicalContext discreteContext = new LexicalContext(viewer)
            {
                Determinant = true,
                Perspective = NarrativePerspective.ThirdPerson,
                Plural      = false,
                Position    = LexicalPosition.Attached,
                Tense       = LexicalTense.Present
            };

            //Self becomes the first sense in the list
            List <ISensoryEvent> messages = new List <ISensoryEvent>();

            foreach (MessagingType sense in sensoryTypes)
            {
                ISensoryEvent me = GetSelf(sense);

                switch (sense)
                {
                case MessagingType.Audible:
                    me.Strength = GetAudibleDelta(viewer);

                    IEnumerable <ISensoryEvent> aDescs = GetAudibleDescriptives(viewer);

                    me.TryModify(aDescs.Where(adesc => adesc.Event.Role == GrammaticalType.Descriptive));

                    ILexica uberSounds = new Lexica(LexicalType.Verb, GrammaticalType.Verb, "hear", collectiveContext);
                    uberSounds.TryModify(aDescs.Where(adesc => adesc.Event.Role == GrammaticalType.DirectObject).Select(adesc => adesc.Event));

                    foreach (ISensoryEvent desc in aDescs.Where(adesc => adesc.Event.Role == GrammaticalType.Subject))
                    {
                        Lexica newDesc = new Lexica(desc.Event.Type, GrammaticalType.Subject, desc.Event.Phrase, discreteContext);
                        newDesc.TryModify(desc.Event.Modifiers);

                        me.TryModify(newDesc);
                    }

                    if (uberSounds.Modifiers.Any(mod => mod.Role == GrammaticalType.Subject))
                    {
                        me.TryModify(uberSounds);
                    }

                    break;

                case MessagingType.Olefactory:
                    me.Strength = GetOlefactoryDelta(viewer);

                    IEnumerable <ISensoryEvent> oDescs = GetOlefactoryDescriptives(viewer);

                    me.TryModify(oDescs.Where(adesc => adesc.Event.Role == GrammaticalType.Descriptive));

                    Lexica uberSmells = new Lexica(LexicalType.Verb, GrammaticalType.Verb, "smell", collectiveContext);
                    uberSmells.TryModify(oDescs.Where(adesc => adesc.Event.Role == GrammaticalType.DirectObject).Select(adesc => adesc.Event));

                    foreach (ISensoryEvent desc in oDescs.Where(adesc => adesc.Event.Role == GrammaticalType.Subject))
                    {
                        Lexica newDesc = new Lexica(desc.Event.Type, GrammaticalType.DirectObject, desc.Event.Phrase, discreteContext);
                        newDesc.TryModify(desc.Event.Modifiers);

                        uberSmells.TryModify(newDesc);
                    }

                    if (uberSmells.Modifiers.Any(mod => mod.Role == GrammaticalType.Subject))
                    {
                        me.TryModify(uberSmells);
                    }

                    break;

                case MessagingType.Psychic:
                    me.Strength = GetPsychicDelta(viewer);

                    IEnumerable <ISensoryEvent> pDescs = GetPsychicDescriptives(viewer);

                    me.TryModify(pDescs.Where(adesc => adesc.Event.Role == GrammaticalType.Descriptive));

                    Lexica collectivePsy = new Lexica(LexicalType.Pronoun, GrammaticalType.Subject, "you", collectiveContext);

                    ILexica uberPsy = collectivePsy.TryModify(LexicalType.Verb, GrammaticalType.Verb, "sense");
                    uberPsy.TryModify(pDescs.Where(adesc => adesc.Event.Role == GrammaticalType.DirectObject).Select(adesc => adesc.Event));

                    foreach (ISensoryEvent desc in pDescs.Where(adesc => adesc.Event.Role == GrammaticalType.Subject))
                    {
                        Lexica newDesc = new Lexica(desc.Event.Type, GrammaticalType.DirectObject, desc.Event.Phrase, discreteContext);
                        newDesc.TryModify(desc.Event.Modifiers);

                        uberPsy.TryModify(newDesc);
                    }

                    if (uberPsy.Modifiers.Any(mod => mod.Role == GrammaticalType.Subject))
                    {
                        me.TryModify(collectivePsy);
                    }

                    break;

                case MessagingType.Taste:
                    me.Strength = GetTasteDelta(viewer);

                    IEnumerable <ISensoryEvent> taDescs = GetTasteDescriptives(viewer);

                    me.TryModify(taDescs.Where(adesc => adesc.Event.Role == GrammaticalType.Descriptive));

                    Lexica uberTaste = new Lexica(LexicalType.Verb, GrammaticalType.Verb, "taste", collectiveContext);
                    uberTaste.TryModify(taDescs.Where(adesc => adesc.Event.Role == GrammaticalType.DirectObject).Select(adesc => adesc.Event));

                    foreach (ISensoryEvent desc in taDescs.Where(adesc => adesc.Event.Role == GrammaticalType.Subject))
                    {
                        Lexica newDesc = new Lexica(desc.Event.Type, GrammaticalType.DirectObject, desc.Event.Phrase, discreteContext);
                        newDesc.TryModify(desc.Event.Modifiers);

                        uberTaste.TryModify(newDesc);
                    }

                    if (uberTaste.Modifiers.Any(mod => mod.Role == GrammaticalType.Subject))
                    {
                        me.TryModify(uberTaste);
                    }

                    break;

                case MessagingType.Tactile:
                    me.Strength = GetTactileDelta(viewer);

                    IEnumerable <ISensoryEvent> tDescs = GetOlefactoryDescriptives(viewer);

                    me.TryModify(tDescs.Where(adesc => adesc.Event.Role == GrammaticalType.Descriptive));

                    Lexica uberTouch = new Lexica(LexicalType.Verb, GrammaticalType.Verb, "feel", collectiveContext);
                    uberTouch.TryModify(tDescs.Where(adesc => adesc.Event.Role == GrammaticalType.DirectObject).Select(adesc => adesc.Event));

                    foreach (ISensoryEvent desc in tDescs.Where(adesc => adesc.Event.Role == GrammaticalType.Subject))
                    {
                        Lexica newDesc = new Lexica(desc.Event.Type, GrammaticalType.DirectObject, desc.Event.Phrase, discreteContext);
                        newDesc.TryModify(desc.Event.Modifiers);

                        uberTouch.TryModify(newDesc);
                    }

                    if (uberTouch.Modifiers.Any(mod => mod.Role == GrammaticalType.Subject))
                    {
                        me.TryModify(uberTouch);
                    }

                    break;

                case MessagingType.Visible:
                    me.Strength = GetVisibleDelta(viewer);

                    IEnumerable <ISensoryEvent> vDescs = GetVisibleDescriptives(viewer);

                    me.TryModify(vDescs.Where(adesc => adesc.Event.Role == GrammaticalType.Descriptive));

                    Lexica uberSight = new Lexica(LexicalType.Verb, GrammaticalType.Verb, "appears", collectiveContext);
                    uberSight.TryModify(vDescs.Where(adesc => adesc.Event.Role == GrammaticalType.DirectObject).Select(adesc => adesc.Event));

                    foreach (ISensoryEvent desc in vDescs.Where(adesc => adesc.Event.Role == GrammaticalType.Subject))
                    {
                        Lexica newDesc = new Lexica(desc.Event.Type, GrammaticalType.DirectObject, desc.Event.Phrase, discreteContext);
                        newDesc.TryModify(desc.Event.Modifiers);

                        uberSight.TryModify(newDesc);
                    }

                    if (uberSight.Modifiers.Any(mod => mod.Role == GrammaticalType.Subject))
                    {
                        me.TryModify(uberSight);
                    }

                    //Describe the size and population of this zone
                    DimensionalSizeDescription objectSize = GeographicalUtilities.ConvertSizeToType(GetModelDimensions(), GetType());

                    me.TryModify(LexicalType.Adjective, GrammaticalType.Descriptive, objectSize.ToString());

                    //Render people in the zone
                    ObjectContainmentSizeDescription bulgeSizeAdjective = GeographicalUtilities.GetObjectContainmentSize(GetContents <IInanimate>().Sum(obj => obj.GetModelVolume()), GetModelVolume());

                    me.TryModify(LexicalType.Adjective, GrammaticalType.Descriptive, bulgeSizeAdjective.ToString());

                    break;
                }

                messages.Add(me);
            }

            return(new LexicalParagraph(messages));
        }