예제 #1
0
        public override void Draw()
        {
            // get direction between nodes so we can offset our lines perpendicular to the line between nodes.
            var factionA = (nodeA as FactionNode)?.faction;
            var factionB = (nodeB as FactionNode)?.faction;

            if (factionA == null || factionB == null)
            {
                Log.Error("FactionEdge with non-FactionNode node(s), or null faction.");
                return;
            }

            // get relevant opinion. Opinion between non-player faction is symmetric, but between player and faction IS NOT - while this has no gameplay impact, it's confusing as f**k.
            float opinion;

            if (factionA == Faction.OfPlayer)
            {
                opinion = factionB.GoodwillWith(factionA);
            }
            else
            {
                opinion = factionA.GoodwillWith(factionB);
            }

            // draw lines
            Helpers.DrawBiDirectionalArrow(nodeA.position, nodeB.position, RelationsHelper.GetRelationColor(opinion));
        }
예제 #2
0
        public void AddObject(GuiItem item, string name_base)
        {
            item.parent = this;
            if (item is INeedRefresh)
            {
                RefreshObject((INeedRefresh)item);
            }
            item.id = RegisterItemID(name_base, item);
            item.Invalidate();
            Undo.Push(new CreateOperation((IRemoveable)item), false);

            // add relations
            if (item is GuiClass)
            {
                GuiClass cl = (GuiClass)item;
                for (int i = 0; i < active_objects.Count; i++)
                {
                    GuiObject obj = (GuiObject)active_objects[i];
                    if (obj is GuiClass)
                    {
                        foreach (UmlRelation rel in RelationsHelper.GetRelations(((GuiClass)obj).st, proj.model))
                        {
                            if (rel.dest == cl.st || rel.src == cl.st)
                            {
                                NewRelation(rel);
                            }
                        }
                    }
                }
            }
        }
예제 #3
0
        public override void Draw()
        {
            var relation = nodeA.pawn.GetMostImportantVisibleRelation(nodeB.pawn);

            // draw lines
            Helpers.DrawArrow(nodeA.position, nodeB.position, RelationsHelper.GetRelationColor(relation, nodeA.pawn.OpinionOfCached(nodeB.pawn)));
            Helpers.DrawArrow(nodeB.position, nodeA.position, RelationsHelper.GetRelationColor(relation, nodeB.pawn.OpinionOfCached(nodeA.pawn)));
        }
예제 #4
0
        private void UpdateConnections()
        {
            // save current connections
            Hashtable ht = new Hashtable();

            foreach (GuiObject obj in active_objects)
            {
                if (obj is GuiConnection)
                {
                    string id = ((GuiConnection)obj).relation_id;
                    if (id != null)
                    {
                        ht[id] = obj;
                    }
                }
            }

            // add new relations
            for (int i = 0; i < active_objects.Count; i++)
            {
                GuiObject obj = (GuiObject)active_objects[i];
                if (obj is GuiClass)
                {
                    foreach (UmlRelation rel in RelationsHelper.GetRelations(((GuiClass)obj).st, proj.model))
                    {
                        if (ht.ContainsKey(rel.ID))
                        {
                            ((GuiConnection)ht[rel.ID]).AdjustRelation(rel);
                            ht.Remove(rel.ID);
                        }
                        else
                        {
                            NewRelation(rel);
                        }
                    }
                }
            }

            // remove old
            foreach (GuiConnection old_conn in ht.Values)
            {
                Destroy((IRemoveable)old_conn);
            }
        }