Example #1
0
        public static GameObject TryPlaceFurniture(SubRoot currentSub)
        {
            MultiplayerBuilder.Initialize();
            global::Utils.PlayEnvSound(MultiplayerBuilder.placeSound, MultiplayerBuilder.ghostModel.transform.position, 10f);

            GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(MultiplayerBuilder.prefab);
            bool       flag       = false;
            bool       flag2      = false;

            if (currentSub != null)
            {
                flag  = currentSub.isBase;
                flag2 = currentSub.isCyclops;
                gameObject.transform.parent = currentSub.GetModulesRoot();
            }
            else if (MultiplayerBuilder.placementTarget != null && MultiplayerBuilder.allowedOutside)
            {
                SubRoot componentInParent2 = MultiplayerBuilder.placementTarget.GetComponentInParent <SubRoot>();
                if (componentInParent2 != null)
                {
                    gameObject.transform.parent = componentInParent2.GetModulesRoot();
                }
            }

            Transform expr_138 = gameObject.transform;

            expr_138.position = MultiplayerBuilder.placePosition;
            expr_138.rotation = MultiplayerBuilder.placeRotation;
            Constructable componentInParent3 = gameObject.GetComponentInParent <Constructable>();

            componentInParent3.SetState(false, true);
            global::Utils.SetLayerRecursively(gameObject, LayerMask.NameToLayer((!flag) ? "Interior" : "Default"), true, -1);
            if (MultiplayerBuilder.ghostModel != null)
            {
                UnityEngine.Object.Destroy(MultiplayerBuilder.ghostModel);
            }

            componentInParent3.SetIsInside(flag || flag2);
            SkyEnvironmentChanged.Send(gameObject, currentSub);

            if (currentSub != null && currentSub.isCyclops)
            {
                gameObject.transform.localPosition = overridePosition;
                gameObject.transform.localRotation = overrideQuaternion;
            }
            else
            {
                gameObject.transform.position = overridePosition;
                gameObject.transform.rotation = overrideQuaternion;
            }

            MultiplayerBuilder.ghostModel = null;
            MultiplayerBuilder.prefab     = null;
            MultiplayerBuilder.canPlace   = false;

            return(gameObject);
        }
Example #2
0
        public static GameObject TryPlaceFurniture(SubRoot currentSub)
        {
#pragma warning disable CS0618
            //Disabling warning as we dont have the FModAsset to use instead.
            Utils.PlayEnvSound(PLACE_SOUND, ghostModel.transform.position);
#pragma warning restore CS0618

            GameObject gameObject = Object.Instantiate <GameObject>(prefab);
            bool       flag       = false;
            bool       flag2      = false;
            if (currentSub != null)
            {
                flag  = currentSub.isBase;
                flag2 = currentSub.isCyclops;
                gameObject.transform.parent = currentSub.GetModulesRoot();
            }
            else if (placementTarget != null && allowedOutside)
            {
                SubRoot componentInParent2 = placementTarget.GetComponentInParent <SubRoot>();
                if (componentInParent2 != null)
                {
                    gameObject.transform.parent = componentInParent2.GetModulesRoot();
                }
            }

            Transform expr138 = gameObject.transform;
            expr138.position = PlacePosition;
            expr138.rotation = PlaceRotation;
            Constructable componentInParent3 = gameObject.GetComponentInParent <Constructable>();
            componentInParent3.SetState(false);
            Utils.SetLayerRecursively(gameObject, LayerMask.NameToLayer((!flag) ? "Interior" : "Default"));
            if (ghostModel != null)
            {
                Object.Destroy(ghostModel);
            }

            componentInParent3.SetIsInside(flag || flag2);
            SkyEnvironmentChanged.Send(gameObject, currentSub);

            if (currentSub != null && currentSub.isCyclops)
            {
                gameObject.transform.localPosition = OverridePosition;
                gameObject.transform.localRotation = OverrideQuaternion;
            }
            else
            {
                gameObject.transform.position = OverridePosition;
                gameObject.transform.rotation = OverrideQuaternion;
            }

            ghostModel       = null;
            prefab           = null;
            RotationMetadata = Optional.Empty;

            return(gameObject);
        }
 public static bool OnHandClick_Prefix(GrownPlant __instance, GUIHand hand)
 {
     if (__instance.seed != null && __instance.seed.gameObject != null)
     {
         PrefabIdentifier prefabID = __instance.seed.gameObject.GetComponent <PrefabIdentifier>();
         if (prefabID == null)
         {
             return(true);
         }
         if (prefabID.ClassId == "MarbleMelonTiny")
         {
             PlantGenericController controllerA = __instance.gameObject.GetComponent <PlantGenericController>();
             if (controllerA == null)
             {
                 controllerA = __instance.seed.gameObject.GetComponent <PlantGenericController>();
             }
             if (controllerA != null && controllerA._progress >= 1.0f)
             {
                 if (__instance.seed.currentPlanter != null && Inventory.Get().HasRoomFor(1, 1))
                 {
                     __instance.seed.currentPlanter.RemoveItem(__instance.seed);
                     if (global::Utils.GetSubRoot() != null)
                     {
                         __instance.seed.pickupable.destroyOnDeath = false;
                     }
                     SkyEnvironmentChanged.Send(__instance.seed.pickupable.gameObject, Player.main.GetSkyEnvironment());
                     UnityEngine.Object.Destroy(__instance.seed.pickupable.gameObject);
                     CraftData.AddToInventorySync(CrafterLogicFixer.MarbleMelonTinyFruit, 1, false, false);
                     hand.player.PlayGrab();
                 }
             }
             return(false);
         }
         else if (prefabID.ClassId == "MarbleMelonTinyFruit")
         {
             if (__instance.seed.currentPlanter != null && __instance.seed.pickupable != null && Inventory.Get().HasRoomFor(__instance.seed.pickupable))
             {
                 PlantGenericController controllerA = __instance.gameObject.GetComponent <PlantGenericController>();
                 if (controllerA == null)
                 {
                     controllerA = __instance.seed.gameObject.GetComponent <PlantGenericController>();
                 }
                 if (controllerA != null && controllerA._progress >= 1.0f)
                 {
                     __instance.seed.currentPlanter.RemoveItem(__instance.seed);
                     Inventory.Get().Pickup(__instance.seed.pickupable, false);
                     hand.player.PlayGrab();
                 }
             }
             return(false);
         }
     }
     return(true);
 }
Example #4
0
        public override void Process(VehicleUndocking packet)
        {
            GameObject vehicleGo           = GuidHelper.RequireObjectFrom(packet.VehicleGuid);
            GameObject vehicleDockingBayGo = GuidHelper.RequireObjectFrom(packet.DockGuid);

            Vehicle           vehicle           = vehicleGo.RequireComponent <Vehicle>();
            VehicleDockingBay vehicleDockingBay = vehicleDockingBayGo.RequireComponentInChildren <VehicleDockingBay>();

            using (packetSender.Suppress <VehicleUndocking>())
            {
                vehicles.SetOnPilotMode(packet.VehicleGuid, packet.PlayerId, true);
                vehicleDockingBay.subRoot.BroadcastMessage("OnLaunchBayOpening", SendMessageOptions.DontRequireReceiver);
                SkyEnvironmentChanged.Broadcast(vehicleGo, (GameObject)null);
                vehicleDockingBay.ReflectionSet("_dockedVehicle", null);
                vehicle.docked = false;
                vehicle.useRigidbody.AddForce(Vector3.down * 5f, ForceMode.VelocityChange);
            }
        }
        public override void Process(VehicleUndocking packet)
        {
            GameObject vehicleGo           = NitroxEntity.RequireObjectFrom(packet.VehicleId);
            GameObject vehicleDockingBayGo = NitroxEntity.RequireObjectFrom(packet.DockId);

            Vehicle           vehicle           = vehicleGo.RequireComponent <Vehicle>();
            VehicleDockingBay vehicleDockingBay = vehicleDockingBayGo.RequireComponentInChildren <VehicleDockingBay>();

            using (packetSender.Suppress <VehicleUndocking>())
            {
                vehicles.SetOnPilotMode(packet.VehicleId, packet.PlayerId, true);
                vehicleDockingBay.subRoot.BroadcastMessage("OnLaunchBayOpening", SendMessageOptions.DontRequireReceiver);
                SkyEnvironmentChanged.Broadcast(vehicleGo, (GameObject)null);



                vehicle.StartCoroutine(WaitBeforePushDown(vehicle, vehicleDockingBay));
            }
        }
Example #6
0
        private void StartVehicleUndocking(VehicleUndocking packet, GameObject vehicleGo, Vehicle vehicle, VehicleDockingBay vehicleDockingBay)
        {
            Optional <RemotePlayer> player = remotePlayerManager.Find(packet.PlayerId);

            vehicleDockingBay.subRoot.BroadcastMessage("OnLaunchBayOpening", SendMessageOptions.DontRequireReceiver);
            SkyEnvironmentChanged.Broadcast(vehicleGo, (GameObject)null);

            if (player.HasValue)
            {
                RemotePlayer playerInstance = player.Value;
                vehicle.mainAnimator.SetBool("player_in", true);
                playerInstance.Attach(vehicle.playerPosition.transform);
                // It can happen that the player turns in circles around himself in the vehicle. This stops it.
                playerInstance.RigidBody.angularVelocity = Vector3.zero;
                playerInstance.ArmsController.SetWorldIKTarget(vehicle.leftHandPlug, vehicle.rightHandPlug);
                playerInstance.AnimationController["in_seamoth"] = vehicle is SeaMoth;
                playerInstance.AnimationController["in_exosuit"] = playerInstance.AnimationController["using_mechsuit"] = vehicle is Exosuit;
                vehicles.SetOnPilotMode(packet.VehicleId, packet.PlayerId, true);
                playerInstance.AnimationController.UpdatePlayerAnimations = false;
            }
            vehicleDockingBay.StartCoroutine(StartUndockingAnimation(vehicleDockingBay));
        }
        // Token: 0x06002B9D RID: 11165
        public static bool TryPlace()
        {
            MultiplayerBuilder.Initialize();
            if (MultiplayerBuilder.prefab == null || !MultiplayerBuilder.canPlace)
            {
                return(false);
            }
            global::Utils.PlayEnvSound(MultiplayerBuilder.placeSound, MultiplayerBuilder.ghostModel.transform.position, 10f);
            ConstructableBase componentInParent = MultiplayerBuilder.ghostModel.GetComponentInParent <ConstructableBase>();

            if (componentInParent != null)
            {
                BaseGhost component = MultiplayerBuilder.ghostModel.GetComponent <BaseGhost>();
                component.GhostBase.transform.position = overridePosition;
                component.Place();

                componentInParent.transform.position = overridePosition;

                component.transform.position = overridePosition;
                component.transform.rotation = overrideQuaternion;
                if (component.TargetBase != null)
                {
                    componentInParent.transform.SetParent(component.TargetBase.transform, true);
                }
                componentInParent.SetState(false, true);

                component.GhostBase.transform.position = overridePosition;

                if (component.TargetBase != null)
                {
                    component.TargetBase.transform.position = overridePosition;
                }
            }
            else
            {
                GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(MultiplayerBuilder.prefab);
                bool       flag       = false;
                bool       flag2      = false;
                SubRoot    currentSub = Player.main.GetCurrentSub();
                if (currentSub != null)
                {
                    flag  = currentSub.isBase;
                    flag2 = currentSub.isCyclops;
                    gameObject.transform.parent = currentSub.GetModulesRoot();
                }
                else if (MultiplayerBuilder.placementTarget != null && MultiplayerBuilder.allowedOutside)
                {
                    SubRoot componentInParent2 = MultiplayerBuilder.placementTarget.GetComponentInParent <SubRoot>();
                    if (componentInParent2 != null)
                    {
                        gameObject.transform.parent = componentInParent2.GetModulesRoot();
                    }
                }
                Transform expr_138 = gameObject.transform;
                expr_138.position = MultiplayerBuilder.placePosition;
                expr_138.rotation = MultiplayerBuilder.placeRotation;
                Constructable componentInParent3 = gameObject.GetComponentInParent <Constructable>();
                componentInParent3.SetState(false, true);
                global::Utils.SetLayerRecursively(gameObject, LayerMask.NameToLayer((!flag) ? "Interior" : "Default"), true, -1);
                componentInParent3.SetIsInside(flag | flag2);
                SkyEnvironmentChanged.Send(gameObject, currentSub);
                gameObject.transform.position = overridePosition;
                gameObject.transform.rotation = overrideQuaternion;
            }
            Console.WriteLine("mBuilder.ghostModel.transform.position: " + MultiplayerBuilder.ghostModel.transform.position);
            Console.WriteLine("mBuilder.placePosition: " + MultiplayerBuilder.placePosition);
            Console.WriteLine("m op: " + MultiplayerBuilder.overridePosition);
            Console.WriteLine("m oq: " + MultiplayerBuilder.overrideQuaternion);
            MultiplayerBuilder.ghostModel = null;
            MultiplayerBuilder.prefab     = null;
            MultiplayerBuilder.canPlace   = false;
            return(true);
        }
Example #8
0
        // Token: 0x060030FF RID: 12543 RVA: 0x0012D7E8 File Offset: 0x0012B9E8
        public static bool TryPlace(out GameObject outObject, out Constructable outConstructable)
        {
            outObject        = null;
            outConstructable = null;

            MultiplayerBuilder.Initialize();

            if (MultiplayerBuilder.prefab == null)
            {
                return(false);
            }

            Utils.PlayEnvSound(MultiplayerBuilder.placeSound, MultiplayerBuilder.ghostModel.transform.position, 10f);
            ConstructableBase componentInParent = MultiplayerBuilder.ghostModel.GetComponentInParent <ConstructableBase>();

            if (componentInParent != null)
            {
                MultiplayerBuilder.Update();
                BaseGhost component = MultiplayerBuilder.ghostModel.GetComponent <BaseGhost>();

                component.Place();
                if (component.TargetBase != null)
                {
                    componentInParent.transform.SetParent(component.TargetBase.transform, true);
                }
                componentInParent.SetState(false, true);

                componentInParent.transform.position = overridePosition;
                componentInParent.transform.rotation = overrideRotation;

                outObject        = componentInParent.gameObject;
                outConstructable = componentInParent;
            }
            else
            {
                MultiplayerBuilder.placementTarget = GuidHelper.Find(targetGuid);

                GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(MultiplayerBuilder.prefab);
                bool       flag       = false;
                bool       flag2      = false;

                SubRoot currentSub = Player.main.GetCurrentSub();
                if (currentSub != null)
                {
                    flag  = currentSub.isBase;
                    flag2 = currentSub.isCyclops;
                    gameObject.transform.parent = currentSub.GetModulesRoot();
                }
                else if (MultiplayerBuilder.placementTarget != null && MultiplayerBuilder.allowedOutside)
                {
                    SubRoot componentInParent2 = MultiplayerBuilder.placementTarget.GetComponentInParent <SubRoot>();
                    if (componentInParent2 != null)
                    {
                        gameObject.transform.parent = componentInParent2.GetModulesRoot();
                    }
                }
                Transform transform = gameObject.transform;
                transform.localPosition = overridePosition;
                transform.localRotation = overrideRotation;

                Constructable componentInParent3 = gameObject.GetComponentInParent <Constructable>();
                componentInParent3.SetState(false, true);
                Utils.SetLayerRecursively(gameObject, LayerMask.NameToLayer((!flag) ? "Interior" : "Default"), true, -1);
                if (MultiplayerBuilder.ghostModel != null)
                {
                    UnityEngine.Object.Destroy(MultiplayerBuilder.ghostModel);
                }
                componentInParent3.SetIsInside(flag || flag2);
                SkyEnvironmentChanged.Send(gameObject, currentSub);

                transform.localPosition = overridePosition;
                transform.localRotation = overrideRotation;

                outObject        = gameObject;
                outConstructable = componentInParent3;
            }
            MultiplayerBuilder.ghostModel = null;
            MultiplayerBuilder.prefab     = null;
            MultiplayerBuilder.canPlace   = false;
            return(true);
        }