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 }); }
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; } } }
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); }
public void ExecuteEnter(VisNode self, VisNode other) { if ((this.execNum++ == 0) || !this.outer.nonInstance) { this.outer.Enter(self, other); } }
public void ExecuteExit(VisNode self, VisNode other) { if ((--this.execNum == 0) || !this.outer.nonInstance) { this.outer.Exit(self, other); } }
public static void SetBorder(VisNode node, string borderColour) { node.color = new VisColor { border = borderColour }; node.borderWidth = 1; }
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}"; } }
protected void Reset() { this._visNode = base.GetComponent <VisNode>(); if (this._visNode != null) { this._visNode.__reactor = this; } }
public VisQuery.TryResult TryRemove(VisNode self, VisNode other) { if (this.applicable.Remove(other)) { this.num--; return(VisQuery.TryResult.Exit); } return(VisQuery.TryResult.Outside); }
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); }
internal void SPECTATOR_REMOVE(VisNode spectator) { try { this.React_SpectatorRemove(spectator); } catch (Exception exception) { Debug.LogError(exception, this); } }
internal void SPECTATOR_ADD(VisNode spectator) { try { this.React_SpectatorAdd(spectator); } catch (Exception exception) { Debug.LogError(exception, this); } }
void IDisposable.Dispose() { if (this._kind != ((Kind)0)) { this._kind = (Kind)0; this.next = dump; dump = this; this._other = null; this._self = null; } }
internal void SEE_REMOVE(VisNode lost) { try { this.React_SeeRemove(lost); } catch (Exception exception) { Debug.LogError(exception, this); } }
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; } }
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); } }
internal void SEE_ADD(VisNode spotted) { try { this.React_SeeAdd(spotted); } catch (Exception exception) { Debug.LogError(exception, this); } }
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; }
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); } }
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); } } }
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); }
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; } }
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); }
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"); } } }
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); }
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); }
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); }
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; } } }
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); } }
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); } } }
private bool Try(VisNode self, VisNode instigator) { Vis.Mask mask = self.traitMask; Vis.Mask mask1 = instigator.traitMask; return this.evaluation.Pass(mask, mask1); }
protected override void React_SeeAdd(VisNode node) { this.Exec(this.awareEnter, node, VisMessageInfo.Kind.SeeAdd); }
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; }
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; } }
protected void Reset() { this._visNode = base.GetComponent<VisNode>(); if (this._visNode) { this._visNode.__reactor = this; } }
protected virtual void React_SpectatorRemove(VisNode spectator) { }
protected virtual void React_SpectatorAdd(VisNode spectator) { }
protected virtual void React_SeeRemove(VisNode lost) { }
protected virtual void React_SeeAdd(VisNode spotted) { }
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; }
public bool Fits(VisNode other) { return this.applicable.Contains(other); }
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; }
protected override void React_SpectatorRemove(VisNode node) { this.Exec(this.awareEnter, node, VisMessageInfo.Kind.SpectatorRemove); }
private void Exec(string message, VisNode arg, VisMessageInfo.Kind kind) { }
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); } }