Beispiel #1
0
 public void Value(ISharedBaseObject value)
 {
     if (currents.TryPeek(out currCurr))
     {
         currCurr.Values.Add(value);
     }
 }
Beispiel #2
0
        public bool CreateRef(ISharedBaseObject baseObject, bool safe)
        {
            if (baseObject == null)
            {
                return(false);
            }
            try
            {
                if (!baseObject.AddRef())
                {
                    // Check safe to prevent throw on TryToAsync calls
                    if (!safe && throwOnExistsCheck)
                    {
                        throw baseObject switch
                              {
                                  IEntity entity => new EntityRemovedException(entity),
                                  IWorldObject worldObject => new WorldObjectRemovedException(worldObject),
                                  _ => new BaseObjectRemovedException(baseObject)
                              };
                    }

                    return(false);
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
                return(false);
            }

            Alt.CoreImpl.CountUpRefForCurrentThread(baseObject);
            baseObjectRefs.AddLast(baseObject);
            return(true);
        }
Beispiel #3
0
 public void CreateMValueBaseObject(out MValueConst mValue, ISharedBaseObject value)
 {
     unsafe
     {
         mValue = new MValueConst(this, MValueConst.Type.BaseObject,
                                  Library.Shared.Core_CreateMValueBaseObject(NativePointer, value.BaseObjectNativePointer));
     }
 }
        public static void CreateLocked(ISharedBaseObject baseObject, IRefContext refContext, out MValueConst mValue)
        {
            if (!refContext.CreateRef(baseObject))
            {
                mValue = MValueConst.Nil;
                return;
            }

            Alt.Core.CreateMValueBaseObject(out mValue, baseObject);
        }
Beispiel #5
0
        public bool CheckIfExists(ISharedBaseObject baseObject)
        {
            if (baseObject.Exists)
            {
                return(true);
            }
            if (throwOnExistsCheck)
            {
                throw new BaseObjectRemovedException(baseObject);
            }

            return(false);
        }
 public IllegalThreadException(ISharedBaseObject baseObject) : base(
         $"API from {baseObject} called in wrong thread with name {Thread.CurrentThread.Name} and id {Thread.CurrentThread.ManagedThreadId}")
 {
 }
 public void CreateMValueBaseObject(out MValueConst mValue, ISharedBaseObject value)
 {
     throw new NotImplementedException();
 }
 internal BaseObjectRemovedException(ISharedBaseObject baseObject) : base(
         $"BaseObject(Type: {baseObject.Type.ToString()}) got deleted.")
 {
 }