Esempio n. 1
0
        private static VisDataSet Convert(IGraph graph)
        {
            var nodeMapper = new VisNodeMapper();
            var edges      = new List <VisEdge>();

            var triples = graph.Triples;

            foreach (var triple in triples)
            {
                VisNode fromNode = nodeMapper.MapNode(triple.Subject);
                VisNode toNode   = nodeMapper.MapNode(triple.Object);

                // As Edge Label we simply use the URI Name:
                var edge = new VisEdge
                {
                    From  = fromNode.Id,
                    To    = toNode.Id,
                    Label = RdfUtils.MakeNodeString(triple.Predicate)
                };

                edges.Add(edge);
            }

            var nodes = nodeMapper.GetNodes();

            return(new VisDataSet
            {
                Nodes = nodes,
                Edges = edges
            });
        }
Esempio n. 2
0
        public void Execute(VisQuery.TryResult res, VisNode self, VisNode other)
        {
            switch (res)
            {
            case VisQuery.TryResult.Enter:
            {
                this.ExecuteEnter(self, other);
                break;
            }

            case VisQuery.TryResult.Stay:
            {
                break;
            }

            case VisQuery.TryResult.Exit:
            {
                this.ExecuteExit(self, other);
                break;
            }

            default:
            {
                goto case VisQuery.TryResult.Stay;
            }
            }
        }
Esempio n. 3
0
        public static VisNode CreateNode(Entity entity, string imagesRelativePath, string nodeType)
        {
            var sanitisedName        = ColourCodeRx.Replace(IconStringRx.Replace(entity.Name, ""), "");
            var sanitisedDescription = ColourCodeRx.Replace(IconStringRx.Replace(entity.Description, ""), "");
            var result = new VisNode {
                id       = entity.Id,
                label    = sanitisedName,
                title    = $"<b>{sanitisedName}</b> ({entity.Id})",
                image    = $"{imagesRelativePath}/{entity.Id}.png",
                hasImage = entity.IconFound,
                nodeType = nodeType
            };

            result.title = result.title + $"<br/><i>{sanitisedDescription}</i>";

            if (entity.Mod != "Stellaris")
            {
                result.title = result.title + $"<br/><b>Mod: </b>{entity.Mod}";
            }

            if (entity.DLC != null)
            {
                result.title = result.title + $"<br/><i>Requires the {entity.DLC} DLC</i>";
            }


            return(result);
        }
Esempio n. 4
0
 public void ExecuteEnter(VisNode self, VisNode other)
 {
     if ((this.execNum++ == 0) || !this.outer.nonInstance)
     {
         this.outer.Enter(self, other);
     }
 }
Esempio n. 5
0
 public void ExecuteExit(VisNode self, VisNode other)
 {
     if ((--this.execNum == 0) || !this.outer.nonInstance)
     {
         this.outer.Exit(self, other);
     }
 }
Esempio n. 6
0
 public static void SetBorder(VisNode node, string borderColour)
 {
     node.color = new VisColor {
         border = borderColour
     };
     node.borderWidth = 1;
 }
Esempio n. 7
0
        public static void AddModifiersToNode(ILocalisationApiHelper localisation, VisNode node,
                                              IDictionary <string, string> modifiers,
                                              Entity source,
                                              bool localiseKeys = true)
        {
            foreach (var modifierNodeKeyValue in modifiers)
            {
                string key    = localiseKeys ? GetPotentialLocalisationKeys(localisation, modifierNodeKeyValue.Key) : modifierNodeKeyValue.Key;
                string prefix = "";
                string suffix = "";
                string value  = modifierNodeKeyValue.Value;
                try {
                    if (modifierNodeKeyValue.Key.ToUpperInvariant().EndsWith("ADD"))
                    {
                        double intValue = value.ToDouble();
                        prefix = intValue >= 0 ? "+" : "";
                    }

                    if (modifierNodeKeyValue.Key.ToUpperInvariant().EndsWith("MULT"))
                    {
                        int percentageValue = (int)(value.ToDouble() * 100);
                        prefix = percentageValue >= 0 ? "+" : "";
                        suffix = "%";
                        value  = percentageValue.ToString(CultureInfo.InvariantCulture);
                    }
                }
                catch (FormatException e) {
                    Log.Logger.Error(e, "Error parsing {nodeId} from {filePath}", node.id, source.FilePath);
                }

                node.title = $"{node.title}<br/><b>{key}:</b> {prefix}{value}{suffix}";
            }
        }
Esempio n. 8
0
 protected void Reset()
 {
     this._visNode = base.GetComponent <VisNode>();
     if (this._visNode != null)
     {
         this._visNode.__reactor = this;
     }
 }
Esempio n. 9
0
 public VisQuery.TryResult TryRemove(VisNode self, VisNode other)
 {
     if (this.applicable.Remove(other))
     {
         this.num--;
         return(VisQuery.TryResult.Exit);
     }
     return(VisQuery.TryResult.Outside);
 }
Esempio n. 10
0
 public VisQuery.TryResult TryRemove(VisNode self, VisNode other)
 {
     if (!this.applicable.Remove(other))
     {
         return(VisQuery.TryResult.Outside);
     }
     VisQuery.Instance instance = this;
     instance.num = instance.num - 1;
     return(VisQuery.TryResult.Exit);
 }
Esempio n. 11
0
 internal void SPECTATOR_REMOVE(VisNode spectator)
 {
     try
     {
         this.React_SpectatorRemove(spectator);
     }
     catch (Exception exception)
     {
         Debug.LogError(exception, this);
     }
 }
Esempio n. 12
0
 internal void SPECTATOR_ADD(VisNode spectator)
 {
     try
     {
         this.React_SpectatorAdd(spectator);
     }
     catch (Exception exception)
     {
         Debug.LogError(exception, this);
     }
 }
Esempio n. 13
0
 void IDisposable.Dispose()
 {
     if (this._kind != ((Kind)0))
     {
         this._kind  = (Kind)0;
         this.next   = dump;
         dump        = this;
         this._other = null;
         this._self  = null;
     }
 }
Esempio n. 14
0
 internal void SEE_REMOVE(VisNode lost)
 {
     try
     {
         this.React_SeeRemove(lost);
     }
     catch (Exception exception)
     {
         Debug.LogError(exception, this);
     }
 }
Esempio n. 15
0
 void System.IDisposable.Dispose()
 {
     if ((int)this._kind != 0)
     {
         this._kind          = (VisMessageInfo.Kind) 0;
         this.next           = VisMessageInfo.dump;
         VisMessageInfo.dump = this;
         this._other         = null;
         this._self          = null;
     }
 }
Esempio n. 16
0
 public void Clear(VisNode self)
 {
     while (--this.num >= 0)
     {
         HSetIter <VisNode> enumerator = this.applicable.GetEnumerator();
         enumerator.MoveNext();
         VisNode current = enumerator.Current;
         enumerator.Dispose();
         this.TryRemove(self, current);
     }
 }
Esempio n. 17
0
 internal void SEE_ADD(VisNode spotted)
 {
     try
     {
         this.React_SeeAdd(spotted);
     }
     catch (Exception exception)
     {
         Debug.LogError(exception, this);
     }
 }
Esempio n. 18
0
 internal void SEE_ADD(VisNode spotted)
 {
     try
     {
         this.React_SeeAdd(spotted);
     }
     catch (Exception exception)
     {
         Debug.LogError(exception, this);
     }
 }
Esempio n. 19
0
        public static void SetLevel(VisNode node, Entity entity, IDictionary <string, VisNode> prereqTechNodeLookup)
        {
            // find the highest prerequisite tech level and then add 1 to it to ensure it is rendered in a sensible place.
            var highestLevelOfPrerequisiteTechs = entity.Prerequisites.Select(x => prereqTechNodeLookup[x.Id].level).Max();

            if (!highestLevelOfPrerequisiteTechs.HasValue)
            {
                throw new Exception(entity.Name + " Had no prerequiste levels: " + entity.FilePath);
            }

            node.level = highestLevelOfPrerequisiteTechs + 1;
        }
Esempio n. 20
0
        public void ExecuteExit(VisNode self, VisNode other)
        {
            VisQuery.Instance instance = this;
            int num  = instance.execNum - 1;
            int num1 = num;

            instance.execNum = num;
            if (num1 == 0 || !this.outer.nonInstance)
            {
                this.outer.Exit(self, other);
            }
        }
Esempio n. 21
0
    private void Exit(VisNode a, VisNode b)
    {
        IDMain idMain     = a.idMain;
        IDMain instigator = !this.nonInstance ? b.idMain : null;

        for (int i = 0; i < this.actions.Length; i++)
        {
            if (this.actions[i] != null)
            {
                this.actions[i].UnAcomplish(idMain, instigator);
            }
        }
    }
Esempio n. 22
0
 public VisQuery.TryResult TryAdd(VisNode self, VisNode other)
 {
     if (!this.outer.Try(self, other))
     {
         return(this.TryRemove(self, other));
     }
     if (this.applicable.Add(other))
     {
         this.num++;
         return(VisQuery.TryResult.Enter);
     }
     return(VisQuery.TryResult.Stay);
 }
Esempio n. 23
0
        public void Execute(VisQuery.TryResult res, VisNode self, VisNode other)
        {
            switch (res)
            {
            case VisQuery.TryResult.Enter:
                this.ExecuteEnter(self, other);
                break;

            case VisQuery.TryResult.Exit:
                this.ExecuteExit(self, other);
                break;
            }
        }
Esempio n. 24
0
 public VisQuery.TryResult TryAdd(VisNode self, VisNode other)
 {
     if (!this.outer.Try(self, other))
     {
         return(this.TryRemove(self, other));
     }
     if (!this.applicable.Add(other))
     {
         return(VisQuery.TryResult.Stay);
     }
     VisQuery.Instance instance = this;
     instance.num = instance.num + 1;
     return(VisQuery.TryResult.Enter);
 }
Esempio n. 25
0
        public static void SetGestaltAvailability(VisNode node, Entity entity)
        {
            if (entity is IGestaltAvailability iga)
            {
                if (iga.Machines.HasValue)
                {
                    node.title = node.title + "<br/>" + (!iga.Machines.Value ? "Not for machine intelligence" : "Machine intelligence");
                }

                if (iga.Gestalt.HasValue)
                {
                    node.title = node.title + "<br/>" + (!iga.Gestalt.Value ? "Not for gestalt consciousness" : "Gestalt consciousness");
                }
            }
        }
Esempio n. 26
0
        private VisNode BuildRootNode(TechArea area, string imagesPath)
        {
            var relativePath = CreateRelativePath(imagesPath);
            var areaName     = area.ToString();
            var result       = new VisNode {
                id       = BuildRootNodeName(area),
                label    = localisationApi.GetName(areaName.ToLower()),
                group    = areaName,
                image    = relativePath + "/" + BuildRootNodeName(area) + ".png",
                hasImage = true,
                level    = 0,
                nodeType = "tech"
            };

            return(result);
        }
Esempio n. 27
0
    public static VisMessageInfo Create(VisReactor issuer, VisNode other, VisMessageInfo.Kind kind)
    {
        VisMessageInfo visMessageInfo;

        if (VisMessageInfo.dump == null)
        {
            visMessageInfo = new VisMessageInfo();
        }
        else
        {
            visMessageInfo      = VisMessageInfo.dump;
            VisMessageInfo.dump = visMessageInfo.next;
            visMessageInfo.next = null;
        }
        visMessageInfo._self  = issuer;
        visMessageInfo._other = other;
        visMessageInfo._kind  = kind;
        return(visMessageInfo);
    }
Esempio n. 28
0
    public static VisMessageInfo Create(VisReactor issuer, VisNode other, Kind kind)
    {
        VisMessageInfo dump;

        if (VisMessageInfo.dump != null)
        {
            dump = VisMessageInfo.dump;
            VisMessageInfo.dump = dump.next;
            dump.next           = null;
        }
        else
        {
            dump = new VisMessageInfo();
        }
        dump._self  = issuer;
        dump._other = other;
        dump._kind  = kind;
        return(dump);
    }
Esempio n. 29
0
 private void Update()
 {
     if (!isUpdatingVisiblity)
     {
         isUpdatingVisiblity = true;
         try
         {
             VisNode.Process();
         }
         catch (Exception exception)
         {
             Debug.LogError(string.Format("{0}\n-- Vis data potentially compromised\n", exception));
         }
         finally
         {
             isUpdatingVisiblity = false;
         }
     }
 }
Esempio n. 30
0
 public void Clear(VisNode self)
 {
     while (true)
     {
         VisQuery.Instance instance = this;
         int num  = instance.num - 1;
         int num1 = num;
         instance.num = num;
         if (num1 < 0)
         {
             break;
         }
         HSetIter <VisNode> enumerator = this.applicable.GetEnumerator();
         enumerator.MoveNext();
         VisNode current = enumerator.Current;
         enumerator.Dispose();
         this.TryRemove(self, current);
     }
 }
Esempio n. 31
0
 private void Exit(VisNode a, VisNode b)
 {
     IDMain dMain;
     IDMain dMain1 = a.idMain;
     if (!this.nonInstance)
     {
         dMain = b.idMain;
     }
     else
     {
         dMain = null;
     }
     IDMain dMain2 = dMain;
     for (int i = 0; i < (int)this.actions.Length; i++)
     {
         if (this.actions[i])
         {
             this.actions[i].UnAcomplish(dMain1, dMain2);
         }
     }
 }
Esempio n. 32
0
    private void Exit(VisNode a, VisNode b)
    {
        IDMain dMain;
        IDMain dMain1 = a.idMain;

        if (!this.nonInstance)
        {
            dMain = b.idMain;
        }
        else
        {
            dMain = null;
        }
        IDMain dMain2 = dMain;

        for (int i = 0; i < (int)this.actions.Length; i++)
        {
            if (this.actions[i])
            {
                this.actions[i].UnAcomplish(dMain1, dMain2);
            }
        }
    }
Esempio n. 33
0
 private bool Try(VisNode self, VisNode instigator)
 {
     Vis.Mask mask = self.traitMask;
     Vis.Mask mask1 = instigator.traitMask;
     return this.evaluation.Pass(mask, mask1);
 }
Esempio n. 34
0
 protected override void React_SeeAdd(VisNode node)
 {
     this.Exec(this.awareEnter, node, VisMessageInfo.Kind.SeeAdd);
 }
Esempio n. 35
0
 public void Execute(VisQuery.TryResult res, VisNode self, VisNode other)
 {
     switch (res)
     {
         case VisQuery.TryResult.Enter:
         {
             this.ExecuteEnter(self, other);
             break;
         }
         case VisQuery.TryResult.Stay:
         {
             break;
         }
         case VisQuery.TryResult.Exit:
         {
             this.ExecuteExit(self, other);
             break;
         }
         default:
         {
             goto case VisQuery.TryResult.Stay;
         }
     }
 }
Esempio n. 36
0
 internal void SPECTATOR_REMOVE(VisNode spectator)
 {
     try
     {
         this.React_SpectatorRemove(spectator);
     }
     catch (Exception exception)
     {
         Debug.LogError(exception, this);
     }
 }
Esempio n. 37
0
 public void ExecuteExit(VisNode self, VisNode other)
 {
     VisQuery.Instance instance = this;
     int num = instance.execNum - 1;
     int num1 = num;
     instance.execNum = num;
     if (num1 == 0 || !this.outer.nonInstance)
     {
         this.outer.Exit(self, other);
     }
 }
Esempio n. 38
0
 public VisQuery.TryResult TryAdd(VisNode self, VisNode other)
 {
     if (!this.outer.Try(self, other))
     {
         return this.TryRemove(self, other);
     }
     if (!this.applicable.Add(other))
     {
         return VisQuery.TryResult.Stay;
     }
     VisQuery.Instance instance = this;
     instance.num = instance.num + 1;
     return VisQuery.TryResult.Enter;
 }
Esempio n. 39
0
 void System.IDisposable.Dispose()
 {
     if ((int)this._kind != 0)
     {
         this._kind = (VisMessageInfo.Kind)0;
         this.next = VisMessageInfo.dump;
         VisMessageInfo.dump = this;
         this._other = null;
         this._self = null;
     }
 }
Esempio n. 40
0
 protected void Reset()
 {
     this._visNode = base.GetComponent<VisNode>();
     if (this._visNode)
     {
         this._visNode.__reactor = this;
     }
 }
Esempio n. 41
0
 protected virtual void React_SpectatorRemove(VisNode spectator)
 {
 }
Esempio n. 42
0
 protected virtual void React_SpectatorAdd(VisNode spectator)
 {
 }
Esempio n. 43
0
 protected virtual void React_SeeRemove(VisNode lost)
 {
 }
Esempio n. 44
0
 protected virtual void React_SeeAdd(VisNode spotted)
 {
 }
Esempio n. 45
0
 public VisQuery.TryResult TryRemove(VisNode self, VisNode other)
 {
     if (!this.applicable.Remove(other))
     {
         return VisQuery.TryResult.Outside;
     }
     VisQuery.Instance instance = this;
     instance.num = instance.num - 1;
     return VisQuery.TryResult.Exit;
 }
Esempio n. 46
0
 internal void SEE_REMOVE(VisNode lost)
 {
     try
     {
         this.React_SeeRemove(lost);
     }
     catch (Exception exception)
     {
         Debug.LogError(exception, this);
     }
 }
Esempio n. 47
0
 public bool Fits(VisNode other)
 {
     return this.applicable.Contains(other);
 }
Esempio n. 48
0
 public static VisMessageInfo Create(VisReactor issuer, VisNode other, VisMessageInfo.Kind kind)
 {
     VisMessageInfo visMessageInfo;
     if (VisMessageInfo.dump == null)
     {
         visMessageInfo = new VisMessageInfo();
     }
     else
     {
         visMessageInfo = VisMessageInfo.dump;
         VisMessageInfo.dump = visMessageInfo.next;
         visMessageInfo.next = null;
     }
     visMessageInfo._self = issuer;
     visMessageInfo._other = other;
     visMessageInfo._kind = kind;
     return visMessageInfo;
 }
Esempio n. 49
0
 protected override void React_SpectatorRemove(VisNode node)
 {
     this.Exec(this.awareEnter, node, VisMessageInfo.Kind.SpectatorRemove);
 }
Esempio n. 50
0
 internal void SPECTATOR_ADD(VisNode spectator)
 {
     try
     {
         this.React_SpectatorAdd(spectator);
     }
     catch (Exception exception)
     {
         Debug.LogError(exception, this);
     }
 }
Esempio n. 51
0
 private void Exec(string message, VisNode arg, VisMessageInfo.Kind kind)
 {
 }
Esempio n. 52
0
 public void Clear(VisNode self)
 {
     while (true)
     {
         VisQuery.Instance instance = this;
         int num = instance.num - 1;
         int num1 = num;
         instance.num = num;
         if (num1 < 0)
         {
             break;
         }
         HSetIter<VisNode> enumerator = this.applicable.GetEnumerator();
         enumerator.MoveNext();
         VisNode current = enumerator.Current;
         enumerator.Dispose();
         this.TryRemove(self, current);
     }
 }