public static Entity GetLocalSimPawnEntity(ExternalSimWorldAccessor simulationWorld) { Entity localPlayerEntity = PlayerHelpers.GetLocalSimPlayerEntity(simulationWorld); // player is controlling an entity if (localPlayerEntity != Entity.Null && simulationWorld.TryGetComponent(localPlayerEntity, out ControlledEntity controlledEntity)) { // entity still exists and is controllable if (simulationWorld.Exists(controlledEntity.Value) && simulationWorld.HasComponent <Controllable>(controlledEntity.Value)) { return(controlledEntity.Value); } } return(Entity.Null); }