Skip to content

Commit

Permalink
Add Entity Grabber
Browse files Browse the repository at this point in the history
  • Loading branch information
olijeffers0n committed Mar 14, 2023
1 parent 9a8703f commit 58d9c05
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion rustplus/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@

__name__ = "rustplus"
__author__ = "olijeffers0n"
__version__ = "5.5.5"
__version__ = "5.5.6"
__support__ = "Discord: https://discord.gg/nQqJe8qvP8"
13 changes: 11 additions & 2 deletions rustplus/api/remote/camera/camera_manager.py
Original file line number Diff line number Diff line change
@@ -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:
Expand Down Expand Up @@ -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
3 changes: 3 additions & 0 deletions rustplus/api/remote/camera/structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 58d9c05

Please sign in to comment.