Esempio n. 1
0
        public HistoricalFigure(List <Property> properties, World world)
            : base(properties, world)
        {
            Initialize();
            foreach (Property property in properties)
            {
                switch (property.Name)
                {
                case "appeared": Appeared = Convert.ToInt32(property.Value); break;

                case "birth_year": BirthYear = Convert.ToInt32(property.Value); break;

                case "birth_seconds72": BirthSeconds72 = Convert.ToInt32(property.Value); break;

                case "death_year": DeathYear = Convert.ToInt32(property.Value); break;

                case "death_seconds72": DeathSeconds72 = Convert.ToInt32(property.Value); break;

                case "name": Name = Formatting.InitCaps(property.Value.Replace("'", "`")); break;

                case "race": Race = string.Intern(Formatting.FormatRace(property.Value)); break;

                case "caste": Caste = string.Intern(Formatting.InitCaps(property.Value.ToLower().Replace('_', ' '))); break;

                case "associated_type": AssociatedType = string.Intern(Formatting.InitCaps(property.Value.ToLower().Replace('_', ' '))); break;

                case "deity": Deity = true; property.Known = true; break;

                case "skeleton": Skeleton = true; property.Known = true; break;

                case "force": Force = true; property.Known = true; Race = "Force"; break;

                case "zombie": Zombie = true; property.Known = true; break;

                case "ghost": Ghost = true; property.Known = true; break;

                case "hf_link":     //Will be processed after all HFs have been loaded
                    world.AddHFtoHfLink(this, property);
                    property.Known = true;
                    List <string> knownSubProperties = new List <string> {
                        "hfid", "link_strength", "link_type"
                    };
                    if (property.SubProperties != null)
                    {
                        foreach (string subPropertyName in knownSubProperties)
                        {
                            Property subProperty = property.SubProperties.FirstOrDefault(property1 => property1.Name == subPropertyName);
                            if (subProperty != null)
                            {
                                subProperty.Known = true;
                            }
                        }
                    }

                    break;

                case "entity_link":
                case "entity_former_position_link":
                case "entity_position_link":
                    world.AddHFtoEntityLink(this, property);
                    property.Known = true;
                    if (property.SubProperties != null)
                    {
                        foreach (string subPropertyName in KnownEntitySubProperties)
                        {
                            Property subProperty = property.SubProperties.FirstOrDefault(property1 => property1.Name == subPropertyName);
                            if (subProperty != null)
                            {
                                subProperty.Known = true;
                            }
                        }
                    }

                    break;

                case "entity_reputation":
                    world.AddReputation(this, property);
                    property.Known = true;
                    if (property.SubProperties != null)
                    {
                        foreach (string subPropertyName in Reputation.KnownReputationSubProperties)
                        {
                            Property subProperty = property.SubProperties.FirstOrDefault(property1 => property1.Name == subPropertyName);
                            if (subProperty != null)
                            {
                                subProperty.Known = true;
                            }
                        }
                    }

                    break;

                case "entity_squad_link":
                case "entity_former_squad_link":
                    property.Known = true;
                    if (property.SubProperties != null)
                    {
                        foreach (string subPropertyName in KnownEntitySquadLinkProperties)
                        {
                            Property subProperty = property.SubProperties.FirstOrDefault(property1 => property1.Name == subPropertyName);
                            if (subProperty != null)
                            {
                                subProperty.Known = true;
                            }
                        }
                    }

                    break;

                case "relationship_profile_hf":
                case "relationship_profile_hf_visual":
                    property.Known = true;
                    if (property.SubProperties != null)
                    {
                        RelationshipProfiles.Add(new RelationshipProfileHf(property.SubProperties));
                    }
                    break;

                case "site_link":
                    world.AddHFtoSiteLink(this, property);
                    property.Known = true;
                    if (property.SubProperties != null)
                    {
                        foreach (string subPropertyName in KnownSiteLinkSubProperties)
                        {
                            Property subProperty = property.SubProperties.FirstOrDefault(property1 => property1.Name == subPropertyName);
                            if (subProperty != null)
                            {
                                subProperty.Known = true;
                            }
                        }
                    }

                    break;

                case "hf_skill":
                    property.Known = true;
                    if (property.SubProperties != null)
                    {
                        Skills.Add(new Skill(property.SubProperties));
                    }

                    break;

                case "active_interaction": ActiveInteractions.Add(string.Intern(property.Value)); break;

                case "interaction_knowledge": InteractionKnowledge.Add(string.Intern(property.Value)); break;

                case "animated": Animated = true; property.Known = true; break;

                case "animated_string": if (AnimatedType != "")
                    {
                        throw new Exception("Animated Type already exists.");
                    }
                    AnimatedType = Formatting.InitCaps(property.Value); break;

                case "journey_pet": JourneyPets.Add(Formatting.FormatRace(property.Value)); break;

                case "goal": Goal = Formatting.InitCaps(property.Value); break;

                case "sphere": Spheres.Add(property.Value); break;

                case "current_identity_id": CurrentIdentityId = Convert.ToInt32(property.Value); break;

                case "used_identity_id": UsedIdentityIds.Add(Convert.ToInt32(property.Value)); break;

                case "ent_pop_id": EntityPopulationId = Convert.ToInt32(property.Value); break;

                case "holds_artifact": HoldingArtifacts.Add(world.GetArtifact(Convert.ToInt32(property.Value))); break;

                case "adventurer":
                    Adventurer     = true;
                    property.Known = true;
                    break;

                case "breed_id":
                    BreedId = property.Value;
                    if (!string.IsNullOrWhiteSpace(BreedId))
                    {
                        if (world.Breeds.ContainsKey(BreedId))
                        {
                            world.Breeds[BreedId].Add(this);
                        }
                        else
                        {
                            world.Breeds.Add(BreedId, new List <HistoricalFigure> {
                                this
                            });
                        }
                    }
                    break;

                case "sex": property.Known = true; break;
                }
            }

            if (string.IsNullOrWhiteSpace(Name))
            {
                Name = !string.IsNullOrWhiteSpace(AnimatedType) ? Formatting.InitCaps(AnimatedType) : "(Unnamed)";
            }
            if (Adventurer)
            {
                world.AddPlayerRelatedDwarfObjects(this);
            }
        }