CryEngine.Attachment.TryAdd C# (CSharp) Méthode

TryAdd() static private méthode

static private TryAdd ( IntPtr ptr ) : Attachment
ptr System.IntPtr
Résultat Attachment
        internal static Attachment TryAdd(IntPtr ptr)
        {
            if (ptr == IntPtr.Zero)
                return null;

            var attachment = Attachments.FirstOrDefault(x => x.Handle == ptr);
            if (attachment == null)
            {
                attachment = new Attachment(ptr);

                Attachments.Add(attachment);
            }

            return attachment;
        }

Usage Example

Exemple #1
0
        /// <summary>
        /// Gets the attachment at the specified slot and index.
        /// </summary>
        /// <param name="index">Attachment index</param>
        /// <param name="characterSlot">Index of the character slot we wish to get an attachment from</param>
        /// <returns>null if failed, otherwise the attachment.</returns>
        public Attachment GetAttachment(int index, int characterSlot = 0)
        {
            var ptr = NativeEntityMethods.GetAttachmentByIndex(this.GetIEntity(), index, characterSlot);

            if (ptr == IntPtr.Zero)
            {
                return(null);
            }

            return(Attachment.TryAdd(ptr, this));
        }
All Usage Examples Of CryEngine.Attachment::TryAdd