Пример #1
0
        public void UnloadObject(Object obj)
        {
            if (obj == null || GetGameSession() == null)
            {
                return;
            }
            switch (obj)
            {
            case Collectable collectable:
                Storage.UnLoadCollectable(collectable);
                break;

            case Asset asset:
                Storage.UnloadAsset(asset);
                break;

            case Jumpgate portal:
                Storage.UnloadPortal(portal);
                break;

            default:
            {
                if (Storage.LoadedObjects.ContainsKey(obj.Id))
                {
                    Storage.LoadedObjects.TryRemove(obj.Id, out _);
                }
                break;
            }
            }
        }
Пример #2
0
 public void ClickableCheck(Object obj)
 {
     if (obj is IClickable && obj.Position != null)
     {
         var active = Vector.IsInRange(Position, obj.Position, obj.Range);
         Packet.Builder.MapAssetActionAvailableCommand(World.StorageManager.GetGameSession(Id), obj, active);
     }
 }
Пример #3
0
        public bool RemoveObject(Object obj)
        {
            var collectable = obj as Collectable;

            if (collectable != null)
            {
                Collectables.Remove(collectable.Hash);
            }
            return(Objects.TryRemove(obj.Id, out obj));
        }
Пример #4
0
 public bool RemoveObject(Object obj)
 {
     if (obj == null)
     {
         return(false);
     }
     RemovedObject?.Invoke(this, obj);
     obj.Position = null;
     return(Objects.TryRemove(obj.Id, out obj));
 }
Пример #5
0
        public void LoadObject(Object obj)
        {
            if (obj == null || obj.Position == null || GetGameSession() == null)
            {
                return;
            }

            if (obj is Station)
            {
                Storage.LoadStation(obj as Station);
            }
            else if (obj is Jumpgate)
            {
                Storage.LoadPortal(obj as Jumpgate);
            }
            else if (obj is Asteroid)
            {
                Storage.LoadAsteroid(obj as Asteroid);
            }
            else if (obj is Asset)
            {
                Storage.LoadAsset(obj as Asset);
            }
            else if (obj is Billboard)
            {
                Storage.LoadBillboard(obj as Billboard);
            }
            else
            {
                //if (obj.Position.DistanceTo(Position) < 2000)
                //{
                if (obj is Collectable)
                {
                    Storage.LoadCollectable(obj as Collectable);
                }
                else if (obj is Ore)
                {
                    Storage.LoadResource(obj as Ore);
                }
                else if (obj is Mine)
                {
                    Storage.LoadMine(obj as Mine);
                }
                else if (obj is Firework)
                {
                    Storage.LoadFirework(obj as Firework);
                }
                //}
                if (!Storage.LoadedObjects.ContainsKey(obj.Id))
                {
                    Storage.LoadedObjects.TryAdd(obj.Id, obj);
                }
            }
        }
Пример #6
0
        public bool AddObject(Object obj)
        {
            var collectable = obj as Collectable;

            if (collectable != null)
            {
                if (!Collectables.ContainsKey(collectable.Hash))
                {
                    Collectables.Add(collectable.Hash, collectable);
                }
            }
            else if (obj is Ore ore)
            {
                if (!Resources.ContainsKey(ore.Hash))
                {
                    Resources.Add(ore.Hash, ore);
                }
            }
            return(Objects.TryAdd(obj.Id, obj));
        }
Пример #7
0
 public bool AddObject(Object obj)
 {
     return(Objects.TryAdd(obj.Id, obj));
 }