Example #1
0
 internal Type(ValueGroup valueGroup, sbyte typeId, Value minValue, Value maxValue)
 {
     this.ValueGroup = valueGroup;
     this.TypeId     = typeId;
     this._minValue  = minValue;
     this._maxValue  = maxValue;
 }
        /// <summary>
        /// ツイートする。
        /// </summary>
        /// <param name="parameters"></param>
        public async Task Tweet(ServicePostParameters parameters)
        {
            var query = new Query
            {
                ["status"] = parameters.Text,
            };

            if (parameters.Attachments.HasItems)
            {
                var mediaIds = await this._account.Media.Uploads(parameters.Attachments)
                               .ConfigureAwait(false);

                query["media_ids"] = new ValueGroup(mediaIds);
            }

            if (parameters.IsContainsWarningAttachment)
            {
                query["possibly_sensitive"] = true;
            }

            //if (parameters.ReplyToStatus != null)
            //{
            //    query["in_reply_to_status_id"] = parameters.ReplyToStatus.Id;
            //}

            await this._account.Api.Statuses.Update(query).ConfigureAwait(false);
        }
Example #3
0
    public Coordinate GetPos(uint coord_x, uint coord_z)
    {
        const uint NEGATIVE_OUTBOUND = 1000;

        if (coord_x > NEGATIVE_OUTBOUND)
        {
            coord_x = 0;
        }
        else if (coord_x > num_rects)
        {
            coord_x = num_rects;
        }
        if (coord_z > NEGATIVE_OUTBOUND)
        {
            coord_z = 0;
        }
        else if (coord_z > num_rects)
        {
            coord_z = num_rects;
        }
        ValueGroup <uint, uint> Key = new ValueGroup <uint, uint>(coord_x, coord_z);

        if (Coords.ContainsKey(Key))
        {
            return(Coords[Key]);
        }
        else
        {
            return(null);
        }
    }
Example #4
0
 public void RemoveCoord(ValueGroup <uint, uint> key)
 {
     if (Coords.ContainsKey(key))
     {
         Coords.Remove(key);
     }
 }
Example #5
0
        /// <summary>
        /// Select the path corresponding to the given ValueGroup. Creates the path if needed,
        /// and rethrows any create time exception as a RuntimeException.
        /// </summary>
        /// <param name="valueGroup"> target value group </param>
        /// <returns> selected part </returns>
        internal virtual T UncheckedSelect(ValueGroup valueGroup)
        {
            switch (valueGroup.innerEnumValue)
            {
            case ValueGroup.InnerEnum.DATE:
                return(Date());

            case ValueGroup.InnerEnum.LOCAL_DATE_TIME:
                return(LocalDateTime());

            case ValueGroup.InnerEnum.ZONED_DATE_TIME:
                return(ZonedDateTime());

            case ValueGroup.InnerEnum.LOCAL_TIME:
                return(LocalTime());

            case ValueGroup.InnerEnum.ZONED_TIME:
                return(ZonedTime());

            case ValueGroup.InnerEnum.DURATION:
                return(Duration());

            default:
                throw new System.InvalidOperationException("Unsupported value group " + valueGroup);
            }
        }
Example #6
0
    // ================================================================================================================
    // CONSTRUCTOR ----------------------------------------------------------------------------------------------------

    public ValueList(string key = "")
    {
        _key = key;

        ValueList.addInstance(this);
        root = new ValueGroup();
    }
Example #7
0
    // ================================================================================================================
    // CONSTRUCTOR ----------------------------------------------------------------------------------------------------

    public ValueList(string name = "")
    {
        _name = name;

        ValueList.addInstance(this);
        root = new ValueGroup();
    }
        /// <summary>
        /// Method for creating of list of value groups and their corresponding special teasps.
        /// </summary>
        /// <param name="dc">user data category</param>
        /// <returns>List of Value Groups</returns>
        private (List <ValueGroup>, List <Teasp>) handleSplitContents(string dc, bool hasPicklist = false)
        {
            TBXContentMap cm = mappingDict.getTBXContentMap(dc);

            string[] tbx_keys = Methods.getKeyArray(tbx_picklists.Keys);

            List <ValueGroup> vgs    = new List <ValueGroup>();
            List <Teasp>      teasps = new List <Teasp>();

            foreach (string tbx_dc in mappingDict.getTBXMappingList(dc))
            {
                if (Methods.inArray(ref tbx_keys, tbx_dc))
                {
                    Teasp teasp = new Teasp();

                    (string target, string eltAtt) = getEltTgtEltAtt(tbx_dc);

                    if (hasPicklist)
                    {
                        teasp.setAll(target, eltAtt, mappingDict.getPicklistMap(dc));
                    }
                    else
                    {
                        teasp.setAll(target, eltAtt);
                    }

                    ValueGroup vg = new ValueGroup();

                    foreach (string content in cm.Keys)
                    {
                        if (cm[content] == tbx_dc)
                        {
                            vg.Add(content);
                        }
                    }
                    vgs.Add(vg);
                    teasps.Add(teasp);
                }
                else
                {
                    Teasp teasp = new Teasp();
                    (string target, string eltAtt) = getEltTgtEltAtt(tbx_dc);
                    teasp.setAll(target, eltAtt);
                    ValueGroup vg = new ValueGroup();
                    foreach (string content in cm.Keys)
                    {
                        if (cm[content] == tbx_dc)
                        {
                            vg.Add(content);
                        }
                    }
                    vgs.Add(vg);
                    teasps.Add(teasp);
                }
            }

            return(vgs, teasps);
        }
Example #9
0
 internal AbstractArrayType(ValueGroup valueGroup, sbyte typeId, ArrayElementComparator arrayElementComparator, ArrayElementValueFactory <T> valueFactory, ArrayElementWriter arrayElementWriter, ArrayElementReader arrayElementReader, System.Func <int, T[]> arrayCreator, Org.Neo4j.Values.Storable.ValueWriter_ArrayType arrayType) : base(valueGroup, typeId, null, null)
 {
     this._arrayElementComparator = arrayElementComparator;
     this._valueFactory           = valueFactory;
     this.ArrayElementWriter      = arrayElementWriter;
     this._arrayElementReader     = arrayElementReader;
     this._arrayCreator           = arrayCreator;
     this._arrayType = arrayType;
 }
 public override bool HasFullValuePrecision(params IndexQuery[] predicates)
 {
     foreach (IndexQuery predicate in predicates)
     {
         ValueGroup valueGroup = predicate.ValueGroup();
         if (valueGroup == ValueGroup.GEOMETRY_ARRAY || valueGroup == ValueGroup.GEOMETRY)
         {
             return(false);
         }
     }
     return(true);
 }
Example #11
0
    /*Gets the closest coord whose center is minimum distance away
     * from the target coordinate.Note that coordinate target doesn't
     * have to the coordinate of the AI's current target*/
    Coordinate GetClosestCoordToTargetCoord(Coordinate target)
    {
        if (target == null)
        {
            return(null);
        }
        const float INTERVAL_THETA       = 20;
        const float FULL_CIRCLE          = 360;
        ValueGroup <Coordinate, float> v = GetMinimalDistStarterCoord(target);
        Coordinate goal          = v.index;
        Coordinate current_coord = Map.Instance.GetPos(ptr.position);
        Vector3    ORIGINAL_POS  = Map.Instance.GetCenter(goal);
        float      dist          = v.value;
        float      goal_cost     = 0;

        if (goal.isHazardous(ptr.gameObject.layer))
        {
            goal_cost = goal.GetHazardCost(ptr.gameObject.layer);
            // Debug.Log("Hazardous");
        }
        float goal_distance = Math.Abs(
            Vector3.Distance(
                Map.Instance.GetCenter(goal),
                Map.Instance.GetCenter(current_coord)));

        for (float degrees = 10; degrees < FULL_CIRCLE; degrees += INTERVAL_THETA)
        {
            Vector3    pos   = Quaternion.AngleAxis(degrees, Vector3.up) * ORIGINAL_POS;
            Coordinate coord = Map.Instance.GetPos(pos);
            if (coord != null)
            {
                float cost = 0;
                if (coord.isHazardous(ptr.gameObject.layer))
                {
                    cost = coord.GetHazardCost(ptr.gameObject.layer);
                }
                float distance = Math.Abs(
                    Vector3.Distance(
                        Map.Instance.GetCenter(coord),
                        Map.Instance.GetCenter(current_coord)));

                if (distance + cost < goal_distance + goal_cost)
                {
                    goal          = coord;
                    goal_distance = distance;
                    goal_cost     = cost;
                }
            }
        }
        return(goal);
    }
Example #12
0
        private Org.Neo4j.Storageengine.Api.schema.IndexProgressor_NodeValueClient InjectFullValuePrecision(Org.Neo4j.Storageengine.Api.schema.IndexProgressor_NodeValueClient cursor, IndexQuery[] query, IndexReader reader)
        {
            Org.Neo4j.Storageengine.Api.schema.IndexProgressor_NodeValueClient target = cursor;
            if (!reader.HasFullValuePrecision(query))
            {
                IndexQuery[] filters = new IndexQuery[query.Length];
                int          count   = 0;
                for (int i = 0; i < query.Length; i++)
                {
                    IndexQuery q = query[i];
                    switch (q.Type())
                    {
                    case range:
                        ValueGroup valueGroup = q.ValueGroup();
                        if ((valueGroup == NUMBER || valueGroup == GEOMETRY) && !reader.HasFullValuePrecision(q))
                        {
                            filters[i] = q;
                            count++;
                        }
                        break;

                    case exact:
                        Value value = ((IndexQuery.ExactPredicate)q).value();
                        if (value.ValueGroup() == ValueGroup.NUMBER || Values.isArrayValue(value) || value.ValueGroup() == ValueGroup.GEOMETRY)
                        {
                            if (!reader.HasFullValuePrecision(q))
                            {
                                filters[i] = q;
                                count++;
                            }
                        }
                        break;

                    default:
                        break;
                    }
                }
                if (count > 0)
                {
                    // filters[] can contain null elements. The non-null elements are the filters and each sit in the designated slot
                    // matching the values from the index.
                    target = new NodeValueClientFilter(target, _cursors.allocateNodeCursor(), _cursors.allocatePropertyCursor(), this, filters);
                }
            }
            return(target);
        }
        /// <summary>
        /// Serialize the <see cref="ValueGroup"/>
        /// </summary>
        /// <param name="valueGroup">The <see cref="ValueGroup"/> to serialize</param>
        /// <returns>The <see cref="JObject"/></returns>
        private JObject Serialize(ValueGroup valueGroup)
        {
            var jsonObject = new JObject();

            jsonObject.Add("alias", this.PropertySerializerMap["alias"](valueGroup.Alias.OrderBy(x => x, this.guidComparer)));
            jsonObject.Add("category", this.PropertySerializerMap["category"](valueGroup.Category.OrderBy(x => x, this.guidComparer)));
            jsonObject.Add("classKind", this.PropertySerializerMap["classKind"](Enum.GetName(typeof(CDP4Common.CommonData.ClassKind), valueGroup.ClassKind)));
            jsonObject.Add("definition", this.PropertySerializerMap["definition"](valueGroup.Definition.OrderBy(x => x, this.guidComparer)));
            jsonObject.Add("excludedDomain", this.PropertySerializerMap["excludedDomain"](valueGroup.ExcludedDomain.OrderBy(x => x, this.guidComparer)));
            jsonObject.Add("excludedPerson", this.PropertySerializerMap["excludedPerson"](valueGroup.ExcludedPerson.OrderBy(x => x, this.guidComparer)));
            jsonObject.Add("hyperLink", this.PropertySerializerMap["hyperLink"](valueGroup.HyperLink.OrderBy(x => x, this.guidComparer)));
            jsonObject.Add("iid", this.PropertySerializerMap["iid"](valueGroup.Iid));
            jsonObject.Add("modifiedOn", this.PropertySerializerMap["modifiedOn"](valueGroup.ModifiedOn));
            jsonObject.Add("name", this.PropertySerializerMap["name"](valueGroup.Name));
            jsonObject.Add("revisionNumber", this.PropertySerializerMap["revisionNumber"](valueGroup.RevisionNumber));
            jsonObject.Add("shortName", this.PropertySerializerMap["shortName"](valueGroup.ShortName));
            jsonObject.Add("thingPreference", this.PropertySerializerMap["thingPreference"](valueGroup.ThingPreference));
            return(jsonObject);
        }
Example #14
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void copyShouldCopyExtremeValues()
        internal virtual void CopyShouldCopyExtremeValues()
        {
            // Given
            GenericKey extreme = NewKeyState();
            GenericKey copy    = NewKeyState();

            foreach (ValueGroup valueGroup in ValueGroup.values())
            {
                if (valueGroup != ValueGroup.NO_VALUE)
                {
                    extreme.InitValueAsLowest(valueGroup);
                    copy.CopyFrom(extreme);
                    assertEquals(0, extreme.CompareValueTo(copy), "states not equals after copy, valueGroup=" + valueGroup);
                    extreme.InitValueAsHighest(valueGroup);
                    copy.CopyFrom(extreme);
                    assertEquals(0, extreme.CompareValueTo(copy), "states not equals after copy, valueGroup=" + valueGroup);
                }
            }
        }
Example #15
0
        private static List <ValueGroup> LoadValueGroups(XmlElement rootElement)
        {
            var valueGroups = new List <ValueGroup>();

            foreach (XmlNode vg in rootElement.SelectNodes("//value-group"))
            {
                if (vg.NodeType != XmlNodeType.Element)
                {
                    continue;
                }
                var valueGroup = new ValueGroup
                {
                    Caption = vg.Value("caption"),
                    Name    = vg.Value("name"),
                    Values  = LoadValues(vg)
                };
                valueGroups.Add(valueGroup);
            }
            return(valueGroups);
        }
Example #16
0
    public void UpdateDamageCounter(int damage, int layer)
    {
        if (layer == LayerMask.NameToLayer("Invincible"))
        {
            return;
        }
        int index = damage_counter_list.FindIndex(delegate(ValueGroup <int, int> v)
        {
            return(v.index == layer);
        });

        if (index == -1)
        {
            damage_counter_list.Add(new ValueGroup <int, int>(layer, damage));
        }
        else
        {
            damage_counter_list[index] = new ValueGroup <int, int>(layer,
                                                                   damage_counter_list[index].value + damage);
        }
    }
Example #17
0
        private void AssertAccessSingleProperty(long nodeId, object expectedValue, ValueGroup expectedValueType)
        {
            // given
            using (NodeCursor node = cursors.allocateNodeCursor(), PropertyCursor props = cursors.allocatePropertyCursor())
            {
                // when
                read.singleNode(nodeId, node);
                assertTrue("node by reference", node.Next());
                assertTrue("has properties", HasProperties(node, props));

                node.Properties(props);
                assertTrue("has properties by direct method", props.Next());
                assertEquals("correct value", expectedValue, props.PropertyValue());
                assertEquals("correct value type ", expectedValueType, props.PropertyType());
                assertFalse("single property", props.Next());

                read.nodeProperties(node.NodeReference(), node.PropertiesReference(), props);
                assertTrue("has properties via property ref", props.Next());
                assertEquals("correct value", expectedValue, props.PropertyValue());
                assertFalse("single property", props.Next());
            }
        }
Example #18
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void add(java.util.Collection<? extends org.neo4j.kernel.api.index.IndexEntryUpdate<?>> updates) throws org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException
        public override void Add <T1>(ICollection <T1> updates) where T1 : Org.Neo4j.Kernel.Api.Index.IndexEntryUpdate <T1>
        {
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.Map<org.neo4j.values.storable.ValueGroup,java.util.List<org.neo4j.kernel.api.index.IndexEntryUpdate<?>>> batchMap = new java.util.HashMap<>();
            IDictionary <ValueGroup, IList <IndexEntryUpdate <object> > > batchMap = new Dictionary <ValueGroup, IList <IndexEntryUpdate <object> > >();

//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: for (org.neo4j.kernel.api.index.IndexEntryUpdate<?> update : updates)
            foreach (IndexEntryUpdate <object> update in updates)
            {
                ValueGroup valueGroup = update.Values()[0].valueGroup();
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.List<org.neo4j.kernel.api.index.IndexEntryUpdate<?>> batch = batchMap.computeIfAbsent(valueGroup, k -> new java.util.ArrayList<>());
                IList <IndexEntryUpdate <object> > batch = batchMap.computeIfAbsent(valueGroup, k => new List <IndexEntryUpdate <object> >());
                batch.Add(update);
            }
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: for (java.util.Map.Entry<org.neo4j.values.storable.ValueGroup,java.util.List<org.neo4j.kernel.api.index.IndexEntryUpdate<?>>> entry : batchMap.entrySet())
            foreach (KeyValuePair <ValueGroup, IList <IndexEntryUpdate <object> > > entry in batchMap.SetOfKeyValuePairs())
            {
                Select(entry.Key).add(entry.Value);
            }
        }
Example #19
0
    public Coordinate GetPos(Vector3 pos)
    {
        /*The coordinate can be ascertained by dividing the
         * position float values by the length and width of
         * each rectangle*/
        uint       coord_x           = (uint)((pos.x - min_x) / interval_x);
        uint       coord_z           = (uint)((pos.z - min_z) / interval_z);
        const uint NEGATIVE_OUTBOUND = 1000;

        if (coord_x > NEGATIVE_OUTBOUND)
        {
            coord_x = 0;
        }
        else if (coord_x > num_rects)
        {
            coord_x = num_rects;
        }
        if (coord_z > NEGATIVE_OUTBOUND)
        {
            coord_z = 0;
        }
        else if (coord_z > num_rects)
        {
            coord_z = num_rects;
        }
        ValueGroup <uint, uint> Key = new ValueGroup <uint, uint>(coord_x, coord_z);

        if (Coords.ContainsKey(Key))
        {
            return(Coords[Key]);
        }
        else
        {
            return(null);
        }
    }
Example #20
0
        /// <summary>
        /// Select the part corresponding to the given ValueGroup, apply function to it and return the result.
        /// If the part isn't created yet return orElse.
        /// </summary>
        /// <param name="valueGroup"> target value group </param>
        /// <param name="function"> function to apply to part </param>
        /// <param name="orElse"> result to return if part isn't created yet </param>
        /// @param <RESULT> type of result </param>
        /// <returns> the result </returns>
        internal virtual RESULT SelectOrElse <RESULT>(ValueGroup valueGroup, System.Func <T, RESULT> function, RESULT orElse)
        {
            T cachedValue;

            switch (valueGroup.innerEnumValue)
            {
            case ValueGroup.InnerEnum.DATE:
                cachedValue = Cache[date];
                break;

            case ValueGroup.InnerEnum.LOCAL_DATE_TIME:
                cachedValue = Cache[localDateTime];
                break;

            case ValueGroup.InnerEnum.ZONED_DATE_TIME:
                cachedValue = Cache[zonedDateTime];
                break;

            case ValueGroup.InnerEnum.LOCAL_TIME:
                cachedValue = Cache[localTime];
                break;

            case ValueGroup.InnerEnum.ZONED_TIME:
                cachedValue = Cache[zonedTime];
                break;

            case ValueGroup.InnerEnum.DURATION:
                cachedValue = Cache[duration];
                break;

            default:
                throw new System.InvalidOperationException("Unsupported value group " + valueGroup);
            }

            return(cachedValue != default(T) ? function(cachedValue) : orElse);
        }
Example #21
0
 internal override void InitValueAsHighest(ValueGroup valueGroups)
 {
     Bytes = null;
 }
Example #22
0
 internal override void InitValueAsHighest(int stateSlot, ValueGroup valueGroup)
 {
     InitValueAsHighest(valueGroup);
 }
Example #23
0
 internal virtual void InitValueAsHighest(ValueGroup valueGroup)
 {
     Clear();
     TypeConflict = valueGroup == ValueGroup.UNKNOWN ? HIGHEST_BY_VALUE_GROUP : Types.ByGroup[valueGroup.ordinal()];
     TypeConflict.initializeAsHighest(this);
 }
 /// <summary>
 /// Add an Value Group row view model to the list of <see cref="ValueGroup"/>
 /// </summary>
 /// <param name="valueGroup">
 /// The <see cref="ValueGroup"/> that is to be added
 /// </param>
 private ValueGroupRowViewModel AddValueGroupRowViewModel(ValueGroup valueGroup)
 {
     return(new ValueGroupRowViewModel(valueGroup, this.Session, this));
 }
Example #25
0
 internal FileLayout(File indexFile, IndexLayout <KEY, NativeIndexValue> layout, ValueGroup valueGroup)
 {
     this.IndexFile  = indexFile;
     this.Layout     = layout;
     this.ValueGroup = valueGroup;
 }
Example #26
0
 /// <summary>
 /// Select the part corresponding to the given ValueGroup. Creates the part if needed,
 /// in which case an exception of type E might be thrown.
 /// </summary>
 /// <param name="valueGroup"> target value group </param>
 /// <returns> selected part </returns>
 internal virtual T Select(ValueGroup valueGroup)
 {
     return(UncheckedSelect(valueGroup));
 }
Example #27
0
 internal override void InitValueAsLowest(int stateSlot, ValueGroup valueGroup)
 {
     stateSlot(stateSlot).InitValueAsLowest(valueGroup);
 }
Example #28
0
    public void UpdateAggro(int damage = 0, NetworkInstanceId player_id = new NetworkInstanceId(), bool account_attack_dist = true)
    {
        if (damage != 0)
        {
            //Debug.Log("Aggro Called");
            float     dist_multiplier = 1;
            Transform playertr        = NetworkServer.FindLocalObject(player_id).transform;
            if (account_attack_dist && Target)
            {
                /*The closer the player is to the enemy the more threat generated from
                 * the respective attack done by the player*/
                float dist_ratio = enemy_attack_detection.radius /
                                   Vector3.Distance(Target.transform.position, ptr.position);
                /*The distance only has 25% bearing on the threat,however.*/
                dist_multiplier = .75f + .25f * (dist_ratio);
            }

            /*If the player is not currently on the enemy's hatelist...
             * (netIds are used as ValueGroup indeces)*/
            if (!Array.Exists(HateList, delegate(ValueGroup g)
            {
                return(g.index == (int)(player_id.Value));
            }))
            {
                /*Find the first empty slot to store threat info
                 * in*/
                int index = Array.FindIndex(HateList, delegate(ValueGroup g)
                {
                    return(g.value == -1);
                });
                //Debug.Log(index);
                HateList[index] = new ValueGroup((int)player_id.Value, dist_multiplier * (float)damage);
            }
            else
            {
                /*If the player is in the aggro list,then simply add to the threat
                 * data stored into it*/
                int index = Array.FindIndex(HateList, delegate(ValueGroup g)
                {
                    return(g.index == (int)player_id.Value);
                });
                HateList[index].value += (float)damage * dist_multiplier;
            }
        }

        /*There needs to be a .2 times more threat to move up one place.
         * This is to prevent rapid switching of targets constantly w/o huge
         * damage changes.*/

        Array.Sort(HateList, delegate(ValueGroup lhs, ValueGroup rhs)
        {
            /*if (lhs.value == -1)
             * {
             *  return 0;
             * } */
            if (lhs.value * .9f > rhs.value)
            {
                return(-1);
            }
            else if (lhs.value * 1.1f < rhs.value)
            {
                return(1);
            }
            else
            {
                return(0);
            }
        });
        if (HateList[0] != NOT_SET)
        {
            /*Assign target to one with most threat.The Gameobject's
             * existence is checked in event that a player disconnects.*/
            GameObject g = NetworkServer.FindLocalObject(new NetworkInstanceId((uint)HateList[0].index));
            if (g == null)
            {
                RemoveAggro(new NetworkInstanceId((uint)HateList[0].index));
            }
            else
            {
                Target = g.GetComponent <HealthDefence>();
            }
        }
        else
        {
            Target = null;
        }
    }
Example #29
0
 public void addGroup(string key, ValueGroup group)
 {
     groups[key] = group;
 }
Example #30
0
 internal abstract void InitValueAsHighest(int stateSlot, ValueGroup valueGroup);