From 58d9c0568ae37e47c4bebcd101837314136b4b81 Mon Sep 17 00:00:00 2001 From: Ollie <69084614+olijeffers0n@users.noreply.github.com> Date: Tue, 14 Mar 2023 17:18:00 +0000 Subject: [PATCH] Add Entity Grabber --- rustplus/__init__.py | 2 +- rustplus/api/remote/camera/camera_manager.py | 13 +++++++++++-- rustplus/api/remote/camera/structures.py | 3 +++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/rustplus/__init__.py b/rustplus/__init__.py index dfc22fc..5378b3a 100644 --- a/rustplus/__init__.py +++ b/rustplus/__init__.py @@ -22,5 +22,5 @@ __name__ = "rustplus" __author__ = "olijeffers0n" -__version__ = "5.5.5" +__version__ = "5.5.6" __support__ = "Discord: https://discord.gg/nQqJe8qvP8" diff --git a/rustplus/api/remote/camera/camera_manager.py b/rustplus/api/remote/camera/camera_manager.py index d45466f..f37f543 100644 --- a/rustplus/api/remote/camera/camera_manager.py +++ b/rustplus/api/remote/camera/camera_manager.py @@ -1,12 +1,12 @@ import time -from typing import Iterable, Union +from typing import Iterable, Union, List from PIL import Image from .camera_parser import Parser from ..rustplus_proto import AppCameraInput, Vector2, AppEmpty from ...structures import Vector -from .structures import CameraInfo, LimitedQueue +from .structures import CameraInfo, LimitedQueue, Entity class CameraManager: @@ -94,3 +94,12 @@ async def exit_camera(self) -> None: async def resubscribe(self) -> None: await self.rust_socket.remote.subscribe_to_camera(self._cam_id, True) self.time_since_last_subscribe = time.time() + + async def get_entities_in_frame(self) -> List[Entity]: + if self._last_packets is None: + return [] + + if len(self._last_packets) == 0: + return [] + + return self._last_packets.get_last().entities \ No newline at end of file diff --git a/rustplus/api/remote/camera/structures.py b/rustplus/api/remote/camera/structures.py index 1456f99..fd5f59d 100644 --- a/rustplus/api/remote/camera/structures.py +++ b/rustplus/api/remote/camera/structures.py @@ -66,6 +66,9 @@ def get(self, index=0) -> Any: return self._queue[index] + def get_last(self) -> Any: + return self.get(-1) + def pop(self) -> Any: return self._queue.pop(0)