Пример #1
0
        public void BuildFamilyTree()
        {
            SocialSystem socialSystem = CivilManager.GetSystem <SocialSystem>();

            _tree = new MultiTreeNode <HumanRecord>(null);

            if (HumanRecord.MarriageRecord != null)
            {
                var grandFathers = socialSystem.HumanRecords.GetGrandFathers(HumanRecord, MaxDepth);
                for (int i = grandFathers.Count - 1; i >= 0; i--)
                {
                    var grandNode = new MultiTreeNode <HumanRecord>(grandFathers[i]);
                    _tree.Cildren.Add(grandNode);

                    var siblings = socialSystem.HumanRecords.GetSiblings(grandFathers[i]);
                    foreach (var sibling in siblings)
                    {
                        var siblingNode = new MultiTreeNode <HumanRecord>(sibling);
                        _tree.Cildren.Add(siblingNode);
                        addHumanChilds(siblingNode, MaxDepth);
                    }

                    addHumanChilds(grandNode, MaxDepth);
                }
            }
            else
            {
                var selfNode = new MultiTreeNode <HumanRecord>(HumanRecord);
                _tree.Cildren.Add(selfNode);
                addHumanChilds(selfNode, MaxDepth);
            }
        }
Пример #2
0
        public void Divorce()
        {
            SocialSystem socialSystem = CivilManager.GetSystem <SocialSystem>();

            var marriageRecord = socialSystem.MarriageRecords.GetRecord(this);

            if (marriageRecord != null)
            {
                socialSystem.DivorceRecords.CreateRecord(marriageRecord);
            }
            else
            {
                // TODO : the man is not married or spouse is died
            }
        }
Пример #3
0
        private void addHumanChilds(MultiTreeNode <HumanRecord> node, uint depth)
        {
            SocialSystem socialSystem = CivilManager.GetSystem <SocialSystem>();

            if (depth == 0)
            {
                return;
            }

            var children = socialSystem.HumanRecords.GetChildren(node.Data);

            foreach (var child in children)
            {
                var childNode = new MultiTreeNode <HumanRecord>(child);
                node.Cildren.Add(childNode);
                addHumanChilds(childNode, depth - 1);
            }
        }
Пример #4
0
        public void ProduceBaby()
        {
            SocialSystem socialSystem = CivilManager.GetSystem <SocialSystem>();

            var marriageRecord = socialSystem.MarriageRecords.GetRecord(this);
            var dieRecord      = socialSystem.DieRecords.GetRecord(this);

            if (marriageRecord == null || marriageRecord.RecordState == RecordState.Obselete ||
                dieRecord != null)
            {
                return;
            }

            HumanSex childSex  = RandomSelector.GetRandomEnumValue <HumanSex>();
            string   childName = RandomSelector.GetRandomName(childSex);

            socialSystem.HumanRecords.CreateRecord(marriageRecord, childName, childSex);
        }