Пример #1
0
        public void Update(double totalMS, double frameMS)
        {
            GameEffect f = _root;

            while (f != null)
            {
                LinkedObject n = f.Next;

                f.Update(totalMS, frameMS);

                if (!f.IsDestroyed && f.Distance > World.ClientViewRange)
                {
                    RemoveEffect(f);
                }

                if (f.IsDestroyed)
                {
                    if (f.Children.Count != 0)
                    {
                        foreach (GameEffect child in f.Children)
                        {
                            if (!child.IsDestroyed)
                            {
                                Add(child);
                            }
                        }

                        f.Children.Clear();
                    }
                }

                f = (GameEffect)n;
            }
        }
Пример #2
0
        public void Insert(LinkedObject first, LinkedObject item)
        {
            if (first == null)
            {
                item.Right = First;
                item.Left  = null;

                if (First != null)
                {
                    First.Left = item;
                }
                First = item;
            }
            else
            {
                var next = first.Right;
                item.Right  = next;
                item.Left   = first;
                first.Right = item;

                if (next != null)
                {
                    next.Left = item;
                }
            }
        }
Пример #3
0
 public WeakHolder(LinkedObject ro)
 {
     this.StrongReference = ro.StrongReference;
     this.LocalLinkId     = ro.LocalId;
     this.Key             = ro.Key;
     this.RemoterWeak     = new WeakReference <LinkedObject>(ro);
 }
Пример #4
0
        public void OnPointerClick(PointerEventData eventData)
        {
            //Catch double click on layer, to move camera to the linked object
            if (layerType == LayerType.ANNOTATION)
            {
                Annotation annotation = LinkedObject.GetComponent <Annotation>();
                CameraModeChanger.Instance.CurrentCameraControls.MoveAndFocusOnLocation(annotation.WorldPointerFollower.WorldPosition, new Quaternion());
                annotation.StartEditingText();
            }

            else if (layerType == LayerType.CAMERA)
            {
                WorldPointFollower  follower = LinkedObject.GetComponent <WorldPointFollower>();
                FirstPersonLocation obj      = LinkedObject.GetComponent <FirstPersonLocation>();
                CameraModeChanger.Instance.CurrentCameraControls.MoveAndFocusOnLocation(follower.WorldPosition, obj.savedRotation);
            }
            else
            {
                //If this is a Transformable, select it
                var transformable = LinkedObject.GetComponent <Transformable>();
                if (transformable)
                {
                    transformable.Select();
                    ToggleLayerOpened();
                }
            }
        }
Пример #5
0
        public void Insert(LinkedObject first, LinkedObject item)
        {
            if (first == null)
            {
                item.Next     = Items;
                item.Previous = null;

                if (Items != null)
                {
                    Items.Previous = item;
                }
                Items = item;
            }
            else
            {
                var next = first.Next;
                item.Next     = next;
                item.Previous = first;
                first.Next    = item;

                if (next != null)
                {
                    next.Previous = item;
                }
            }
        }
Пример #6
0
 private void Update()
 {
     foreach (GameObject LinkedObject in LinkedSpawners)
     {
         Debug.DrawLine(GetComponent <Renderer>().bounds.center, end: LinkedObject.GetComponent <Renderer>().bounds.center, color: Color.red);
     }
 }
Пример #7
0
        private static void Main(string[] args)
        {
            var foo = new LinkedObject<string>("foo");
            var bar = new LinkedObject<string>("bar");
            var baz = new LinkedObject<string>("baz");

            foo.Next = baz;
            foo.Next = bar;

            bar.Remove();

            //foo.Next.Remove();

            dynamic iniFile1 = IniFile.From("test.ini", new IniSettings
            {
                DuplicateSectionHandling = DuplicateSectionHandling.Merge,
                DuplicatePropertyHandling = DuplicatePropertyHandling.KeepLast
            });
            iniFile1.Save("test2.ini");

            var serv1 = iniFile1.database.server;

            var iniFile2 = IniFile.From("test.ini");
            var serv2 = iniFile2["database"]["server"];
            var section = iniFile2.AddSection("downloads");
        }
Пример #8
0
        public void PushToBack(LinkedObject item)
        {
            if (item == null)
            {
                return;
            }

            Remove(item);

            if (Items == null)
            {
                Items = item;
            }
            else
            {
                var current = Items;
                while (current.Next != null)
                {
                    current = current.Next;
                }

                current.Next  = item;
                item.Previous = current;
            }
        }
Пример #9
0
        private static void Main(string[] args)
        {
            var foo = new LinkedObject <string>("foo");
            var bar = new LinkedObject <string>("bar");
            var baz = new LinkedObject <string>("baz");

            foo.Next = baz;
            foo.Next = bar;

            bar.Remove();


            //foo.Next.Remove();

            dynamic iniFile1 = IniFile.From("test.ini", new IniSettings
            {
                DuplicateSectionHandling  = DuplicateSectionHandling.Merge,
                DuplicatePropertyHandling = DuplicatePropertyHandling.KeepLast
            });

            iniFile1.Save("test2.ini");

            var serv1 = iniFile1.database.server;

            var iniFile2 = IniFile.From("test.ini");
            var serv2    = iniFile2["database"]["server"];
            var section  = iniFile2.AddSection("downloads");
        }
Пример #10
0
        public void Unlink(LinkedObject item)
        {
            if (item == null)
            {
                return;
            }

            if (item == Items)
            {
                Items = Items.Next;
                if (Items != null)
                {
                    Items.Previous = null;
                }
            }
            else
            {
                if (item.Previous != null)
                {
                    item.Previous.Next = item.Next;
                }

                if (item.Next != null)
                {
                    item.Next.Previous = item.Previous;
                }
            }
        }
Пример #11
0
        public override void Start()
        {
            if (!LinkedObject.HasComponent <Button2DComponent>())
            {
                Debug.LogWarning("The 2DObject \"" + LinkedObject.ObjectName + "\" has a Dropdown 2D Component but no button to interact with it. A button 2D Component has automatically been added.", true);
                LinkedObject.AddComponent(new Button2DComponent());
            }

            DropDownParent = new Object2D("Dropdown_" + LinkedObject.ObjectName, LinkedObject.Position + new Vector2(0, LinkedObject.Size.Y / 2), Size, LinkedObject.Rotation, new Component2D[] { new Image2DComponent(DefaultValues.PixelTexture, DropDownColor), new Spacer2DComponent(SpacerOption.VerticalSpacer, ItemSpacing, Alignment.TopLeft, ItemSpacing) }, Alignment.TopLeft, LinkedObject.Layer, LinkedObject);

            if (MustClick)
            {
                LinkedObject.GetComponent <Button2DComponent>().OnClick        += () => OpenDropdown();
                LinkedObject.GetComponent <Button2DComponent>().OnClickOutside += () => CloseDropdown();
            }
            else
            {
                LinkedObject.GetComponent <Button2DComponent>().OnEnter += () => OpenDropdown();
                LinkedObject.GetComponent <Button2DComponent>().OnExit  += () => CloseDropdown();
            }

            foreach (Object2D obj in DropdownItems.ToArray())
            {
                DropDownParent.AddChild(obj);
            }

            CloseDropdown();
        }
Пример #12
0
        private bool TryGetUnderLock(KeyType key, out LinkedObject result)
        {
            if (!indexByKey.TryGetValue(key, out var holder))
            {
                result = null;
                return(false);
            }

            if (!holder.IsValid)
            {
                result = null;
                return(false);
            }

            if (holder.RemoterWeak.TryGetTarget(out result))
            {
                return(true);
            }

            // Remove stale reference, it is Collected but Finalizer is not called yet.
            // clear the index
            indexByKey.Remove(key);

            // but keep id entry (so no other remoter can reclaim it until existing one is finalized.
            holder.Invalidate();
            return(false);
        }
Пример #13
0
 // Start is called before the first frame update
 void Start()
 {
     //Sets bridge open/closed
     if (LinkedObjectType == ObjectType.Bridge)
     {
         Activated = LinkedObject.GetComponent <Bridge>().isOpen();
     }
 }
Пример #14
0
 public void AddLinkedObject(LinkedObject p_LinkedObject)
 {
     if (InnerState != ProtocolWriteHeaderInnerState.Started)
     {
         throw new ProtocolWriteHeaderInnerStateException($"InnerState is {InnerState}, but must be {ProtocolWriteHeaderInnerState.Started}");
     }
     _ProtocolWriteRepository.AddLinkedObject(HeaderId, p_LinkedObject);
 }
Пример #15
0
        public void AddLinkedObject(long p_HeaderId, LinkedObject p_LinkedObject)
        {
            if (p_LinkedObject == null)
            {
                throw new ArgumentNullException(nameof(p_LinkedObject));
            }

            SaveLine(p_HeaderId, $"ADD LinkedObject Name='{p_LinkedObject.ObjectName}' Id='{p_LinkedObject.ObjectId}'");
        }
Пример #16
0
        public void Remove(LinkedObject item)
        {
            if (item == null)
            {
                return;
            }

            Unlink(item);
            item.Next     = null;
            item.Previous = null;
        }
Пример #17
0
 public void AddLinkedObject(long p_HeaderId, LinkedObject p_LinkedObject)
 {
     using (var conn = new SqlConnection(_ConnectionString))
     {
         conn.Open();
         conn.Insert(new LinkedObjectRow()
         {
             HeaderId = p_HeaderId, Name = p_LinkedObject.ObjectName, Id = p_LinkedObject.ObjectId?.ToString()
         });
     }
 }
Пример #18
0
        public void Remove(LinkedObject item)
        {
            if (item == null)
            {
                return;
            }

            Unlink(item);
            item.Right = null;
            item.Left  = null;
        }
Пример #19
0
        public void NextTests()
        {
            var foo = new LinkedObject <string>("foo");
            var bar = new LinkedObject <string>("bar");
            var baz = new LinkedObject <string>("baz");
            var qux = new LinkedObject <string>("qux");

            // create chain

            // foo, bar, baz, qux

            foo.Next = bar;
            bar.Next = baz;
            baz.Next = qux;

            // check chain

            Assert.AreSame(bar, foo.Next);
            Assert.AreSame(baz, bar.Next);
            Assert.AreSame(qux, baz.Next);
            Assert.IsNull(qux.Next);

            Assert.AreSame(baz, qux.Previous);
            Assert.AreSame(bar, baz.Previous);
            Assert.AreSame(foo, bar.Previous);
            Assert.IsNull(foo.Previous);

            CollectionAssert.AreEqual(new[] { foo, bar, baz, qux }, foo.After.ToList());
            CollectionAssert.AreEqual(new[] { foo }, foo.Before.ToList());
            CollectionAssert.AreEqual(new[] { qux, baz, bar, foo }, qux.Before.ToList());

            // move qux back

            // foo, qux, bar, baz

            foo.Next = qux;

            Assert.AreSame(qux, foo.Next);
            Assert.AreSame(baz, bar.Next);
            Assert.AreSame(bar, qux.Next);
            Assert.IsNull(baz.Next);

            Assert.AreSame(foo, qux.Previous);
            Assert.AreSame(bar, baz.Previous);
            Assert.AreSame(qux, bar.Previous);
            Assert.IsNull(foo.Previous);

            CollectionAssert.AreEqual(new[] { foo, qux, bar, baz }, foo.After.ToList());
            CollectionAssert.AreEqual(new[] { foo }, foo.Before.ToList());
            CollectionAssert.AreEqual(new[] { qux, foo }, qux.Before.ToList());
            CollectionAssert.AreEqual(new[] { baz, bar, qux, foo }, baz.Before.ToList());
        }
Пример #20
0
        public void NextTests()
        {
            var foo = new LinkedObject<string>("foo");
            var bar = new LinkedObject<string>("bar");
            var baz = new LinkedObject<string>("baz");
            var qux = new LinkedObject<string>("qux");

            // create chain

            // foo, bar, baz, qux

            foo.Next = bar;
            bar.Next = baz;
            baz.Next = qux;

            // check chain

            Assert.AreSame(bar, foo.Next);
            Assert.AreSame(baz, bar.Next);
            Assert.AreSame(qux, baz.Next);
            Assert.IsNull(qux.Next);

            Assert.AreSame(baz, qux.Previous);
            Assert.AreSame(bar, baz.Previous);
            Assert.AreSame(foo, bar.Previous);
            Assert.IsNull(foo.Previous);

            CollectionAssert.AreEqual(new[] { foo, bar, baz, qux }, foo.After.ToList());
            CollectionAssert.AreEqual(new[] { foo }, foo.Before.ToList());
            CollectionAssert.AreEqual(new[] { qux, baz, bar, foo }, qux.Before.ToList());

            // move qux back

            // foo, qux, bar, baz

            foo.Next = qux;

            Assert.AreSame(qux, foo.Next);
            Assert.AreSame(baz, bar.Next);
            Assert.AreSame(bar, qux.Next);
            Assert.IsNull(baz.Next);

            Assert.AreSame(foo, qux.Previous);
            Assert.AreSame(bar, baz.Previous);
            Assert.AreSame(qux, bar.Previous);
            Assert.IsNull(foo.Previous);

            CollectionAssert.AreEqual(new[] { foo, qux, bar, baz }, foo.After.ToList());
            CollectionAssert.AreEqual(new[] { foo }, foo.Before.ToList());
            CollectionAssert.AreEqual(new[] { qux, foo }, qux.Before.ToList());
            CollectionAssert.AreEqual(new[] { baz, bar, qux, foo }, baz.Before.ToList());
        }
Пример #21
0
 public override void Draw()
 {
     if ((float)Game.Gametime.TotalGameTime.TotalSeconds > TimeToPass)
     {
         LinkedObject.GetComponent <Text2DComponent>().Text = "FPS: " + FramesPassed;
         TimeToPass  += 1;
         FramesPassed = 0;
     }
     else
     {
         FramesPassed += 1;
     }
 }
Пример #22
0
        private void AddUnderLock(LinkedObject ro, Action <UInt32> setter)
        {
            do
            {
                nextLocalId++;
            }while (nextLocalId == 0 || activeLinks.ContainsKey(nextLocalId));

            setter(nextLocalId);
            var holder = new WeakHolder(ro);

            activeLinks.Add(holder.LocalLinkId, holder);
            indexByKey.Add(holder.Key, holder);
        }
Пример #23
0
        public void Replace(T entity, uint newSerial)
        {
            if (_entities.Remove(entity.Serial))
            {
                for (LinkedObject i = entity.Items; i != null; i = i.Next)
                {
                    Item it = (Item)i;
                    it.Container = newSerial;
                }

                _entities[newSerial] = entity;
                entity.Serial        = newSerial;
            }
        }
Пример #24
0
            public void EnterObject(IDataWriter dataWriter)
            {
                var item = new LinkedObject(dataWriter);

                if (root is null)
                {
                    root = item;
                    curr = item;
                }
                else
                {
                    item.Prev = curr;
                    curr      = item;
                }
            }
Пример #25
0
        public new void Clear()
        {
            GameEffect first = (GameEffect)Items;

            while (first != null)
            {
                LinkedObject n = first.Next;

                first.Destroy();

                first = (GameEffect)n;
            }

            Items = null;
        }
Пример #26
0
        public void MoveToFront(LinkedObject item)
        {
            if (item != null && item != First)
            {
                Unlink(item);

                if (First != null)
                {
                    First.Left = item;
                }

                item.Right = First;
                item.Left  = null;
                First      = item;
            }
        }
Пример #27
0
 public THeaderId Start(string p_HeaderName, LinkedObject p_LinkedObject = null)
 {
     if (InnerState == ProtocolWriteHeaderInnerState.Started)
     {
         throw new ProtocolWriteHeaderInnerStateException(
                   $"InnerState is {InnerState}, but must be {ProtocolWriteHeaderInnerState.Created} / {ProtocolWriteHeaderInnerState.Stopped}");
     }
     InnerState  = ProtocolWriteHeaderInnerState.Started;
     StartedTime = _DateTime.Now;
     HeaderId    = _ProtocolWriteRepository.Start(StartedTime.Value, _Login.Login, p_HeaderName);
     if (p_LinkedObject != null)
     {
         _ProtocolWriteRepository.AddLinkedObject(HeaderId, p_LinkedObject);
     }
     return(HeaderId);
 }
Пример #28
0
        public void MoveToFront(LinkedObject item)
        {
            if (item != null && item != Items)
            {
                Unlink(item);

                if (Items != null)
                {
                    Items.Previous = item;
                }

                item.Next     = Items;
                item.Previous = null;
                Items         = item;
            }
        }
Пример #29
0
        void MoveHandle()
        {
            if (Enabled)
            {
                if (Orientation == Orientation.Horizontal)
                {
                    NormalisedValue = (MouseInput.Position.X - (int)LinkedObject.GetCorner(Alignment.MiddleLeft).X) / LinkedObject.Size.X;
                }
                else
                {
                    NormalisedValue = ((int)LinkedObject.GetCorner(Alignment.MiddleLeft).Y - MouseInput.Position.Y) / LinkedObject.Size.X;
                }

                Value = Math.Clamp((NormalisedValue * (MaxValue + Math.Abs(MinValue))) + MinValue, MinValue, MaxValue);
                UpdateSlider();
            }
        }
Пример #30
0
        public void Clear()
        {
            while (_root != null)
            {
                LinkedObject n = _root.Next;

                foreach (GameEffect child in _root.Children)
                {
                    RemoveEffect(child);
                }

                _root.Children.Clear();

                RemoveEffect(_root);

                _root = (GameEffect)n;
            }
        }
Пример #31
0
        private LinkedObject GetOrAdd(LinkedObject ro, Action <UInt32> setter)
        {
            lock (Lock)
            {
                if (this.CollectionId == 0)
                {
                    throw new ObjectDisposedException(GetType().Name);
                }

                if (!TryGetUnderLock(ro.Key, out var result))
                {
                    result = ro;
                    AddUnderLock(ro, setter);
                }

                return(result);
            }
        }
Пример #32
0
        private void RemoveLastCommand()
        {
            if (_databox.Children.Count != 0)
            {
                LinkedObject last = Macro.GetLast();

                Macro.Remove(last);

                _databox.Children[_databox.Children.Count - 1].Dispose();

                SetupMacroUI();
            }

            if (_databox.Children.Count == 0)
            {
                AddEmptyMacro();
            }
        }
Пример #33
0
        public void PreviousTests()
        {
            var foo = new LinkedObject<string>("foo");
            var bar = new LinkedObject<string>("bar");
            var baz = new LinkedObject<string>("baz");

            foo.Previous = bar;
            bar.Previous = baz;

            Assert.AreSame(bar, foo.Previous);
            Assert.AreSame(baz, bar.Previous);
            Assert.IsNull(baz.Previous);

            Assert.AreSame(bar, baz.Next);
            Assert.AreSame(foo, bar.Next);
            Assert.IsNull(foo.Next);

            CollectionAssert.AreEqual(new[] { foo }, foo.After.ToList());
            CollectionAssert.AreEqual(new[] { foo, bar, baz }, foo.Before.ToList());
            CollectionAssert.AreEqual(new[] { baz }, baz.Before.ToList());
        }
Пример #34
0
        public void RemoveTests()
        {
            var foo = new LinkedObject<string>("foo");
            var bar = new LinkedObject<string>("bar");
            var baz = new LinkedObject<string>("baz");

            foo.Next = bar;
            bar.Next = baz;

            bar.Remove();

            Assert.IsNull(foo.Previous);
            Assert.AreSame(baz, foo.Next);

            Assert.AreSame(foo, baz.Previous);
            Assert.IsNull(baz.Next);

            Assert.IsNull(bar.Previous);
            Assert.IsNull(bar.Next);
        }