Пример #1
0
        public AddHfEntityLink(List <Property> properties, World world)
            : base(properties, world)
        {
            LinkType   = HfEntityLinkType.Unknown;
            PositionId = -1;
            foreach (Property property in properties)
            {
                switch (property.Name)
                {
                case "civ":
                case "civ_id":
                    Entity = world.GetEntity(Convert.ToInt32(property.Value));
                    break;

                case "hfid":
                case "histfig":
                    HistoricalFigure = world.GetHistoricalFigure(Convert.ToInt32(property.Value));
                    break;

                case "link":
                case "link_type":
                    switch (property.Value.Replace("_", " "))
                    {
                    case "position":
                        LinkType = HfEntityLinkType.Position;
                        break;

                    case "prisoner":
                        LinkType = HfEntityLinkType.Prisoner;
                        break;

                    case "enemy":
                        LinkType = HfEntityLinkType.Enemy;
                        break;

                    case "member":
                        LinkType = HfEntityLinkType.Member;
                        break;

                    case "slave":
                        LinkType = HfEntityLinkType.Slave;
                        break;

                    case "squad":
                        LinkType = HfEntityLinkType.Squad;
                        break;

                    case "former member":
                        LinkType = HfEntityLinkType.FormerMember;
                        break;

                    default:
                        world.ParsingErrors.Report("Unknown HfEntityLinkType: " + property.Value);
                        break;
                    }
                    break;

                case "position": Position = property.Value; break;

                case "position_id": PositionId = Convert.ToInt32(property.Value); break;

                case "appointer_hfid": AppointerHf = world.GetHistoricalFigure(Convert.ToInt32(property.Value)); break;

                case "promise_to_hfid": PromiseToHf = world.GetHistoricalFigure(Convert.ToInt32(property.Value)); break;
                }
            }

            HistoricalFigure.AddEvent(this);
            Entity.AddEvent(this);
            AppointerHf.AddEvent(this);
            if (PromiseToHf != HistoricalFigure)
            {
                PromiseToHf.AddEvent(this);
            }
        }