Ejemplo n.º 1
0
        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>();
                Rocket     rocket  = subname.GetComponentInParent <Rocket>();

                if (vehicle)
                {
                    parentVehicle = vehicle.gameObject;
                }
                else if (rocket)
                {
                    parentVehicle = rocket.gameObject;
                }
                else
                {
                    parentVehicle = subRoot.gameObject;
                }

                NitroxId           id     = NitroxEntity.GetId(parentVehicle);
                VehicleColorChange packet = new VehicleColorChange(__instance.SelectedColorIndex, id, eventData.hsb.ToDto(), eventData.color.ToDto());
                NitroxServiceLocator.LocateService <IPacketSender>().Send(packet);
            }
        }
Ejemplo n.º 2
0
        private void OnColorChange(ColorChangeEventData eventData)
        {
            Color selectedColor = eventData.color;

            GameObject selectedColorGameObject = playerSettingsPanel.RequireGameObject("BaseTab/SelectedColor");

            Image baseTabSelectedColorImage = selectedColorGameObject.GetComponent <Image>();

            baseTabSelectedColorImage.color = selectedColor;
        }
        public static void Postfix(SubNameInput __instance, ColorChangeEventData eventData)
        {
            Player player = (Player)__instance.ReflectionGet("player");

            if (player != null)
            {
                String guid = GuidHelper.GetGuid(player.GetCurrentSub().gameObject);
                Multiplayer.Logic.Cyclops.ChangeColor(guid, __instance.SelectedColorIndex, eventData.hsb, eventData.color);
            }
        }
        public static void Postfix(SubNameInput __instance, ColorChangeEventData eventData)
        {
            SubName subname = __instance.target;

            if (subname)
            {
                GameObject parentVehicle;
                NitroxId   controllerId = null;

                if (subname.TryGetComponent(out Vehicle vehicle))
                {
                    parentVehicle = vehicle.gameObject;

                    GameObject baseCell = __instance.gameObject.RequireComponentInParent <BaseCell>().gameObject;
                    GameObject moonpool = baseCell.RequireComponentInChildren <BaseFoundationPiece>().gameObject;

                    controllerId = NitroxEntity.GetId(moonpool);
                }
                else if (subname.TryGetComponentInParent(out SubRoot subRoot))
                {
                    parentVehicle = subRoot.gameObject;
                }
                else if (subname.TryGetComponentInParent(out Rocket rocket))
                {
                    // For some reason only the rocket has a full functioning ghost with a different NitroxId when spawning/constructing, so we are ignoring it.
                    if (rocket.TryGetComponentInChildren(out VFXConstructing constructing) && !constructing.isDone)
                    {
                        return;
                    }

                    parentVehicle = rocket.gameObject;
                }
                else
                {
                    Log.Error($"[SubNameInput_OnColorChange_Patch] The GameObject {subname.gameObject.name} doesn't have a Vehicle/SubRoot/Rocket component.");
                    return;
                }

                NitroxId           vehicleId = NitroxEntity.GetId(parentVehicle);
                VehicleColorChange packet    = new(__instance.SelectedColorIndex, controllerId, vehicleId, eventData.hsb.ToDto(), eventData.color.ToDto());
                Resolve <ThrottledPacketSender>().SendThrottled(packet);
            }
        }
Ejemplo n.º 5
0
        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;
                }

                string             guid   = GuidHelper.GetGuid(parentVehicle);
                VehicleColorChange packet = new VehicleColorChange(__instance.SelectedColorIndex, guid, 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);
            }
        }