public static void Postfix(SubNameInput __instance, ColorChangeEventData eventData) { SubName subname = (SubName)__instance.ReflectionGet("target"); if (subname != null) { GameObject parentVehicle; Vehicle vehicle = subname.GetComponentInParent <Vehicle>(); SubRoot subRoot = subname.GetComponentInParent <SubRoot>(); if (vehicle) { parentVehicle = vehicle.gameObject; } else { parentVehicle = subRoot.gameObject; } NitroxId id = NitroxIdentifier.GetId(parentVehicle); VehicleColorChange packet = new VehicleColorChange(__instance.SelectedColorIndex, id, eventData.hsb, eventData.color); NitroxServiceLocator.LocateService <IPacketSender>().Send(packet); } }
public static void Postfix(SubNameInput __instance, ColorChangeEventData eventData) { SubName subname = (SubName)__instance.ReflectionGet("target"); if (subname != null) { GameObject parentVehicle; // This patch works for the vehicles as well as the cyclops; this has to be found for a proper and synced guid. SubRoot subRoot = subname.GetComponentInParent <SubRoot>(); if (subRoot) { parentVehicle = subRoot.gameObject; } else { parentVehicle = subname.GetComponent <Vehicle>().gameObject; } string guid = GuidHelper.GetGuid(parentVehicle); VehicleColorChange packet = new VehicleColorChange(__instance.SelectedColorIndex, guid, eventData.hsb, eventData.color); Multiplayer.PacketSender.Send(packet); } }