/// <summary> /// Render this to a look command (what something sees when it 'look's at this /// </summary> /// <returns>the output strings</returns> public override ILexicalParagraph RenderToVisible(IEntity viewer) { short strength = GetVisibleDelta(viewer); IPathwayTemplate bS = Template <IPathwayTemplate>(); ISensoryEvent me = GetSelf(MessagingType.Visible, strength); if (bS.Descriptives.Any()) { foreach (ISensoryEvent desc in bS.Descriptives) { me.Event.TryModify(desc.Event); } } else { LexicalContext collectiveContext = new LexicalContext(viewer) { Determinant = true, Perspective = NarrativePerspective.SecondPerson, Plural = false, Position = LexicalPosition.Near, Tense = LexicalTense.Present }; LexicalContext discreteContext = new LexicalContext(viewer) { Determinant = true, Perspective = NarrativePerspective.ThirdPerson, Plural = false, Position = LexicalPosition.Attached, Tense = LexicalTense.Present }; Lexica verb = new Lexica(LexicalType.Verb, GrammaticalType.Verb, "leads", collectiveContext); //Fallback to using names if (DirectionType == MovementDirectionType.None) { Lexica origin = new Lexica(LexicalType.Noun, GrammaticalType.DirectObject, Origin.TemplateName, discreteContext); origin.TryModify(new Lexica(LexicalType.Noun, GrammaticalType.IndirectObject, Destination.TemplateName, discreteContext)); verb.TryModify(origin); } else { Lexica direction = new Lexica(LexicalType.Noun, GrammaticalType.DirectObject, DirectionType.ToString(), discreteContext); Lexica origin = new Lexica(LexicalType.Noun, GrammaticalType.IndirectObject, Origin.TemplateName, discreteContext); origin.TryModify(new Lexica(LexicalType.Noun, GrammaticalType.IndirectObject, Destination.TemplateName, discreteContext)); direction.TryModify(origin); } me.Event.TryModify(verb); } return(new LexicalParagraph(me)); }
/// <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)); }
/// <summary> /// Render this as being show inside a container /// </summary> /// <param name="viewer">The entity looking</param> /// <returns>the output strings</returns> public override ILexicalParagraph RenderAsContents(IEntity viewer, MessagingType[] sensoryTypes) { 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 }; List <ISensoryEvent> sensoryOutput = new List <ISensoryEvent>(); foreach (MessagingType sense in sensoryTypes) { SensoryEvent me = new SensoryEvent(new Lexica(LexicalType.Pronoun, GrammaticalType.Subject, "you", collectiveContext), 0, sense); ILexica senseVerb = null; IEnumerable <ISensoryEvent> senseDescs = Enumerable.Empty <ISensoryEvent>(); switch (sense) { case MessagingType.Audible: me.Strength = GetAudibleDelta(viewer); senseVerb = new Lexica(LexicalType.Verb, GrammaticalType.Verb, "hear", collectiveContext); IEnumerable <ISensoryEvent> audibleDescs = GetAudibleDescriptives(viewer); if (audibleDescs.Count() == 0) { continue; } ISensoryEvent audibleNoun = null; if (!audibleDescs.Any(desc => desc.Event.Role == GrammaticalType.DirectObject)) { audibleNoun = new SensoryEvent(new Lexica(LexicalType.Noun, GrammaticalType.DirectObject, "noise", discreteContext), me.Strength, sense); } else { audibleNoun = audibleDescs.FirstOrDefault(desc => desc.Event.Role == GrammaticalType.DirectObject); } audibleNoun.TryModify(audibleDescs.Where(desc => desc.Event.Role == GrammaticalType.Descriptive)); senseDescs = new List <ISensoryEvent>() { audibleNoun }; break; case MessagingType.Olefactory: me.Strength = GetOlefactoryDelta(viewer); senseVerb = new Lexica(LexicalType.Verb, GrammaticalType.Verb, "smell", collectiveContext); IEnumerable <ISensoryEvent> smellDescs = GetOlefactoryDescriptives(viewer); if (smellDescs.Count() == 0) { continue; } ISensoryEvent smellNoun = null; if (!smellDescs.Any(desc => desc.Event.Role == GrammaticalType.DirectObject)) { smellNoun = new SensoryEvent(new Lexica(LexicalType.Noun, GrammaticalType.DirectObject, "odor", discreteContext), me.Strength, sense); } else { smellNoun = smellDescs.FirstOrDefault(desc => desc.Event.Role == GrammaticalType.DirectObject); } smellNoun.TryModify(smellDescs.Where(desc => desc.Event.Role == GrammaticalType.Descriptive)); senseDescs = new List <ISensoryEvent>() { smellNoun }; break; case MessagingType.Psychic: me.Strength = GetPsychicDelta(viewer); senseVerb = new Lexica(LexicalType.Verb, GrammaticalType.Verb, "sense", collectiveContext); IEnumerable <ISensoryEvent> psyDescs = GetPsychicDescriptives(viewer); if (psyDescs.Count() == 0) { continue; } ISensoryEvent psyNoun = null; if (!psyDescs.Any(desc => desc.Event.Role == GrammaticalType.DirectObject)) { psyNoun = new SensoryEvent(new Lexica(LexicalType.Noun, GrammaticalType.DirectObject, "presence", discreteContext), me.Strength, sense); } else { psyNoun = psyDescs.FirstOrDefault(desc => desc.Event.Role == GrammaticalType.DirectObject); } psyNoun.TryModify(psyDescs.Where(desc => desc.Event.Role == GrammaticalType.Descriptive)); senseDescs = new List <ISensoryEvent>() { psyNoun }; break; case MessagingType.Tactile: case MessagingType.Taste: continue; case MessagingType.Visible: me.Strength = GetVisibleDelta(viewer); senseVerb = new Lexica(LexicalType.Verb, GrammaticalType.Verb, "see", collectiveContext); IEnumerable <ISensoryEvent> seeDescs = GetVisibleDescriptives(viewer); if (seeDescs.Count() == 0) { continue; } ISensoryEvent seeNoun = null; if (!seeDescs.Any(desc => desc.Event.Role == GrammaticalType.DirectObject)) { seeNoun = new SensoryEvent(new Lexica(LexicalType.Noun, GrammaticalType.DirectObject, "thing", discreteContext), me.Strength, sense); } else { seeNoun = seeDescs.FirstOrDefault(desc => desc.Event.Role == GrammaticalType.DirectObject); } seeNoun.TryModify(seeDescs.Where(desc => desc.Event.Role == GrammaticalType.Descriptive)); senseDescs = new List <ISensoryEvent>() { seeNoun }; break; } if (senseVerb != null && senseDescs.Count() > 0) { IEnumerable <ILexica> senseEvents = senseDescs.Select(desc => desc.Event); foreach (ILexica evt in senseEvents) { evt.Context = discreteContext; senseVerb.TryModify(evt); } me.TryModify(senseVerb); sensoryOutput.Add(me); } } return(new LexicalParagraph(sensoryOutput)); }
/// <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)); }