public Problems RoadSegmentSurfaceAttributeFromPositionNotEqualToZero(AttributeId attributeId, RoadSegmentPosition fromPosition) { return(new Problems( _problems.Add( new Error(nameof(RoadSegmentSurfaceAttributeFromPositionNotEqualToZero), new ProblemParameter("AttributeId", attributeId.ToInt32().ToString()), new ProblemParameter("FromPosition", fromPosition.ToString()))))); }
public Problems RoadSegmentSurfaceAttributeToPositionNotEqualToLength(AttributeId attributeId, RoadSegmentPosition toPosition, double length) { return(new Problems( _problems.Add( new Error(nameof(RoadSegmentSurfaceAttributeToPositionNotEqualToLength), new ProblemParameter("AttributeId", attributeId.ToInt32().ToString()), new ProblemParameter("ToPosition", toPosition.ToString()), new ProblemParameter("Length", length.ToString(CultureInfo.InvariantCulture)))))); }
public AddRoadSegmentToEuropeanRoad( AttributeId temporaryAttributeId, RoadSegmentId segmentId, EuropeanRoadNumber number) { TemporaryAttributeId = temporaryAttributeId; SegmentId = segmentId; Number = number; }
public RoadSegmentWidthAttribute( AttributeId temporaryId, RoadSegmentWidth width, RoadSegmentPosition from, RoadSegmentPosition to ) : base(temporaryId, from, to) { Width = width; }
public RoadSegmentSurfaceAttribute( AttributeId temporaryId, RoadSegmentSurfaceType type, RoadSegmentPosition from, RoadSegmentPosition to ) : base(temporaryId, from, to) { Type = type; }
private RoadNetworkView Given(Messages.RoadSegmentAdded @event) { var id = new RoadSegmentId(@event.Id); var start = new RoadNodeId(@event.StartNodeId); var end = new RoadNodeId(@event.EndNodeId); var attributeHash = AttributeHash.None .With(RoadSegmentAccessRestriction.Parse(@event.AccessRestriction)) .With(RoadSegmentCategory.Parse(@event.Category)) .With(RoadSegmentMorphology.Parse(@event.Morphology)) .With(RoadSegmentStatus.Parse(@event.Status)) .WithLeftSide(@event.LeftSide.StreetNameId.HasValue ? new CrabStreetnameId(@event.LeftSide.StreetNameId.Value) : new CrabStreetnameId?()) .WithRightSide(@event.RightSide.StreetNameId.HasValue ? new CrabStreetnameId(@event.RightSide.StreetNameId.Value) : new CrabStreetnameId?()) .With(new OrganizationId(@event.MaintenanceAuthority.Code)); var segment = new RoadSegment( id, GeometryTranslator.Translate(@event.Geometry), start, end, attributeHash); return(new RoadNetworkView( _nodes .TryReplace(start, node => node.ConnectWith(id)) .TryReplace(end, node => node.ConnectWith(id)), _segments.Add(id, segment), _maximumNodeId, RoadSegmentId.Max(id, _maximumSegmentId), _maximumGradeSeparatedJunctionId, _maximumEuropeanRoadAttributeId, _maximumNationalRoadAttributeId, _maximumNumberedRoadAttributeId, @event.Lanes.Length != 0 ? AttributeId.Max( new AttributeId(@event.Lanes.Max(_ => _.AttributeId)), _maximumLaneAttributeId) : _maximumLaneAttributeId, @event.Widths.Length != 0 ? AttributeId.Max( new AttributeId(@event.Widths.Max(_ => _.AttributeId)), _maximumWidthAttributeId) : _maximumWidthAttributeId, @event.Surfaces.Length != 0 ? AttributeId.Max( new AttributeId(@event.Surfaces.Max(_ => _.AttributeId)), _maximumSurfaceAttributeId) : _maximumSurfaceAttributeId, _segmentReusableLaneAttributeIdentifiers.AddOrMergeDistinct(id, @event.Lanes.Select(lane => new AttributeId(lane.AttributeId))), _segmentReusableWidthAttributeIdentifiers.AddOrMergeDistinct(id, @event.Widths.Select(width => new AttributeId(width.AttributeId))), _segmentReusableSurfaceAttributeIdentifiers.AddOrMergeDistinct(id, @event.Surfaces.Select(surface => new AttributeId(surface.AttributeId))) )); }
public AddRoadSegmentToNationalRoad( AttributeId temporaryAttributeId, RoadSegmentId segmentId, NationalRoadNumber number) { TemporaryAttributeId = temporaryAttributeId; SegmentId = segmentId; Number = number; }
public void Init(AttributeId attributeName, float value = 0) { var definition = AttributeRepository.Current.GetDefinition(attributeName); var attribute = new ActorAttribute(definition); attribute.Value = value; Attributes.Add(attribute); _attributesMap[attributeName] = attribute; }
public SimpleAttribute(AttributeId attributeId, T defaultValue) { _attributeId = attributeId; _defaultValue = defaultValue; if (typeof(T) != typeof(int) && typeof(T) != typeof(float)) { throw new NotSupportedException("Generic type T must be either int or float."); } }
public Problems RoadSegmentSurfaceAttributesNotAdjacent(AttributeId attributeId1, RoadSegmentPosition toPosition, AttributeId attributeId2, RoadSegmentPosition fromPosition) { return(new Problems( _problems.Add( new Error(nameof(RoadSegmentSurfaceAttributesNotAdjacent), new ProblemParameter("AttributeId", attributeId1.ToInt32().ToString()), new ProblemParameter("ToPosition", toPosition.ToString()), new ProblemParameter("AttributeId", attributeId2.ToInt32().ToString()), new ProblemParameter("FromPosition", fromPosition.ToString()))))); }
public RoadSegmentSurfaceAttribute( AttributeId id, AttributeId temporaryId, RoadSegmentSurfaceType type, RoadSegmentPosition from, RoadSegmentPosition to, GeometryVersion asOfGeometryVersion ) : base(id, temporaryId, from, to, asOfGeometryVersion) { Type = type; }
public RoadSegmentWidthAttribute( AttributeId id, AttributeId temporaryId, RoadSegmentWidth width, RoadSegmentPosition from, RoadSegmentPosition to, GeometryVersion asOfGeometryVersion ) : base(id, temporaryId, from, to, asOfGeometryVersion) { Width = width; }
public double GetAttributeValue(AttributeId attributeId, int modifier = -1) { var descriptor = AttributeCache.Current.GetDescriptor(attributeId); var value = default(AttributeValue); if (_attributeReader == null || ACD == null || _attributeReader.TryGetAttributeValue(ACD.FastAttribGroupID, attributeId, modifier, out value) == false) { return descriptor.DataType == typeof(int) ? descriptor.DefaultValue : new AttributeValue { Int32 = descriptor.DefaultValue } }
public RoadSegmentLaneAttribute( AttributeId temporaryId, RoadSegmentLaneCount count, RoadSegmentLaneDirection direction, RoadSegmentPosition from, RoadSegmentPosition to ) : base(temporaryId, from, to) { Count = count; Direction = direction; }
/// <summary> /// Compares this attribute reference to another. /// </summary> /// <param name="other">The attribute reference to compare against.</param> /// <returns>Zero if references are identical.</returns> public int CompareTo(AttributeReference other) { int refDiff = _fileReference.CompareTo(other._fileReference); if (refDiff != 0) { return(refDiff); } return(AttributeId.CompareTo(other.AttributeId)); }
public static FileError IdentifierNotUnique(this IDbaseFileRecordProblemBuilder builder, AttributeId identifier, RecordNumber takenByRecordNumber) { return(builder .Error(nameof(IdentifierNotUnique)) .WithParameters( new ProblemParameter("Identifier", identifier.ToString()), new ProblemParameter("TakenByRecordNumber", takenByRecordNumber.ToString()) ) .Build()); }
public RoadSegmentLaneAttribute( AttributeId id, AttributeId temporaryId, RoadSegmentLaneCount count, RoadSegmentLaneDirection direction, RoadSegmentPosition from, RoadSegmentPosition to, GeometryVersion asOfGeometryVersion ) : base(id, temporaryId, from, to, asOfGeometryVersion) { Count = count; Direction = direction; }
public AddRoadSegmentToNumberedRoad( AttributeId temporaryAttributeId, RoadSegmentId segmentId, NumberedRoadNumber number, RoadSegmentNumberedRoadDirection direction, RoadSegmentNumberedRoadOrdinal ordinal) { TemporaryAttributeId = temporaryAttributeId; SegmentId = segmentId; Number = number; Direction = direction; Ordinal = ordinal; }
public bool TryGetAttributeValue(int groupId, AttributeId attribId, int modifier, out AttributeValue value) { value = default(AttributeValue); var group = _groupCache.Items[(short)groupId]; if (group == null) { return(false); } var key = (AttributeKey)((modifier << 12) + ((int)attribId & 0xFFF)); var map = (group.Flags & 4) != 0 ? group.PtrMap.Dereference() : null; if (map == null) { map = group.Map; } map.TakeSnapshot(); if (map.Count == 0) { return(false); } var hash = key.GetHashCode(); var index = map.Mask & hash; var address = map.Buckets[index].ValueAddress; if (address == 0) { return(false); } while (true) { if (address == 0) { return(false); } var entry = _allocationCache.Read(address); if (entry.Key == key) { value = entry.Value; return(true); } address = entry.Next.ValueAddress; } }
public TalentAttribute Create(AttributeId id) { IAttributeFactory factory; if (m_AttributeFactory.TryGetValue(id, out factory)) { return(factory.Create()); } else { LogSystem.Error("-----create talent failed: not find talent type {0}", id); } return(null); }
public double GetAttributeValue(int groupId, AttributeId attributeId, int modifier = -1) { AttributeValue value; var descriptor = MemoryContext.Current.DataSegment.AttributeDescriptors[(int)attributeId]; if (!TryGetAttributeValue(groupId, attributeId, modifier, out value)) { value = new AttributeValue { Int32 = descriptor.DefaultValue } } ; return(descriptor.DataType == typeof(int) ? value.Int32 : value.Single); }
public bool TryGetAttributeValue(int groupId, AttributeId attribId, int modifier, out AttributeValue value) { int key = (modifier << 12) + ((int)attribId & 0xFFF); var group = FastAttribGroup.Get(groupId); if (group != null) { if (((group.x004_Flags & 4) != 0 && group.x00C_PtrMap != null && group.x00C_PtrMap.TryGetValue(key, out value, GetHashOfKey)) || group.x010_Map.TryGetValue(key, out value, GetHashOfKey)) { return(true); } } value = default(AttributeValue); return(false); }
protected DynamicRoadSegmentAttribute( AttributeId temporaryId, RoadSegmentPosition from, RoadSegmentPosition to ) { if (from >= to) { throw new ArgumentException(nameof(From), $"The from position ({from.ToDecimal()}) must be less than the to position ({to.ToDecimal()})."); } TemporaryId = temporaryId; From = from; To = to; }
private Dictionary <string, string> GetAttributes() { var dictionary = new Dictionary <string, string>(); for (var index = 0; index < dgAttributeMap.Rows.Count - 1; index++) { var row = dgAttributeMap.Rows[index]; var id = new AttributeId(); if (Enum.TryParse(row.Cells[0].Value.ToString(), out id)) { var description = id.GetDescription(); dictionary.Add(description, row.Cells[1].Value.ToString()); } } return(dictionary); }
public bool TryGetAttributeValue(int groupId, AttributeId attribId, int modifier, out AttributeValue value) { int key = (modifier << 12) + ((int)attribId & 0xFFF); var group = MemoryContext.Current.DataSegment.ObjectManager.FastAttrib.FastAttribGroups[groupId]; if (group != null) { value = default(AttributeValue); if (((group.Flags & 4) != 0 && group.PtrMap.Dereference()?.TryGetValue(key, out value) == true) || group.Map != null && group.Map.TryGetValue(key, out value)) { return(true); } } value = default(AttributeValue); return(false); }
private RoadNetworkView Given(Messages.RoadSegmentAddedToNumberedRoad @event) { return(new RoadNetworkView( _nodes, _segments, _maximumNodeId, _maximumSegmentId, _maximumGradeSeparatedJunctionId, _maximumEuropeanRoadAttributeId, _maximumNationalRoadAttributeId, AttributeId.Max(new AttributeId(@event.AttributeId), _maximumNumberedRoadAttributeId), _maximumLaneAttributeId, _maximumWidthAttributeId, _maximumSurfaceAttributeId, _segmentReusableLaneAttributeIdentifiers, _segmentReusableWidthAttributeIdentifiers, _segmentReusableSurfaceAttributeIdentifiers)); }
private RoadNetworkView With(AddRoadSegmentToNumberedRoad command) { return(new RoadNetworkView( _nodes, _segments, _maximumNodeId, _maximumSegmentId, _maximumGradeSeparatedJunctionId, _maximumEuropeanRoadAttributeId, _maximumNationalRoadAttributeId, AttributeId.Max(command.AttributeId, _maximumNumberedRoadAttributeId), _maximumLaneAttributeId, _maximumWidthAttributeId, _maximumSurfaceAttributeId, _segmentReusableLaneAttributeIdentifiers, _segmentReusableWidthAttributeIdentifiers, _segmentReusableSurfaceAttributeIdentifiers)); }
public static double GetAttributeValue(this ActorCommonData acd, AttributeId attribId, int modifier = -1) { var attribDef = Engine.Current.AttributeDescriptors[(int)attribId]; if (attribDef == null) { throw new ArgumentOutOfRangeException("attribId"); } AttributeValue value; if (!TryGetAttributeValue(acd, attribId, modifier, out value)) { return(Int32OrSingleToDouble(attribDef.x04_DefaultValue, attribDef.x10_DataType == 1)); } return(attribDef.x10_DataType == 1 ? value.Int32 : value.Single); }
public TalentAttribute GetTalentAttribute(AttributeId attr_id) { for (int i = 0; i < (int)EquipSlot.kMax; i++) { TalentCard card = null; if (m_EquipTalents.TryGetValue((EquipSlot)i, out card)) { for (int phase = 0; phase < (int)TalentPhase.kMax; phase++) { TalentAttribute attr = card.GetAttribute((TalentPhase)phase); if (attr != null && attr.GetId() == attr_id) { return(attr); } } } } return(null); }
/// <summary> /// Gets the next attribute value of the specified attribute for the specified scanner. /// </summary> /// <param name="scannerService"></param> /// <param name="scannerId"></param> /// <param name="attribute"></param> /// <returns></returns> /// <remarks> /// Can be used to create an asynchronous scanner attribute iterator. /// </remarks> public static IObservable <AttributeInfo> GetNextAttributeValueAsync( this ICoreScannerService scannerService, Int32 scannerId, AttributeId attributeId) { Contract.Requires(scannerService != null); Contract.Requires(scannerId > 0); XDocument inXml = new XDocument( new XElement("inArgs", new XElement("scannerID", scannerId), new XElement("cmdArgs", new XElement("arg-xml", new XElement("attrib_list", (Int32)attributeId))))); IObservable <AttributeInfo> resultAsync = scannerService .WhenCommandResponded() .Do(e => e.Status.ThrowIfError()) .SelectMany(e => e.OutXml .ParseXmlDocument() .Elements("outArgs")) .Where(outArgs => outArgs .Elements("scannerID") .All(e => e.Value.ToInt32().Equals(scannerId))) .SelectMany(outArgs => outArgs .Elements("arg-xml") .Elements("response")) .Where(response => response .Elements("opcode") .Select(opCode => (OperationCode)opCode.Value.ToInt32()) .All(opCode => opCode.Equals(OperationCode.GetNextAttribute))) .FirstAsync() .RunAsync(CancellationToken.None) .SelectMany(response => response .Elements("attrib_list") .Elements("attribute") .Select(attribute => AttributeInfo.Parse(attribute.ToString()))); scannerService .ExecuteCommandAsync(OperationCode.GetNextAttribute, inXml.ToString()); return(resultAsync); }
public float this[AttributeId name] { get { var attribute = _attributesMap[name]; if (attribute.Template.IsComputed) return attribute.Template.Function(this); else return attribute.Value; } set { var attribute = _attributesMap[name]; if (attribute.Template.IsComputed) throw new Exception(); attribute.Value = value; attribute.IsDirty = true; } }
/* Methods */ /// <summary> /// For an <see cref="AttributeId" /> value, returns the corresponding /// <see cref="CharacterAttributeId" /> value, if any. /// </summary> /// <param name="attributeId"> /// The ID of the EVE attribute to convert to a character attribute. /// </param> /// <returns> /// The <see cref="CharacterAttributeId" /> which corresponds to the value /// specified in <paramref name="attributeId" />. /// </returns> /// <exception cref="InvalidOperationException"> /// Thrown if <paramref name="attributeId" /> does not correspond to a /// character attribute ID. /// </exception> public static CharacterAttributeId AttributeToCharacterAttribute(AttributeId attributeId) { switch (attributeId) { case AttributeId.Charisma: return(CharacterAttributeId.Charisma); case AttributeId.Intelligence: return(CharacterAttributeId.Intelligence); case AttributeId.Memory: return(CharacterAttributeId.Memory); case AttributeId.Perception: return(CharacterAttributeId.Perception); case AttributeId.Willpower: return(CharacterAttributeId.Willpower); default: throw new InvalidOperationException("The specified EVE attribute does not correspond to a character attribute."); } }
public AttributeTemplate GetDefinition(AttributeId name) { return Attributes.First(a => a.AttributeId == name); }
public AttributeKeyValue(AttributeId name, float value) : this() { this.Name = name; this.Value = value; }