Example #1
0
        // Copy trait and keep trait type id to identify it as the same relationship elsewhere in the program
        public Relationship(Relationship anotherRel, StoryEntity originatingEntity, StoryData world)
        {
            UInt64 nullTargetId = 0;
            if (originatingEntity.GetType() == typeof(Character))
            {
                nullTargetId = Character.getNoOneCharacter().Id;
            }
            else if (originatingEntity.GetType() == typeof(Environment))
            {

                nullTargetId = Environment.getNoWhereEnvironment().Id;
            }

            Constructor(anotherRel.Name, originatingEntity.Id, nullTargetId, 0.0, anotherRel.TypeId, world);
        }
Example #2
0
        public static void SynchronizeEntityRelationships(List<Environment> entities, List<Relationship> newList, StoryData world)
        {
            foreach (Environment currEntity in entities)
            {
                List<Relationship> properList = new List<Relationship>();

                foreach (Relationship newRel in newList)
                {
                   // Relationship oldRel = currEntity.getRelationshipByTypeId(newRel.TypeId);
                   // if (oldRel == null)
                    //{
                        Relationship convertedRel = new Relationship(newRel, currEntity, world);

                        Relationship oldRel = currEntity.findRelationshipByName(newRel.Name);
                        if (oldRel != null)
                        {
                            convertedRel.ToId = oldRel.ToId;
                            convertedRel.Strength = oldRel.Strength;
                        }

                        properList.Add(convertedRel);
                   // }
                   // else
                   // {
                        //oldRel.Name = newRel.Name;
                       // properList.Add(oldRel);
                    //}
                }
                currEntity.Relationships = properList;
            }
        }