public static String GetCarrying(PlayerControls playerControls) { ClientPlayerAttachmentCarrier clientCarrier = (ClientPlayerAttachmentCarrier)ReflectionUtil.GetValue(playerControls, "m_clientCarrier"); IClientAttachment[] carriedObjects = (IClientAttachment[])ReflectionUtil.GetValue(clientCarrier, "m_carriedObjects"); // Logger.Log($"Number of carried objects: {carriedObjects.Length}"); for (int i = 0; i < carriedObjects.Length; i++) { // Logger.Log($" Carried object is null: {carriedObjects[i] == null}"); // Logger.Log($" CarriedObject Type: {carriedObjects[i].GetType()}"); // Logger.Log($" Carried game object is null: {carriedObjects[i].AccessGameObject() == null}"); if (carriedObjects[i] != null) { if (carriedObjects[i].AccessGameObject() != null) { // Logger.Log($" Carried game object type: {carriedObjects[i].AccessGameObject()}"); return(carriedObjects[i].AccessGameObject().name); } } } return(""); }
public static void LogTestReflectionUtil() { Logger.Log("Test1"); ClientWorkstation[] stations = Object.FindObjectsOfType <ClientWorkstation>(); Logger.Log("Test2"); foreach (ClientWorkstation station in stations) { Logger.Log("Test3"); // ReflectionUtil.GetValue(station, "m_attachStation"); ClientAttachStation attachStation = (ClientAttachStation)ReflectionUtil.GetValue(station, "m_attachStation"); Logger.Log($"Test4: {attachStation.name}"); if (attachStation.InspectItem() != null) { Logger.Log($"Item on workstation: {attachStation.InspectItem()}"); } else { Logger.Log($"No item on workstation"); } Logger.Log("Test5"); } Logger.Log("Test6"); }
public static Component GetPlateLocationComponent(ClientPlate plate) { Component locationComponent = GetObjectLocationComponent(plate); if (locationComponent != null) { return(locationComponent); } ClientPlateReturnStation[] plateReturnStations = Object.FindObjectsOfType <ClientPlateReturnStation>(); foreach (ClientPlateReturnStation plateReturnStation in plateReturnStations) { ClientPlateStackBase plateStackBase = (ClientPlateStackBase)ReflectionUtil.GetValue(plateReturnStation, "m_stack"); ClientStack clientStack = (ClientStack)ReflectionUtil.GetValue(plateStackBase, "m_stack"); List <GameObject> stackItems = (List <GameObject>)ReflectionUtil.GetValue(clientStack, "m_stackItems"); if (stackItems.Contains(plate.gameObject)) { return(plateReturnStation); } } return(null); }
public bool IsChoppingNotBlocked(Component component) { if (component is ClientWorkstation clientWorkstation) { ClientAttachStation clientAttachStation = (ClientAttachStation)ReflectionUtil.GetValue(clientWorkstation, "m_attachStation"); return(clientAttachStation.InspectItem() == null); } return(false); }
/** * Return whether the attachstation given is not a bin/chopping-board/etc. */ public static bool IsCleanAttachStation(Component targetStation) { if (!(targetStation is ClientAttachStation)) { return(false); } // TODO: fill with all station types Dictionary <Type, String> stationMapping = new Dictionary <Type, string> { { typeof(ClientWorkstation), "m_attachStation" }, { typeof(ClientRubbishBin), "m_clientAttachStation" }, { typeof(ClientCookingStation), "m_attachStation" }, { typeof(ClientPlateReturnStation), "m_attachStation" }, { typeof(ClientPlateStation), "m_ClientAttachStation" }, }; foreach (Type type in stationMapping.Keys) { var stations = Object.FindObjectsOfType(type); foreach (var station in stations) { ClientAttachStation attachStation = (ClientAttachStation)ReflectionUtil.GetValue(station, type, stationMapping[type]); if (attachStation.Equals(targetStation)) { return(false); } } } // Different test for item containers, since they have no associated attach station Vector3 targetPos = targetStation.transform.position; foreach (ClientPickupItemSpawner spawner in Object.FindObjectsOfType <ClientPickupItemSpawner>()) { Vector3 spawnerPos = spawner.transform.position; if (new Vector2(spawnerPos.x - targetPos.x, spawnerPos.z - targetPos.z).sqrMagnitude < 0.1) { return(false); } } return(true); }
private bool IsCookableOnStation(ClientCookableContainer container, ClientCookingStation station) { if (ReflectionUtil.GetValue(station, "m_itemPot") == null) { Logger.Log("Cookable is not on station (null)"); return(false); } IClientCookable clientCookable = (IClientCookable)ReflectionUtil.GetValue(station, "m_itemPot"); if (clientCookable.Equals(container.GetCookingHandler())) { Logger.Log("Cookable is on station"); } else { Logger.Log("Cookable is not on station"); } return(clientCookable.Equals(container.GetCookingHandler())); }
public static ArrayList GetOrders(ClientKitchenFlowControllerBase flowController) { ArrayList recipes = new ArrayList(); ClientOrderControllerBase orderController = flowController.GetMonitorForTeam(TeamID.One).OrdersController; IEnumerable activeOrderFieldEnumerable = (IEnumerable)ReflectionUtil.GetValue(orderController, "m_activeOrders"); IEnumerator enumerator = activeOrderFieldEnumerable.GetEnumerator(); while (enumerator.MoveNext()) { RecipeList.Entry entry = (RecipeList.Entry)ReflectionUtil.GetValue(enumerator.Current, "RecipeListEntry"); recipes.Add(entry.m_order.name); } return(recipes); }
public static bool HasFinishedChopping(ClientWorkstation workstation) { ClientWorkableItem workableItem = (ClientWorkableItem)ReflectionUtil.GetValue(workstation, "m_item"); return(workableItem.HasFinished()); }