Example #1
0
        public static IdPair deserialize(byte[] buffer, ref uint offset)
        {
            // null
            bool _null = boolBuffer.deserialize(buffer, ref offset);

            if (_null)
            {
                return(null);
            }

            // id

            int _id = intBuffer.deserialize(buffer, ref offset);



            // value

            int _value = intBuffer.deserialize(buffer, ref offset);

            IdPair _IdPair = new IdPair();

            _IdPair.id = _id;

            _IdPair.value = _value;
            return(_IdPair);
        }
Example #2
0
            /// <summary>
            /// Create a frozen anchor visual in the indicated fragment.
            /// </summary>
            /// <param name="source">Source data to create from.</param>
            /// <param name="resource">The created resource.</param>
            /// <returns></returns>
            public bool CreateFrozenVisual(AnchorFragmentPose source, out IdPair <AnchorId, FrozenAnchorVisual> resource)
            {
                // Already ensured this fragment exists.
                FragmentId fragmentId = source.fragmentPose.fragmentId;

                AnchorId anchorId = source.anchorId;

                FrameVisual frozenFragmentViz;

                if (!frozenFragmentVisuals.TryGetValue(fragmentId, out frozenFragmentViz))
                {
                    resource = new IdPair <AnchorId, FrozenAnchorVisual>()
                    {
                        id = AnchorId.Invalid, target = null
                    };
                    return(false);
                }

                // If there isn't a visualization for this anchor, add one.
                FrozenAnchorVisual frozenAnchorVisual;

                frozenAnchorVisual = Prefab_FrozenAnchorViz.Instantiate(anchorId.FormatStr(), frozenFragmentViz);
                //frozenAnchorVisual.gameObject.AddComponent<AdjusterMoving>();

                // Put the frozen anchor vis at the world locked transform of the anchor
                SetPose(source, frozenAnchorVisual);

                resource = new IdPair <AnchorId, FrozenAnchorVisual>()
                {
                    id     = source.anchorId,
                    target = frozenAnchorVisual
                };
                return(true);
            }
Example #3
0
        /**
         * Sets whether a (dataTYpeId, companyId) tuple is enabled. This is done by hashset removal or addition, but
         * this is a useful abstraction
         */
        public async void SetEnabled(int dataTypeId, int companyId, bool setting)
        {
            IdPair idPair = new IdPair()
            {
                data_type = dataTypeId, enterprise = companyId
            };

            if (setting && !InEnabledSet(dataTypeId, companyId))
            {
                enabledSet.Add(idPair); //update the value locally
                //update the value on the server
                var jsonString  = JsonConvert.SerializeObject(idPair);
                var jsonContent = new StringContent(jsonString, Encoding.UTF8, "application/json");
                await DatabaseInteraction.SendDatabaseRequest(DatabaseInteraction.DatabaseRequest.ALLOW_PERMISSION,
                                                              DatabaseInteraction.HttpRequestType.POST, jsonContent, true, true);

                //error checking done in the request
            }
            else if (!setting && InEnabledSet(dataTypeId, companyId))
            {
                enabledSet.Remove(idPair);
                //update the value on the server
                var jsonString  = JsonConvert.SerializeObject(idPair);
                var jsonContent = new StringContent(jsonString, Encoding.UTF8, "application/json");
                await DatabaseInteraction.SendDatabaseRequest(DatabaseInteraction.DatabaseRequest.DENY_PERMISSION,
                                                              DatabaseInteraction.HttpRequestType.POST, jsonContent, true, true);

                //error checking done in the request
            }
        }
Example #4
0
        /// <summary> 에디터모드로 돌아왔을 때 복원할 컴포넌트 등록 </summary>
        public static void AddComponentForSave(Component component)
        {
            if (component == null)
            {
                return;
            }

            // ID 얻기
            var cID = component.GetInstanceID();
            var oID = component.gameObject.GetInstanceID();
            var ids = new IdPair(oID, cID);

            // 컴포넌트로부터 SO 생성
            var so = new SerializedObject(component);

            // 딕셔너리에 추가
            if (dataForSaveDict.ContainsKey(ids))
            {
                dataForSaveDict[ids] = so;
            }
            else
            {
                dataForSaveDict.Add(ids, so);
            }
        }
            public static IdPair <AnchorId, PositionDummy> MakePair(int id, float x, float y)
            {
                IdPair <AnchorId, PositionDummy> ret = new IdPair <AnchorId, PositionDummy>();

                ret.id     = (AnchorId)id;
                ret.target = new PositionDummy(new Vector3(x, y, 0));
                return(ret);
            }
Example #6
0
 public IdPair[] GetIdPairs(int len)
 {
     IdPair[] rt = new IdPair[len];
     for (int ii = 0; ii < len; ++ii)
     {
         rt[ii].a = 10 + ii;
         rt[ii].b = 10 + ii + 1;
     }
     return(rt);
 }
        private static int FindInSortedList <S, T>(S key, List <IdPair <S, T> > list, IComparer <IdPair <S, T> > comparer)
        {
            IdPair <S, T> item = new IdPair <S, T>()
            {
                id = key
            };
            int idx = list.BinarySearch(item, comparer);

            return(idx);
        }
            public static IdPair <AnchorId, AnchorVisTest> Make(AnchorId id)
            {
                IdPair <AnchorId, AnchorVisTest> ret = new IdPair <AnchorId, AnchorVisTest>()
                {
                    id     = id,
                    target = new AnchorVisTest()
                    {
                        id = id
                    }
                };

                return(ret);
            }
Example #9
0
            /// <summary>
            /// Create a Spongy Anchor Visual matching the spongy anchor source.
            /// </summary>
            /// <param name="source">The source Spongy Anchor.</param>
            /// <param name="resource">The created SpongyAnchorVisual with matching id.</param>
            /// <returns></returns>
            public bool CreateSpongyVisual(AnchorManager.SpongyAnchorWithId source, out IdPair <AnchorId, SpongyAnchorVisual> resource)
            {
                var spongyAnchorVisual = Prefab_SpongyAnchorVisual.Instantiate(
                    spongyWorldVisual,
                    source.spongyAnchor);

                resource = new IdPair <AnchorId, SpongyAnchorVisual>()
                {
                    id     = source.anchorId,
                    target = spongyAnchorVisual
                };
                return(true);
            }
            public bool ShouldConnect(
                IdPair <AnchorId, PositionDummy> frozen,
                IdPair <AnchorId, PositionDummy> spongy)
            {
                if (frozen.id != spongy.id)
                {
                    return(false);
                }
                float MinDistanceSquared = 0.01f; // one centimeter.
                float distanceSq         = (frozen.target.transform.position - spongy.target.transform.position).sqrMagnitude;

                if (distanceSq < MinDistanceSquared)
                {
                    return(false);
                }
                return(true);
            }
Example #11
0
        public static void serialize(IdPair value, XSteam steam)
        {
            // null
            boolBuffer.serialize(value == null, steam);
            if (value == null)
            {
                return;
            }

            // id

            intBuffer.serialize(value.id, steam);



            // value

            intBuffer.serialize(value.value, steam);
        }
Example #12
0
            /// <summary>
            /// Look up the frozen anchor endpoints and connect them with a line.
            /// </summary>
            /// <param name="edge">Pair of anchor ids.</param>
            /// <param name="resource">The resource to create.</param>
            /// <returns></returns>
            public bool CreateFrozenEdge(AnchorEdge edge, out IdPair <AnchorEdge, ConnectingLine> resource)
            {
                var anchorId1 = edge.anchorId1;
                var anchorId2 = edge.anchorId2;

                var frozenAnchor1Idx = FindInSortedList(anchorId1, frozenResources, frozenAnchorVisualComparer);
                var frozenAnchor2Idx = FindInSortedList(anchorId2, frozenResources, frozenAnchorVisualComparer);

                if (frozenAnchor1Idx < 0 || frozenAnchor2Idx < 0)
                {
                    resource = new IdPair <AnchorEdge, ConnectingLine>()
                    {
                        id = edge, target = null
                    };
                    return(false);
                }
                var frozenAnchor1 = frozenResources[frozenAnchor1Idx];
                var frozenAnchor2 = frozenResources[frozenAnchor2Idx];

                Transform parent1      = frozenAnchor1.target.transform.parent;
                Transform parent2      = frozenAnchor2.target.transform.parent;
                bool      sameFragment = parent1 == parent2;
                Color     color        = Color.blue;
                float     width        = 0.002f;
                Transform parent       = parent1;

                if (!sameFragment)
                {
                    color = Color.yellow;
                    width = 0.004f;
                }

                var edgeVisual = ConnectingLine.Create(parent,
                                                       frozenAnchor1.target.transform, frozenAnchor2.target.transform,
                                                       width, color);

                resource = new IdPair <AnchorEdge, ConnectingLine>()
                {
                    id     = edge,
                    target = edgeVisual
                };
                return(true);
            }
 public static bool Create(IdPair <AnchorId, AnchorDummy> source, out IdPair <AnchorId, AnchorVisTest> resource)
 {
     resource = Make(source.id);
     return(true);
 }
 public void DestroyDisplacement(IdPair <AnchorId, PositionDummyPair> target)
 {
 }
Example #15
0
 public int AddIdPair(IdPair p)
 {
     return(p.a + p.b);
 }
Example #16
0
 public int AddIdPair(IdPair p)
 {
     return p.a + p.b;
 }
Example #17
0
    public IdPair GetUserIdPair(Wolframe.ProcProvider provider, User usr)
    {
        IdPair rt = (IdPair)provider.call("GetIdPair", usr, typeof(IdPair).GUID);

        return(rt);
    }
 public static void Destroy(IdPair <AnchorId, AnchorVisTest> target)
 {
 }
Example #19
0
 public IdPair[] GetIdPairs(int len)
 {
     IdPair[] rt = new IdPair[len];
     for (int ii = 0; ii < len; ++ii)
     {
         rt[ii].a = 10 + ii;
         rt[ii].b = 10 + ii + 1;
     }
     return rt;
 }
 /// <summary>
 /// Convenience comparison function comparing by identifier (ignoring associated data).
 /// </summary>
 /// <param name="lhs">The left hand side.</param>
 /// <param name="rhs">The right hand side.</param>
 /// <returns>If lhs GT rhs then -1 else if lhs LT rhs then 1 else 0</returns>
 public static int CompareById(IdPair <IdType, T> lhs, IdPair <IdType, T> rhs)
 {
     return(Comparer <IdType> .Default.Compare(lhs.id, rhs.id));
 }
 public static bool Create(AnchorEdge source, out IdPair <AnchorEdge, AnchorEdgeVisTest> resource)
 {
     resource = Make(source);
     return(true);
 }
Example #22
0
 /// <summary>
 /// Release resources for stale edges.
 /// </summary>
 /// <param name="target">The resource to release.</param>
 public void DestroyFrozenEdge(IdPair <AnchorEdge, ConnectingLine> target)
 {
     Destroy(target.target.gameObject);
 }
Example #23
0
 /// <summary>
 /// Destroy a no longer needed connecting line.
 /// </summary>
 /// <param name="target">The resource to destroy.</param>
 public void DestroyDisplacement(IdPair <AnchorId, ConnectingLine> target)
 {
     Destroy(target.target.gameObject);
 }
Example #24
0
 bool idPairComparer(IdPair a, IdPair b)
 {
     return(String.Equals(a.UniqueId, b.UniqueId, StringComparison.InvariantCultureIgnoreCase) &&
            String.Equals(a.CurrentId, b.CurrentId, StringComparison.InvariantCultureIgnoreCase) &&
            String.Equals(a.BackupId, b.BackupId, StringComparison.InvariantCultureIgnoreCase));
 }
Example #25
0
 /// <summary>
 /// Destroy a no longer needed FrozenAnchorVisual.
 /// </summary>
 /// <param name="target"></param>
 public void DestroyFrozenVisual(IdPair <AnchorId, FrozenAnchorVisual> target)
 {
     Destroy(target.target.gameObject);
 }
Example #26
0
 /// <summary>
 /// Update the pose of the existing resource.
 /// </summary>
 /// <param name="source">The resource's source data.</param>
 /// <param name="target">The resource to update.</param>
 public void UpdateFrozenVisual(AnchorFragmentPose source, IdPair <AnchorId, FrozenAnchorVisual> target)
 {
     SetPose(source, target.target);
 }
 public static void Update(IdPair <AnchorId, AnchorDummy> source, IdPair <AnchorId, AnchorVisTest> target)
 {
     Assert.AreEqual(source.id, target.id);
 }
 public static void Update(AnchorEdge source, IdPair <AnchorEdge, AnchorEdgeVisTest> target)
 {
     Assert.AreEqual(source, target.id);
 }
Example #29
0
        public static AchievementConfig deserialize(byte[] buffer, ref uint offset)
        {
            // null
            bool _null = boolBuffer.deserialize(buffer, ref offset);

            if (_null)
            {
                return(null);
            }

            // Id

            int _Id = intBuffer.deserialize(buffer, ref offset);



            // Name

            int _Name = intBuffer.deserialize(buffer, ref offset);



            // Desc

            int _Desc = intBuffer.deserialize(buffer, ref offset);



            // Icon

            int _Icon = intBuffer.deserialize(buffer, ref offset);



            // Difficulty

            int _Difficulty = intBuffer.deserialize(buffer, ref offset);



            // Condition

            AchievementCondition _Condition = AchievementConditionBuffer.deserialize(buffer, ref offset);



            // RewardItem


            int _RewardItem_length = intBuffer.deserialize(buffer, ref offset);

            RewardItem[] _RewardItem = new RewardItem[_RewardItem_length];
            for (int i = 0; i < _RewardItem_length; i++)
            {
                _RewardItem[i] = RewardItemBuffer.deserialize(buffer, ref offset);
            }


            // Buff

            IdPair _Buff = IdPairBuffer.deserialize(buffer, ref offset);



            // NeedAchievement

            int _NeedAchievement = intBuffer.deserialize(buffer, ref offset);



            // TargetSystem

            TargetSystem _TargetSystem = TargetSystemBuffer.deserialize(buffer, ref offset);



            // Group

            int _Group = intBuffer.deserialize(buffer, ref offset);

            AchievementConfig _AchievementConfig = new AchievementConfig();

            _AchievementConfig.Id = _Id;

            _AchievementConfig.Name = _Name;

            _AchievementConfig.Desc = _Desc;

            _AchievementConfig.Icon = _Icon;

            _AchievementConfig.Difficulty = _Difficulty;

            _AchievementConfig.Condition = _Condition;

            _AchievementConfig.RewardItem = _RewardItem;

            _AchievementConfig.Buff = _Buff;

            _AchievementConfig.NeedAchievement = _NeedAchievement;

            _AchievementConfig.TargetSystem = _TargetSystem;

            _AchievementConfig.Group = _Group;
            return(_AchievementConfig);
        }
 public static void Destroy(IdPair <AnchorEdge, AnchorEdgeVisTest> target)
 {
 }
        public void AnchorListSyncTest()
        {
            UnityEngine.Debug.Log("Enter Sync Test");

            List <IdPair <AnchorId, AnchorVisTest> > existing = new List <IdPair <AnchorId, AnchorVisTest> >();

            for (int i = 2; i < 6; ++i)
            {
                existing.Add(AnchorIdVisTestCreator.Make(i));
            }
            existing.Sort(IdPair <AnchorId, AnchorVisTest> .CompareById);

            List <IdPair <AnchorId, AnchorDummy> > current = new List <IdPair <AnchorId, AnchorDummy> >();

            for (int i = 1; i < 7; ++i)
            {
                current.Add(new IdPair <AnchorId, AnchorDummy>()
                {
                    id = (AnchorId)i, target = AnchorDummy.Create(i)
                });
            }
            current.Sort(IdPair <AnchorId, AnchorDummy> .CompareById);

            /// Initial state is:
            ///   current == [1..7]
            ///   existing == [2..6]
            /// Expected is to add 1 and 7 to existing.
            ResourceMirror.Sync <IdPair <AnchorId, AnchorDummy>, IdPair <AnchorId, AnchorVisTest> >(
                current,
                existing,
                (item, res) => item.id.CompareTo(res.id),
                AnchorIdVisTestCreator.Create,
                AnchorIdVisTestCreator.Update,
                x => { Debug.LogError("Not expecting to be deleting here, only adding."); }
                );
            CheckSynced(existing, current);

            current.RemoveAt(current.Count / 2);

            /// Lists are the same, except one has been removed from current.
            /// Expect a single matching resource removed from existing.
            ResourceMirror.CompareToResource <IdPair <AnchorId, AnchorDummy>, IdPair <AnchorId, AnchorVisTest> > comparisonById = (item, res) => item.id.CompareTo(res.id);
            ResourceMirror.Sync <IdPair <AnchorId, AnchorDummy>, IdPair <AnchorId, AnchorVisTest> >(
                current,
                existing,
                comparisonById,
                (IdPair <AnchorId, AnchorDummy> x, out IdPair <AnchorId, AnchorVisTest> y) => { Debug.LogError("Not expecting to be creating resources here, only deleting."); y = new IdPair <AnchorId, AnchorVisTest>(); return(false); },
                AnchorIdVisTestCreator.Update,
                AnchorIdVisTestCreator.Destroy
                );
            CheckSynced(existing, current);

            current.RemoveAt(0);
            current.RemoveAt(current.Count - 1);

            ResourceMirror.Sync(
                current,
                existing,
                comparisonById, // reused from above
                AnchorIdVisTestCreator.Create,
                AnchorIdVisTestCreator.Update,
                AnchorIdVisTestCreator.Destroy
                );
            CheckSynced(existing, current);

            current.Clear();
            ResourceMirror.Sync(
                current,
                existing,
                comparisonById,
                AnchorIdVisTestCreator.Create,
                AnchorIdVisTestCreator.Update,
                AnchorIdVisTestCreator.Destroy
                );
            CheckSynced(existing, current);
        }
Example #32
0
 /// <summary>
 /// Destroy the visual which is no longer needed.
 /// </summary>
 /// <param name="target">The visual to destroy.</param>
 public void DestroySpongyVisual(IdPair <AnchorId, SpongyAnchorVisual> target)
 {
     Destroy(target.target.gameObject);
 }