コード例 #1
0
        private static void UpdateLocalPlayerPda(INitroxPlayer player, PingInstance ping)
        {
            PDA          localPlayerPda      = Player.main.GetPDA();
            GameObject   pdaScreenGameObject = localPlayerPda.ui.gameObject;
            GameObject   pingTabGameObject   = pdaScreenGameObject.transform.Find("Content/PingManagerTab").gameObject;
            uGUI_PingTab pingTab             = pingTabGameObject.GetComponent <uGUI_PingTab>();

            MethodInfo updateEntities = typeof(uGUI_PingTab).GetMethod("UpdateEntries", BindingFlags.NonPublic | BindingFlags.Instance);

            updateEntities.Invoke(pingTab,
                                  new object[]
            {
            });

            FieldInfo pingTabEntriesField = typeof(uGUI_PingTab).GetField("entries", BindingFlags.NonPublic | BindingFlags.Instance);
            Dictionary <int, uGUI_PingEntry> pingEntries = (Dictionary <int, uGUI_PingEntry>)pingTabEntriesField.GetValue(pingTab);
            uGUI_PingEntry pingEntry = pingEntries[ping.GetInstanceID()];

            pingEntry.icon.color = player.PlayerSettings.PlayerColor.ToUnity();

            GameObject pingEntryGameObject = pingEntry.gameObject;

            pingEntryGameObject.transform.Find("ColorToggle").gameObject.SetActive(false);

            if (!localPlayerPda.isInUse)
            {
                pdaScreenGameObject.gameObject.SetActive(false);
            }
        }
コード例 #2
0
        private static void SetInGamePingColor(INitroxPlayer player, PingInstance ping)
        {
            uGUI_Pings pings = Object.FindObjectOfType <uGUI_Pings>();

            MethodInfo setColor = typeof(uGUI_Pings).GetMethod("OnColor", BindingFlags.NonPublic | BindingFlags.Instance);

            setColor.Invoke(pings, new object[] { ping.GetInstanceID(), player.PlayerSettings.PlayerColor });
        }
コード例 #3
0
 public static void Postfix(PingInstance instance)
 {
     if (!instance)
     {
         return;
     }
     NitroxServiceLocator.LocateService <IPacketSender>().Send(new PingRenamed(NitroxEntity.GetId(instance.gameObject), instance.GetLabel(), SerializationHelper.GetBytes(instance.gameObject)));
 }
コード例 #4
0
        private static void Postfix(PingInstance __instance)
        {
            var saver = __instance.gameObject.GetComponent <PingInstanceSaver>();

            if (saver == null)
            {
                saver = __instance.gameObject.AddComponent <PingInstanceSaver>();
            }
        }
コード例 #5
0
        public static void Postfix(PingInstance instance)
        {
            // Only beacons are synced here (not mission, vehicle or other signals) because spawning is handled differently for non-droppable entities
            if (!instance || !instance.GetComponent <Beacon>())
            {
                return;
            }

            PingRenamed packet = new(NitroxEntity.GetId(instance.gameObject), instance.GetLabel(), SerializationHelper.GetBytes(instance.gameObject));

            NitroxServiceLocator.LocateService <IPacketSender>().Send(packet);
        }
コード例 #6
0
        static IEnumerator SpawnDeathMarker()
        {
            // Delay spawning the marker so that it doesn't end up right in the player's face
            yield return(new WaitForSeconds(5));

            GameObject            pingBase       = new GameObject();
            GameObject            pingModel      = GameObject.Instantiate(Resources.Load <GameObject>("WorldEntities/Tools/DiveReelNode"));
            PingInstance          ping           = pingBase.AddComponent <PingInstance>();
            Light                 pingLight      = pingModel.AddComponent <Light>();
            SphereCollider        pingCollider   = pingModel.AddComponent <SphereCollider>();
            DeathMarkerInteractor pingInteractor = pingModel.AddComponent <DeathMarkerInteractor>();

            pingCollider.radius = 0.35f;

            // Set options for the light.
            pingLight.color = new Color(112 / 255, 255 / 255, 3 / 255, 0.25f);
            pingLight.type  = LightType.Point;
            pingLight.range = 10f;

            // Parent transforms
            pingModel.transform.SetParent(pingBase.transform);
            pingLight.transform.SetParent(pingModel.transform);
            pingCollider.transform.SetParent(pingModel.transform);

            // Set the ping to the player's position at death.
            Vector3 playerPos = SubnauticaDeathMarker.DeathPosition;

            pingBase.transform.position = playerPos;

            // Set information about the ping.
            ping.enabled    = false;
            ping.pingType   = PingType.Signal;
            ping.origin     = pingBase.transform;
            ping.colorIndex = 0;
            ping.visible    = true;

            if (SubnauticaDeathMarker.Config.AddCoords)
            {
                ping.SetLabel($"Death ({playerPos.x:F1}, {playerPos.y:F1}, {playerPos.z:F1})");
            }
            else
            {
                ping.SetLabel("Death");
            }

            ping.enabled = true;

            pingInteractor.Ping = ping;

            PingManager.Register(ping);
        }
コード例 #7
0
ファイル: PlayerModelManager.cs プロジェクト: volcmen/Nitrox
        public void AttachPing(INitroxPlayer player)
        {
            GameObject signalBase = Object.Instantiate(SignalBasePrototype, player.PlayerModel.transform, false);

            signalBase.name = "signal" + player.PlayerName;

            PingInstance ping = signalBase.GetComponent <PingInstance>();

            ping.SetLabel("Player " + player.PlayerName);
            ping.pingType = PingType.Signal;

            UpdateLocalPlayerPda(player, ping);
            SetInGamePingColor(player, ping);
        }
コード例 #8
0
        public void Awake()
        {
            pingInstance        = gameObject.EnsureComponent <PingInstance>();
            pingInstance.origin = transform;

            prefabIdentifier = gameObject.GetComponent <PrefabIdentifier>();

            if (prefabIdentifier == null)
            {
                DestroyImmediate(this);
            }

            isSignalReady = true;
        }
コード例 #9
0
ファイル: PlayerPingBuilder.cs プロジェクト: m1ksu/Nitrox
        private static void SetPingColor(RemotePlayer player, PingInstance ping)
        {
            FieldInfo field = typeof(PingManager).GetField("colorOptions", BindingFlags.Static | BindingFlags.Public);

            Color[] colors = PingManager.colorOptions;

            Color[] colorOptions = new Color[colors.Length + 1];
            colors.ForEach(color => colorOptions[Array.IndexOf(colors, color)] = color);
            colorOptions[colorOptions.Length - 1] = player.PlayerSettings.PlayerColor;

            // Replace the normal colorOptions with our colorOptions (has one color more with the player-color). Set the color of the ping with this. Then replace it back.
            field.SetValue(null, colorOptions);
            ping.SetColor(colorOptions.Length - 1);
        }
コード例 #10
0
ファイル: PlayerPingBuilder.cs プロジェクト: m1ksu/Nitrox
        public void Build(RemotePlayer player)
        {
            GameObject signalBase = Object.Instantiate(Resources.Load("VFX/xSignal")) as GameObject;

            signalBase.name = "signal" + player.PlayerName;
            signalBase.transform.localScale     = new Vector3(.5f, .5f, .5f);
            signalBase.transform.localPosition += new Vector3(0, 0.8f, 0);
            signalBase.transform.SetParent(player.PlayerModel.transform, false);

            PingInstance ping = signalBase.GetComponent <PingInstance>();

            ping.SetLabel("Player " + player.PlayerName);
            ping.pingType = PingType.Signal;

            SetPingColor(player, ping);
        }
コード例 #11
0
        public void Initialize(PingInstance target)
        {
            base.Initialize();

            this.target = target;

            var sprite = ImageUtils.LoadSprite(Mod.GetAssetPath("Circle.png"), new Vector2(0.5f, 0.5f));

            for (int i = 0; i < buttons.Count; ++i)
            {
                var button = buttons[i];
                button.Initialize(i, CustomPings.GetColor(i), i == target.colorIndex, sprite);
            }

            onSelect = OnSelect;
        }
コード例 #12
0
        private void Awake()
        {
            ping = GetComponent <PingInstance>();
            var uniqueIdentifier = GetComponent <PrefabIdentifier>();

            if (uniqueIdentifier != null)
            {
                id = uniqueIdentifier.Id;
            }
            else if (gameObject.name == "EscapePod")
            {
                id = "EscapePod";
            }
            else
            {
                Logger.Error("Created a PingInstance with no uniqueIdentifier (" + gameObject.name + ")");
                Destroy(this);
            }
        }
コード例 #13
0
        public RemotePlayer(string playerId)
        {
            PlayerId = playerId;
            GameObject originalBody = GameObject.Find("body");

            //Cheap fix for showing head, much easier since male_geo contains many different heads
            originalBody.GetComponentInParent <Player>().head.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.On;
            body = Object.Instantiate(originalBody);
            originalBody.GetComponentInParent <Player>().head.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.ShadowsOnly;

            rigidBody            = body.AddComponent <Rigidbody>();
            rigidBody.useGravity = false;

            //Get player
            playerView = body.transform.Find("player_view").gameObject;

            //Move variables to keep player animations from mirroring and for identification
            playerView.GetComponent <ArmsController>().smoothSpeed = 0;

            //Sets a new language value
            Language language = Language.main;
            JsonData data     = (JsonData)language.ReflectionGet("strings"); //UM4SN only: JsonData data = language.strings;

            data["Signal_" + playerId] = "Player " + playerId;

            //Sets up a copy from the xSignal template for the signal
            //todo: settings menu to disable this?
            GameObject signalBase = Object.Instantiate(Resources.Load("VFX/xSignal")) as GameObject;

            signalBase.name = "signal" + playerId;
            signalBase.transform.localPosition += new Vector3(0, 0.8f, 0);
            signalBase.transform.SetParent(playerView.transform, false);
            SignalLabel  label = signalBase.GetComponent <SignalLabel>();
            PingInstance ping  = signalBase.GetComponent <PingInstance>();

            label.description = "Signal_" + playerId;
            ping.pingType     = PingType.Signal;

            animationController = playerView.AddComponent <AnimationController>();

            ErrorMessage.AddMessage($"{playerId} joined the game.");
        }
コード例 #14
0
        /// <summary>
        /// Will create a new remote player object from their custom properties
        /// </summary>
        /// <param name="player">The remote player to create an object for</param>
        /// <returns>The remote player objects PhotonView.viewID, to be stored in the dictionary</returns>
        int CreateNewPlayerPrefab(PhotonPlayer player)
        {
            // Gets the ID allocated by the remote player from the customproperties
            int        id        = (int)player.CustomProperties["ObjectID"];
            GameObject newPlayer = Instantiate(remotePlayerPrefab);

            PhotonView newView = newPlayer.GetComponent <PhotonView>();

            newView.enabled = true;
            newView.viewID  = id;
            newView.TransferOwnership(player);

            GameObject   signal = newPlayer.transform.Find("signalbase").gameObject;
            PingInstance ping   = signal.GetComponent <PingInstance>();

            ping.SetLabel(player.NickName);
            signal.SetActive(true);

            return(id);
        }
コード例 #15
0
        public void Awake()
        {
            //Debug.Log($"Spawning fragment at position: {transform.position}");

            signal = Instantiate(Resources.Load <GameObject>("worldentities/environment/generated/signal"));

            techTag = gameObject.GetComponent <TechTag>();

            SignalPing signalPing = signal.GetComponent <SignalPing>();

            signalPing.enabled = false;

            pingInstance = signal.GetComponent <PingInstance>();

            pingInstance.displayPingInManager = true;
            pingInstance.pingType             = PingType.Signal;
            pingInstance.visible = true;
            pingInstance.minDist = 5;
            pingInstance.maxDist = 10;
            pingInstance.origin  = transform;
        }
コード例 #16
0
        private static void UpdateLocalPlayerPda(INitroxPlayer player, PingInstance ping)
        {
            PDA          localPlayerPda      = Player.main.GetPDA();
            GameObject   pdaScreenGameObject = localPlayerPda.ui.gameObject;
            GameObject   pingTabGameObject   = pdaScreenGameObject.transform.Find("Content/PingManagerTab").gameObject;
            uGUI_PingTab pingTab             = pingTabGameObject.GetComponent <uGUI_PingTab>();

            pingTab.UpdateEntries();
            Dictionary <int, uGUI_PingEntry> pingEntries = pingTab.entries;
            uGUI_PingEntry pingEntry = pingEntries[ping.GetInstanceID()];

            pingEntry.icon.color = player.PlayerSettings.PlayerColor.ToUnity();

            GameObject pingEntryGameObject = pingEntry.gameObject;

            pingEntryGameObject.transform.Find("ColorToggle").gameObject.SetActive(false);

            if (!localPlayerPda.isInUse)
            {
                pdaScreenGameObject.gameObject.SetActive(false);
            }
        }
コード例 #17
0
        public RemotePlayer(string playerId)
        {
            PlayerId = playerId;
            GameObject originalBody = GameObject.Find("body");

            //Cheap fix for showing head, much easier since male_geo contains many different heads
            originalBody.GetComponentInParent <Player>().head.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.On;
            Body = Object.Instantiate(originalBody);
            originalBody.GetComponentInParent <Player>().head.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.ShadowsOnly;


            RigidBody            = Body.AddComponent <Rigidbody>();
            RigidBody.useGravity = false;

            //Get player
            PlayerView = Body.transform.Find("player_view").gameObject;

            //Move variables to keep player animations from mirroring and for identification
            ArmsController = PlayerView.GetComponent <ArmsController>();
            ArmsController.smoothSpeedUnderWater = 0;
            ArmsController.smoothSpeedAboveWater = 0;

            //Sets up a copy from the xSignal template for the signal
            //todo: settings menu to disable this?
            GameObject signalBase = Object.Instantiate(Resources.Load("VFX/xSignal")) as GameObject;

            signalBase.name = "signal" + playerId;
            signalBase.transform.localScale     = new Vector3(.5f, .5f, .5f);
            signalBase.transform.localPosition += new Vector3(0, 0.8f, 0);
            signalBase.transform.SetParent(PlayerView.transform, false);
            PingInstance ping = signalBase.GetComponent <PingInstance>();

            ping.SetLabel("Player " + playerId);
            ping.pingType = PingType.Signal;

            AnimationController = PlayerView.AddComponent <AnimationController>();

            ErrorMessage.AddMessage($"{playerId} joined the game.");
        }
コード例 #18
0
        /// <summary>
        /// Creates the initial prefab to be used when other players join the game
        /// </summary>
        void InitRemotePlayerPrefab()
        {
            GameObject playerBody = Player.main.transform.Find("body").gameObject;

            // Set the ID to zero before cloning to avoid a duplicate ID being created and throwing an exception (ids of zero are ignored)
            int id = localPlayerView.viewID;

            localPlayerView.viewID = 0;

            // Set the player's head to be visible, clone it then revert it back to create an appropriate remote prefab
            Player.main.head.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.On;
            remotePlayerPrefab = Instantiate(playerBody, Vector3.one * 10000f, Quaternion.identity);

            localPlayerView.viewID = id;

            Player.main.head.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.ShadowsOnly;

            // Remove all components that we dont need from the remote player prefab
            remotePlayerPrefab.RemoveNonEssentialComponents(remotePlayerEssentials);

            remotePlayerPrefab.GetComponent <PhotonView>().enabled = false;

            GameObject signalBase = Instantiate(Resources.Load("VFX/xSignal"), remotePlayerPrefab.transform) as GameObject;

            signalBase.name = "signalbase";
            signalBase.transform.localScale     = new Vector3(.5f, .5f, .5f);
            signalBase.transform.localPosition += new Vector3(0, 0.8f, 0);

            PingInstance ping = signalBase.GetComponent <PingInstance>();

            ping.pingType = PingType.Sunbeam;
            signalBase.SetActive(false);

            // Now that we have created the initial prefab we can begin to spawn other players
            canCreateRemotePlayerObjects = true;
        }
コード例 #19
0
        public void Initialize(PingInstance target)
        {
            base.Initialize();

            this.target = target;

            var names  = Enum.GetNames(typeof(PingType));
            var values = (PingType[])Enum.GetValues(typeof(PingType));
            var color  = CustomPings.GetColor(target.colorIndex);

            for (int i = 0; i < buttons.Count; ++i)
            {
                var button = buttons[i];
                var name   = names[i + 1];
                var value  = values[i + 1];
                var sprite = SpriteManager.Get(SpriteManager.Group.Pings, name);
                button.Initialize(i, color, value == target.pingType, sprite);
            }

            onSelect = OnSelect;
            int initialPage = GetPageForType(target.pingType);

            ShowPage(initialPage);
        }
コード例 #20
0
        public static PingInstance AddNewBeacon(GameObject gameObject, PingType pingType, string beaconName, int minDist, int maxDist)
        {
            Initialize();
            if (cachedSprites.ContainsKey(pingType) == false)
            {
                Log.Error($"CustomBeaconManager::AddNewBeacon attempted to add a beacon with a PingType ({pingType}) that was not registered with CustomBeaconManager::RegisterNewPingType", false);
                return(null);
            }

            PingInstance pingInstance = gameObject.GetOrAddComponent <PingInstance>();

            pingInstance.pingType = pingType;
            pingInstance.minDist  = minDist;
            pingInstance.maxDist  = maxDist;
            pingInstance.origin   = gameObject.transform;
            pingInstance.SetLabel(beaconName);

            if (pingUI != null)
            {
                pingUI.pings[pingInstance.GetInstanceID()].SetIcon(cachedSprites[pingType]);
            }

            return(pingInstance);
        }
コード例 #21
0
        private void DrawCyclopsDebugMenu()
        {
            if (GUILayout.Button("Destroy Cyclops static mesh"))
            {
                Ray ray4 = Camera.main.ScreenPointToRay(Input.mousePosition);
                if (Physics.Raycast(ray4, out RaycastHit raycastHit4))
                {
                    if (raycastHit4.rigidbody.gameObject.name.ToLower().Contains("cyclops"))
                    {
                        Transform transform = raycastHit4.rigidbody.gameObject.transform.Find("CyclopsMeshStatic");
                        Log.Print("Size 1: " + transform.GetComponentInChildren <MeshFilter>().mesh.triangles.Length);
                        Log.Print("Size 2: " + transform.GetComponentInChildren <MeshFilter>().mesh.vertices.Length);
                        Destroy(transform.gameObject);
                    }
                }
            }

            if (GUILayout.Button("Cyclops Engine RPM SFX Manager"))
            {
                Ray ray4 = Camera.main.ScreenPointToRay(Input.mousePosition);
                if (Physics.Raycast(ray4, out RaycastHit raycastHit4))
                {
                    if (raycastHit4.rigidbody.gameObject.name.ToLower().Contains("cyclops"))
                    {
                        EngineRpmSFXManager engine = raycastHit4.rigidbody.GetComponentInChildren <EngineRpmSFXManager>();
                        if (engine == null)
                        {
                            Utilities.Log.Print("EngineRpmSFXManager not found");
                            return;
                        }

                        Log.Print("engineRpmSFX: " + engine.engineRpmSFX?.asset?.path);
                        Log.Print("stopSoundInterval: " + engine.engineRpmSFX?.stopSoundInterval);
                        Log.Print("engineRevUp: " + engine.engineRevUp?.asset?.path);
                        Log.Print("rampUpSpeed: " + engine.rampUpSpeed);
                        Log.Print("rampDownSpeed: " + engine.rampDownSpeed);
                    }
                }
            }

            if (GUILayout.Button("Cyclops render materials"))
            {
                Ray ray4 = Camera.main.ScreenPointToRay(Input.mousePosition);
                if (Physics.Raycast(ray4, out RaycastHit raycastHit4))
                {
                    if (raycastHit4.rigidbody.gameObject.name.ToLower().Contains("cyclops"))
                    {
                        //Transform gggg1 = raycastHit4.rigidbody.gameObject.transform.Find("CyclopsMeshStatic").transform.Find("undamaged").Find("cyclops_LOD0").Find("cyclops_submarine_exterior");
                        Transform gggg1 = raycastHit4.rigidbody.gameObject.transform.Find("CyclopsMeshStatic").transform.Find("undamaged").Find("cyclops_LOD0").Find("Cyclops_submarine_exterior_glass");
                        //Transform gggg1 = raycastHit4.rigidbody.gameObject.transform.Find("CyclopsMeshStatic").transform.Find("undamaged").Find("cyclops_LOD0").Find("cyclops_submarine_exterior_decals");
                        //Transform gggg1 = raycastHit4.rigidbody.gameObject.transform.Find("CyclopsMeshStatic").transform.Find("undamaged").Find("cyclops_LOD0");

                        /*foreach (MeshRenderer mr in gggg1.gameObject.GetComponentsInChildren<MeshRenderer>())
                         * {
                         *  Utilities.Log.Print("Gameobject: " + mr.gameObject.name);
                         *  foreach (Material mat2 in mr.materials)
                         *  {
                         *      Utilities.Log.Print("Material: " + mat2.name);
                         *      Utilities.Log.Print("keywords: " + mat2.shaderKeywords.Length);
                         *      foreach(var s in mat2.shaderKeywords)
                         *      {
                         *          Utilities.Log.Print("Keyword: " + s);
                         *      }
                         *      Utilities.Log.Print("-");
                         *  }
                         *  Utilities.Log.Print("--");
                         * }*/

                        Log.Print("Materials count: " + gggg1.GetComponent <MeshRenderer>().materials.Length);
                        Material mat = gggg1.GetComponent <MeshRenderer>().material;
                        mat.PrintAllMarmosetUBERShaderProperties();
                    }
                }
            }

            if (GUILayout.Button("Cyclops Oxygen Manager"))
            {
                Ray ray4 = Camera.main.ScreenPointToRay(Input.mousePosition);
                if (Physics.Raycast(ray4, out RaycastHit raycastHit4))
                {
                    if (raycastHit4.rigidbody.gameObject.name.ToLower().Contains("cyclops"))
                    {
                        OxygenManager[] oxygenManager = raycastHit4.rigidbody.GetComponentsInChildren <OxygenManager>();
                        Log.Print("Oxygen Manager Found Count " + oxygenManager.Length);
                    }
                }
            }

            if (GUILayout.Button("Cyclops Depth Cleaer"))
            {
                Ray ray4 = Camera.main.ScreenPointToRay(Input.mousePosition);
                if (Physics.Raycast(ray4, out RaycastHit raycastHit4))
                {
                    if (raycastHit4.rigidbody.gameObject.name.ToLower().Contains("cyclops"))
                    {
                        SubRoot      subRoot = raycastHit4.rigidbody.GetComponent <SubRoot>();
                        MeshRenderer mr      = subRoot.depthClearer as MeshRenderer;
                        Log.Print("DepthClearer type: " + subRoot.depthClearer.GetType());
                        Log.Print("DepthClearer name: " + subRoot.depthClearer.name);
                        Log.Print("DepthClearer material: " + subRoot.depthClearer.material);
                        Log.Print("DepthClearer mesh: " + subRoot.depthClearer.GetComponent <MeshFilter>().mesh);
                        Log.Print("DepthClearer mesh name: " + subRoot.depthClearer.GetComponent <MeshFilter>().mesh.name);
                        Log.Print("DepthClearer Children count: " + subRoot.depthClearer.transform.childCount);
                        Log.Print("DepthClearer transform pos: " + subRoot.depthClearer.transform.localPosition);
                        Log.Print("DepthClearer transform size: " + subRoot.depthClearer.transform.localScale);
                        Log.Print("DepthClearer transform Parent: " + subRoot.depthClearer.transform.parent?.name);
                        subRoot.depthClearer.material.color = new Color(1f, 0f, 0f, 1f);
                        Log.Print("DepthClearer mat color: " + subRoot.depthClearer.material.color);
                        Log.Print("DepthClearer enabled?: " + subRoot.depthClearer.enabled);

                        Log.Print("DepthClearer Component cound: " + subRoot.depthClearer.GetComponents(typeof(Component)).Length);
                        foreach (Component c in subRoot.depthClearer.GetComponents(typeof(Component)))
                        {
                            Utilities.Log.Print("Component: " + c);
                        }
                    }
                }
            }

            if (GUILayout.Button("Cyclops Ladder"))
            {
                Ray ray4 = Camera.main.ScreenPointToRay(Input.mousePosition);
                if (Physics.Raycast(ray4, out RaycastHit raycastHit4))
                {
                    if (raycastHit4.rigidbody.gameObject.name.ToLower().Contains("cyclops"))
                    {
                        Utilities.Log.Print(raycastHit4.rigidbody.gameObject.name);
                        foreach (SkinnedMeshRenderer smr in raycastHit4.rigidbody.gameObject.GetComponentsInChildren <SkinnedMeshRenderer>())
                        {
                            if (smr.gameObject.name.ToLower().Equals("submarine_ladder_04") || smr.gameObject.name.ToLower().Equals("cyclops_ladder_long") ||
                                smr.gameObject.name.ToLower().Equals("cyclops_ladder_short_right") || smr.gameObject.name.ToLower().Equals("cyclops_ladder_short_left") ||
                                smr.gameObject.name.ToLower().Equals("submarine_ladder_02"))
                            {
                                Utilities.Log.Print("Mesh: " + smr.gameObject.GetComponent <SkinnedMeshRenderer>()?.sharedMesh?.name);
                                Utilities.Log.Print("Bones Length: " + smr.gameObject.GetComponent <SkinnedMeshRenderer>()?.bones?.Length);
                                smr.gameObject.GetComponent <SkinnedMeshRenderer>()?.material?.PrintAllMarmosetUBERShaderProperties();
                            }
                        }
                    }
                }
            }

            if (GUILayout.Button("Cyclops Force Damage Point"))
            {
                Ray ray4 = Camera.main.ScreenPointToRay(Input.mousePosition);
                if (Physics.Raycast(ray4, out RaycastHit raycastHit4))
                {
                    if (raycastHit4.rigidbody.gameObject.name.ToLower().Contains("cyclops"))
                    {
                        CyclopsExternalDamageManager damage = raycastHit4.rigidbody.GetComponentInChildren <CyclopsExternalDamageManager>();
                        if (damage == null)
                        {
                            Log.Print("CyclopsExternalDamageManager not found");
                            return;
                        }

                        MethodInfo mi = SMLHelper.V2.Utility.ReflectionHelper.GetInstanceMethod(damage, "CreatePoint");
                        if (mi == null)
                        {
                            Log.Print("CreatePoint method not found");
                            return;
                        }

                        mi.FastInvoke(damage);
                    }
                }
            }

            if (GUILayout.Button("Cyclops Print Damage Info"))
            {
                Ray ray4 = Camera.main.ScreenPointToRay(Input.mousePosition);
                if (Physics.Raycast(ray4, out RaycastHit raycastHit4))
                {
                    if (raycastHit4.rigidbody.gameObject.name.ToLower().Contains("cyclops"))
                    {
                        CyclopsExternalDamageManager damage = raycastHit4.rigidbody.GetComponentInChildren <CyclopsExternalDamageManager>();
                        if (damage == null)
                        {
                            Log.Print("CyclopsExternalDamageManager not found");
                            return;
                        }

                        CyclopsDamagePoint[] damagePoints = raycastHit4.rigidbody.gameObject.GetComponentsInChildren <CyclopsDamagePoint>();
                        foreach (var dp in damagePoints)
                        {
                            dp.gameObject.GetComponentInChildren <LiveMixin>().PrintAllLiveMixinDetails();
                            Log.Print(" ");
                        }
                    }
                }
            }

            if (GUILayout.Button("CyclopsDestructionevent information."))
            {
                Ray ray4 = Camera.main.ScreenPointToRay(Input.mousePosition);
                if (Physics.Raycast(ray4, out RaycastHit raycastHit4))
                {
                    if (raycastHit4.rigidbody.gameObject.name.ToLower().Contains("cyclops"))
                    {
                        CyclopsDestructionEvent dm = raycastHit4.rigidbody.GetComponentInChildren <CyclopsDestructionEvent>();
                        if (dm == null)
                        {
                            Log.Print("Cyclop's CyclopsDestructionEvent not found.");
                            return;
                        }

                        Utilities.Log.Print("explodeSFX: " + dm.fxControl);
                    }
                }
            }

            if (GUILayout.Button("Cyclops PingInstance information."))
            {
                Ray ray4 = Camera.main.ScreenPointToRay(Input.mousePosition);
                if (Physics.Raycast(ray4, out RaycastHit raycastHit4))
                {
                    if (raycastHit4.rigidbody.gameObject.name.ToLower().Contains("cyclops"))
                    {
                        PingInstance pi = raycastHit4.rigidbody.GetComponentInChildren <PingInstance>();
                        if (pi == null)
                        {
                            Log.Print("Cyclop's PingInstance not found.");
                            return;
                        }

                        Log.Print("colorIndex: " + pi.colorIndex);
                        Log.Print("currentVersion: " + pi.currentVersion);
                        Log.Print("displayPingInManager: " + pi.displayPingInManager);
                        Log.Print("maxDist: " + pi.maxDist);
                        Log.Print("minDist: " + pi.minDist);
                        Log.Print("origin: " + pi.origin);
                        Log.Print("pingType: " + pi.pingType);
                        Log.Print("visible: " + pi.visible);
                    }
                }
            }
        }
コード例 #22
0
        private static void SetInGamePingColor(INitroxPlayer player, PingInstance ping)
        {
            uGUI_Pings pings = Object.FindObjectOfType <uGUI_Pings>();

            pings.OnColor(ping.GetInstanceID(), player.PlayerSettings.PlayerColor.ToUnity());
        }
コード例 #23
0
        /**
         * If the component requires other custom components then do it here.
         * Read the comment on Components.MantaSeializationFixer if you wish to understand why this horrible system exists.
         */
        public static void SetUpManta(GameObject submarine)
        {
            MantaSubmarine     mantaSubmarine     = submarine.GetComponent <MantaSubmarine>();
            Transform          applyForceLocation = submarine.FindChild("PointsOfInterest").FindChild("ForceAppliedLocation").transform;
            MovementController movementController = submarine.GetOrAddComponent <MovementController>();

            movementController.ApplyForceLocation = applyForceLocation;

            GameObject doorLeft = submarine.FindChild("PointsOfInterest").FindChild("PlayerEntranceLeftFlap");

            doorLeft.GetComponentInChildren <HingeJoint>().connectedBody = submarine.GetComponent <Rigidbody>();
            HingeJointDoor hingeDoorLeft = doorLeft.GetOrAddComponent <HingeJointDoor>();

            hingeDoorLeft.OverwriteTargetVelocity = true;
            hingeDoorLeft.TargetVelocity          = 150f;
            hingeDoorLeft.TriggerToEverything     = false;
            hingeDoorLeft.TriggerToPlayer         = true;
            hingeDoorLeft.TriggerToVehicles       = false;
            hingeDoorLeft.OpenSound  = CyclopsDefaultAssets.PLAYER_HATCH_OPEN;
            hingeDoorLeft.CloseSound = CyclopsDefaultAssets.PLAYER_HATCH_CLOSE;

            GameObject doorRight = submarine.FindChild("PointsOfInterest").FindChild("PlayerEntranceRightFlap");

            doorRight.GetComponentInChildren <HingeJoint>().connectedBody = submarine.GetComponent <Rigidbody>();
            HingeJointDoor hingeDoorRight = doorRight.GetOrAddComponent <HingeJointDoor>();

            hingeDoorRight.OverwriteTargetVelocity = true;
            hingeDoorRight.TargetVelocity          = 150f;
            hingeDoorRight.TriggerToEverything     = false;
            hingeDoorRight.TriggerToPlayer         = true;
            hingeDoorRight.TriggerToVehicles       = false;
            hingeDoorRight.OpenSound  = CyclopsDefaultAssets.PLAYER_HATCH_OPEN;
            hingeDoorRight.CloseSound = CyclopsDefaultAssets.PLAYER_HATCH_CLOSE;

            GameObject vehicleDoorLeft = submarine.FindChild("PointsOfInterest").FindChild("VehicleEntranceLeftFlap");

            vehicleDoorLeft.GetComponentInChildren <HingeJoint>().connectedBody = submarine.GetComponent <Rigidbody>();
            HingeJointDoor hingeVehicleDoorLeft = vehicleDoorLeft.GetOrAddComponent <HingeJointDoor>();

            hingeVehicleDoorLeft.OverwriteTargetVelocity = true;
            hingeVehicleDoorLeft.TargetVelocity          = 150f;
            hingeVehicleDoorLeft.TriggerToEverything     = false;
            hingeVehicleDoorLeft.TriggerToPlayer         = false;
            hingeVehicleDoorLeft.TriggerToVehicles       = true;
            hingeVehicleDoorLeft.OpenSound  = CyclopsDefaultAssets.DOCKING_DOORS_OPEN;
            hingeVehicleDoorLeft.CloseSound = CyclopsDefaultAssets.DOCKING_DOORS_CLOSE;

            GameObject vehicleDoorRight = submarine.FindChild("PointsOfInterest").FindChild("VehicleEntranceRightFlap");

            vehicleDoorRight.GetComponentInChildren <HingeJoint>().connectedBody = submarine.GetComponent <Rigidbody>();
            HingeJointDoor hingeVehicleDoorRight = vehicleDoorRight.GetOrAddComponent <HingeJointDoor>();

            hingeVehicleDoorRight.OverwriteTargetVelocity = true;
            hingeVehicleDoorRight.TargetVelocity          = 150f;
            hingeVehicleDoorRight.TriggerToEverything     = false;
            hingeVehicleDoorRight.TriggerToPlayer         = false;
            hingeVehicleDoorRight.TriggerToVehicles       = true;
            hingeVehicleDoorRight.OpenSound  = CyclopsDefaultAssets.DOCKING_DOORS_OPEN;
            hingeVehicleDoorRight.CloseSound = CyclopsDefaultAssets.DOCKING_DOORS_CLOSE;

            GameObject    entrancePosition      = submarine.FindChild("PointsOfInterest").FindChild("EntranceTeleportSpot");
            GameObject    entranceHatch         = submarine.FindChild("PointsOfInterest").FindChild("PlayerEntrance").FindChild("Base");
            EntranceHatch entranceHatchTeleport = entranceHatch.GetOrAddComponent <EntranceHatch>();

            entranceHatchTeleport.HoverText         = "Board Manta";
            entranceHatchTeleport.HoverHandReticle  = HandReticle.IconType.Hand;
            entranceHatchTeleport.TeleportTarget    = entrancePosition;
            entranceHatchTeleport.Submarine         = mantaSubmarine;
            entranceHatchTeleport.EnteringSubmarine = true;

            GameObject    leavePosition      = submarine.FindChild("PointsOfInterest").FindChild("LeaveTeleportSpot");
            GameObject    leaveHatch         = submarine.FindChild("PointsOfInterest").FindChild("PlayerEntrance").FindChild("Top");
            EntranceHatch leaveHatchTeleport = leaveHatch.GetOrAddComponent <EntranceHatch>();

            leaveHatchTeleport.HoverText         = "Disembark Manta";
            leaveHatchTeleport.HoverHandReticle  = HandReticle.IconType.Hand;
            leaveHatchTeleport.TeleportTarget    = leavePosition;
            leaveHatchTeleport.Submarine         = mantaSubmarine;
            leaveHatchTeleport.EnteringSubmarine = false;

            GameObject      steeringConsolePOI             = submarine.FindChild("PointsOfInterest").FindChild("SteeringConsole");
            GameObject      steeringConsoleLeftHandTarget  = submarine.FindChild("PointsOfInterest").FindChild("SteeringConsole").FindChild("LeftIKTarget");
            GameObject      steeringConsoleRightHandTarget = submarine.FindChild("PointsOfInterest").FindChild("SteeringConsole").FindChild("RightIKTarget");
            GameObject      playerParentWhilePiloting      = submarine.FindChild("PointsOfInterest").FindChild("SteeringConsole").FindChild("PlayerLockedWhileSteeringPosition");
            SteeringConsole steeringConsole = steeringConsolePOI.GetOrAddComponent <SteeringConsole>();

            steeringConsole.MovementController    = submarine.GetComponent <MovementController>();
            steeringConsole.ParentWhilePilotingGO = playerParentWhilePiloting;
            steeringConsole.LeftHandIKTarget      = steeringConsoleLeftHandTarget;
            steeringConsole.RightHandIKTarget     = steeringConsoleRightHandTarget;
            steeringConsole.Submarine             = mantaSubmarine;

            CyclopsCollisionSounds collisionSounds = submarine.GetOrAddComponent <CyclopsCollisionSounds>();

            MovementData normalSpeedMovementData = new MovementData
            {
                ForwardAccelerationSpeed   = 5f,
                BackwardsAccelerationSpeed = 3f,
                AscendDescendSpeed         = 3f,
                RotationSpeed = 0.3f,
                StrafeSpeed   = 2f
            };

            EngineManager engineManager = submarine.GetOrAddComponent <EngineManager>();

            engineManager.SetMovementDataForEngineState(EngineState.SLOW, normalSpeedMovementData);
            engineManager.SetMovementDataForEngineState(EngineState.NORMAL, normalSpeedMovementData);
            engineManager.SetMovementDataForEngineState(EngineState.FAST, normalSpeedMovementData);
            engineManager.SetMovementDataForEngineState(EngineState.SPECIAL, normalSpeedMovementData);

            CyclopsStartupPowerDownSequence   cyclopsStartupPowerDownSequence   = submarine.GetOrAddComponent <CyclopsStartupPowerDownSequence>();
            CyclopsEngineStateChangedCallouts cyclopsEngineStateChangedCallouts = submarine.GetOrAddComponent <CyclopsEngineStateChangedCallouts>();

            movementController.EngineManager = engineManager;
            CyclopsWelcomeCallout cyclopsWelcomeCallout = submarine.GetOrAddComponent <CyclopsWelcomeCallout>();
            CyclopsEngineSound    cyclopsEngineSound    = submarine.GetOrAddComponent <CyclopsEngineSound>();

            cyclopsEngineSound.RampUpSpeed   = 0.2f;
            cyclopsEngineSound.RampDownSpeed = 0.2f;
            movementController.EngineSound   = cyclopsEngineSound;

            OxygenReplenishment oxygenReplenishment = submarine.GetOrAddComponent <OxygenReplenishment>();

            oxygenReplenishment.OxygenPerSecond  = 15f;
            oxygenReplenishment.OxygenEnergyCost = 0.1f;

            LiveMixin liveMixin = submarine.GetOrAddComponent <LiveMixin>();

            liveMixin.data           = CyclopsLiveMixinData.Get(); // TO:DO Create a proper health system for the manta.
            liveMixin.data.knifeable = true;                       // TO:DO remove just here for testing purposes.
            liveMixin.data.maxHealth = 500;

            GameObject externalLights = submarine.FindChild("Lights").FindChild("Exterior");
            GameObject internalLights = submarine.FindChild("Lights").FindChild("Interior");

            LightsManager lightsManager      = submarine.GetOrAddComponent <LightsManager>();
            List <Light>  internalLightsList = new List <Light>();
            List <Light>  externalLightsList = new List <Light>();

            foreach (Light light in externalLights.GetComponentsInChildren <Light>())
            {
                externalLightsList.Add(light);
            }
            foreach (Light light in internalLights.GetComponentsInChildren <Light>())
            {
                internalLightsList.Add(light);
            }
            lightsManager.ExternalLights              = externalLightsList;
            lightsManager.InternalLights              = internalLightsList;
            lightsManager.ExternalLightsOnIntensity   = 1.5f;
            lightsManager.ExternalLightsOffIntensity  = 0f;
            lightsManager.InternalLightsOnIntensity   = 1.5f;
            lightsManager.InternalLightsOffIntensity  = 0f;
            lightsManager.EnableInternalLightsOnStart = true;
            lightsManager.EnableExternalLightsOnStart = true;

            CyclopsUnderAttackEmergencyLighting emergencyLighting = submarine.GetOrAddComponent <CyclopsUnderAttackEmergencyLighting>();

            emergencyLighting.LightsAffected = internalLightsList;

            submarine.GetOrAddComponent <CyclopsUnderAttackCallout>();

            ExternalDamageManager externalDamageManager = submarine.GetOrAddComponent <ExternalDamageManager>();

            externalDamageManager.DamagePoints       = submarine.FindChild("PointsOfInterest").FindChild("DamagePoints").transform;
            externalDamageManager.SubmarineLiveMixin = liveMixin;
            externalDamageManager.LiveMixinDataForExternalDamagePoints = CyclopsExternalDamagePointLiveMixinData.Get();
            externalDamageManager.DamagePointParticleEffects           = new List <GameObject>()
            {
                CyclopsDefaultAssets.EXTERNAL_DAMAGE_POINT_PARTICLES,
            };
            externalDamageManager.DamagePointGameObjects = new List <GameObject>()
            {
                CyclopsDefaultAssets.EXTERNAL_DAMAGE_POINT,
            };

            InternalFireManager internalFireManager = submarine.GetOrAddComponent <InternalFireManager>();

            internalFireManager.SubmarineLiveMixin = liveMixin;
            internalFireManager.FirePoints         = submarine.FindChild("PointsOfInterest").FindChild("FirePoints").transform;
            internalFireManager.FirePrefabs        = new List <GameObject>()
            {
                CyclopsDefaultAssets.CYCLOPS_FIRE,
            };
            internalFireManager.DamageDonePerFirePerSecond = 5f;
            internalFireManager.Submarine = mantaSubmarine;
            internalFireManager.ChancePerDamageTakenToSpawnFire = 5;

            AutoRegenConditional autoRegen = submarine.GetOrAddComponent <AutoRegenConditional>();

            autoRegen.InternalFireManager   = internalFireManager;
            autoRegen.ExternalDamageManager = externalDamageManager;
            autoRegen.LiveMixin             = liveMixin;
            autoRegen.RegenPerSecond        = 2f;

            InternalLeakManager internalLeakManage = submarine.GetOrAddComponent <InternalLeakManager>();

            internalLeakManage.LeakPrefabs = new List <GameObject>()
            {
                CyclopsDefaultAssets.WATER_LEAK
            };

            DeathManager deathManager = submarine.GetOrAddComponent <DeathManager>();

            deathManager.DeathPreparationTime = 22f;

            BasicDeath basicDeath = submarine.GetOrAddComponent <BasicDeath>();

            basicDeath.TimeTillDeletionOfSub = 60f;
            basicDeath.FallSpeed             = 2f;

            CyclopsDeathExplosion cyclopsDeathExplosion = submarine.GetOrAddComponent <CyclopsDeathExplosion>();

            cyclopsDeathExplosion.TimeToExplosionAfterDeath = 18f;
            cyclopsDeathExplosion.FMODAsset = CyclopsDefaultAssets.CYCLOPS_EXPLOSION_FMOD;

            CyclopsAbandonShip cyclopsAbandonShip = submarine.GetOrAddComponent <CyclopsAbandonShip>();

            cyclopsAbandonShip.TimeToCalloutAfterDeath = 0f;
            cyclopsAbandonShip.FMODAsset = CyclopsDefaultAssets.AI_ABANDON;

            DestabiliseOnSubDeath      destabiliseOnSubDeath      = submarine.GetOrAddComponent <DestabiliseOnSubDeath>();
            KillPlayerInsideOnSubDeath killPlayerInsideOnSubDeath = submarine.GetOrAddComponent <KillPlayerInsideOnSubDeath>();

            // Temp screens
            GameObject helmMantaOSScreen            = submarine.FindChild("PointsOfInterest").FindChild("UpgradesAndBatteries").FindChild("HelmScreen").FindChild("Canvas");
            GameObject rearMantaOSScreen            = submarine.FindChild("PointsOfInterest").FindChild("UpgradesAndBatteries").FindChild("UpgradeScreen").FindChild("Canvas");
            GameObject steeringConsoleMantaOSScreen = submarine.FindChild("PointsOfInterest").FindChild("SteeringConsole").FindChild("Canvas");

            Object.Instantiate(MantaAssetLoader.MANTA_OS_MAIN_LAYOUT_PAGE).transform.SetParent(helmMantaOSScreen.transform, false);
            Object.Instantiate(MantaAssetLoader.MANTAOS_OFFLINE_PAGE).transform.SetParent(rearMantaOSScreen.transform, false);
            Object.Instantiate(MantaAssetLoader.MANTAOS_OFFLINE_PAGE).transform.SetParent(steeringConsoleMantaOSScreen.transform, false);

            SMLHelper.V2.Handlers.TechTypeHandler.TryGetModdedTechType(UNIQUE_ID, out TechType mantaTechType);
            PingType     mantaPingType = CustomBeaconManager.RegisterNewPingType(mantaTechType, NAME, MantaAssetLoader.MANTA_PING_ICON);
            PingInstance pingInstance  = CustomBeaconManager.AddNewBeacon(submarine, mantaPingType, "HMS Unknown Manta");
        }
コード例 #24
0
 public bool?getPingState(PingInstance ping) => ping?getPingState(ping.pingType, ping.colorIndex) : null;
コード例 #25
0
ファイル: MainForm.cs プロジェクト: xmarwin/MwPinger
        private void addPingerToolStripMenuItem_Click(object sender, EventArgs e)
        {
            AddNewPingerForm addNewPingerForm = new AddNewPingerForm()
            {
                PingerName = string.Empty,
                Target = string.Empty,
                Interval = settings.GetDefaultInterval(),
                Timeout = settings.GetDefaultTimeout(),
                BufferSize = settings.GetDefaultBufferSize(),
                Autostart = settings.GetDefaultAutostart()
            };

            DialogResult retVal = addNewPingerForm.ShowForm();

            if (retVal == DialogResult.OK)
            {
                string id = (++maxPingInstanceId).ToString();
                string pingerName = addNewPingerForm.PingerName;
                string target = addNewPingerForm.Target;
                int interval = addNewPingerForm.Interval;
                int timeout = addNewPingerForm.Timeout;
                int bufferSize = addNewPingerForm.BufferSize;
                bool autostart = addNewPingerForm.Autostart;

                PingInstance pi = new PingInstance(pingObject)
                {
                    Target = IPAddress.Parse(target),
                    Interval = interval,
                    Timeout = timeout,
                    BufferSize = bufferSize,
                    Name = pingerName,
                    Id = id,
                    Autostart = autostart
                };

                pi.PingReceived += pi_PingReceived;
                pi.Uc = new ucPingInstance(pi);
                m.PingInstances.Add(pi);

                var loc = m.Locations.FirstOrDefault(x => x.Id.Equals(tvwLocations.SelectedNode.Name));
                if (loc != null)
                {
                    loc.PingInstanceIds.Add(pi.Id);
                    ShowPingInstances(loc.Id);
                }

                if (autostart)
                {
                    m.Start(pi);
                }
            }
        }
コード例 #26
0
ファイル: MainForm.cs プロジェクト: xmarwin/MwPinger
        public MainForm()
        {
            InitializeComponent();

            m = new Main();
            settings = new Settings(m);

            #region Get Targets

            XmlDocument xmlTargets = settings.GetTargets();
            foreach (XmlNode node in xmlTargets.SelectNodes("/PingInstanceList/PingInstance"))
            {
                var target = IPAddress.Parse(node.Attributes["target"].Value);
                int interval = int.Parse(node.Attributes["interval"].Value);
                int timeout = int.Parse(node.Attributes["timeout"].Value);
                int bufferSize = int.Parse(node.Attributes["bufferSize"].Value);
                string name = node.Attributes["name"].Value.ToString();
                string id = node.Attributes["id"].Value;
                bool autostart = node.Attributes["autostart"].Value.Equals("true", StringComparison.InvariantCultureIgnoreCase);

                int intId = 0;
                if (int.TryParse(id, out intId))
                {
                    if (intId > maxPingInstanceId)
                    {
                        maxPingInstanceId = intId;
                    }
                }
                else
                {
                    // TODO
                }

                PingInstance pi = new PingInstance(pingObject)
                {
                    Target = target,
                    Interval = interval,
                    Timeout = timeout,
                    BufferSize = bufferSize,
                    Name = name,
                    Id = id,
                    Autostart = autostart,
                    Status = PingResultStatus.Idle
                };

                pi.PingReceived += pi_PingReceived;
                pi.Uc = new ucPingInstance(pi);
                m.PingInstances.Add(pi);
            }

            #endregion

            #region Get Nodes

            var xmlNodes = settings.GetNodes();

            foreach (XmlNode node in xmlNodes.SelectNodes("/NodeList/Node"))
            {
                string id = node.Attributes["id"].Value;
                string parentId = node.Attributes["parentNodeId"].Value;
                string name = node.Attributes["name"].Value;

                int intId = 0;
                if (int.TryParse(id, out intId))
                {
                    if (intId > maxNodeId)
                    {
                        maxNodeId = intId;
                    }
                }
                else
                {
                    // TODO
                }

                Location l = new Location()
                {
                    Id = id,
                    ParentId = parentId,
                    Name = name
                };

                m.Locations.Add(l);
            }

            #endregion

            #region Get Ping Instance Locations

            var xmlPingInstanceLocations = settings.GetPingInstanceLocations();

            foreach (XmlNode loc in xmlPingInstanceLocations.SelectNodes("/PingInstanceLocations/PingInstanceLocation"))
            {
                string nodeId = loc.Attributes["nodeId"].Value;
                string pingInstanceId = loc.Attributes["pingInstanceId"].Value;

                var node = m.Locations.FirstOrDefault(x => x.Id.Equals(nodeId));
                if (node != null)
                {
                    node.PingInstanceIds.Add(pingInstanceId);
                }
            }

            #endregion

            ShowLocations(tvwLocations);
            ShowPingInstances(string.Empty);

            m.Autostart();
        }
コード例 #27
0
 internal void Initialize(PingInstance ping)
 {
     _ping = ping;
 }
コード例 #28
0
        public override GameObject GetGameObject()
        {
            if (sharkPrefabCache)
            {
                return(sharkPrefabCache);
            }

            Console.WriteLine("Beginning shark load");

            Exosuit    exo        = CraftData.GetPrefabForTechType(TechType.Exosuit).GetComponent <Exosuit>();
            SeaMoth    sea        = CraftData.GetPrefabForTechType(TechType.Seamoth).GetComponent <SeaMoth>();
            GameObject ionCrystal = CraftData.GetPrefabForTechType(TechType.PrecursorIonCrystal);

            GameObject shark = MainPatch.bundle.LoadAsset <GameObject>("SharkPrefab.prefab");

            List <string> exclusions = new List <string>
            {
                "Window",
                "Sonar",
                "EnergyBlade",
                "VolumeLight",
                "Shield"
            };

            Material newMat  = new Material(ionCrystal.GetComponentInChildren <MeshRenderer>().material);
            Vector4  fakesss = newMat.GetVector("_FakeSSSparams");

            fakesss.y = 0f;
            newMat.SetVector("_FakeSSSparams", fakesss);

            foreach (Renderer rend in shark.GetComponentsInChildren <MeshRenderer>())
            {
                if (exclusions.IndexOf(rend.name) == -1)
                {
                    rend.material.shader = Shader.Find("MarmosetUBER");
                }

                if (rend.name == "EnergyBlade")
                {
                    rend.material          = newMat;
                    rend.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;
                }
            }

            Console.WriteLine("Setting up component");

            Shark sharkComp = shark.EnsureComponent <Shark>();

            sharkComp.playerSits     = true;
            sharkComp.playerPosition = shark.transform.Find("Scaler/SeatPosition").gameObject;
            sharkComp.handLabel      = "Pilot 5H-4RK";
            sharkComp.controlSheme   = Vehicle.ControlSheme.Submersible;
            sharkComp.mainAnimator   = shark.EnsureComponent <Animator>();
            sharkComp.mainAnimator.runtimeAnimatorController = sea.mainAnimator.runtimeAnimatorController;
            sharkComp.oxygenEnergyCost = 0f;

            sharkComp.bladeControl = shark.EnsureComponent <SharkBladeControl>();

            while (shark.GetComponent <FMOD_CustomLoopingEmitter>())
            {
                GameObject.Destroy(shark.GetComponent <FMOD_CustomLoopingEmitter>());
            }

            sharkComp.chargeUp = shark.AddComponent <FMOD_CustomLoopingEmitter>();
            sharkComp.chargeUp.followParent = true;
            sharkComp.chargeUp.asset        = sea.pulseChargeSound.asset;
            sharkComp.boost = shark.AddComponent <FMOD_CustomLoopingEmitter>();
            sharkComp.boost.followParent      = true;
            sharkComp.boost.asset             = exo.loopingJetSound.asset;
            sharkComp.boost.assetStop         = exo.loopingJetSound.assetStop;
            sharkComp.normalMove              = shark.AddComponent <FMOD_CustomLoopingEmitter>();
            sharkComp.normalMove.followParent = true;
            sharkComp.normalMove.asset        = sea.engineSound.engineRpmSFX.asset;
            sharkComp.chargeFinished          = sea.seamothElectricalDefensePrefab.GetComponent <ElectricalDefense>().defenseSound;
            sharkComp.splash = sea.splashSound;

            sharkComp.welcomeNotification             = shark.EnsureComponent <VoiceNotification>();
            sharkComp.welcomeNotification.text        = "5H-4RK: Welcome aboard, Captain";
            sharkComp.welcomeNotification.minInterval = exo.welcomeNotification.minInterval;
            sharkComp.welcomeNotification.sound       = exo.welcomeNotification.sound;

            sharkComp.rightHandPlug = sharkComp.transform.Find("Scaler/HandTargets/Right");
            sharkComp.leftHandPlug  = sharkComp.transform.Find("Scaler/HandTargets/Left");
            sharkComp.window        = shark.transform.Find("Scaler/SharkMesh/Sonar").gameObject;

            Console.WriteLine("Adding control");

            SharkControl control = shark.EnsureComponent <SharkControl>();

            control.shark       = sharkComp;
            control.sound       = shark.EnsureComponent <SharkSound>();
            control.sound.shark = sharkComp;

            Console.WriteLine("Adding health");

            LiveMixin     mixin = shark.EnsureComponent <LiveMixin>();
            LiveMixinData data  = ScriptableObject.CreateInstance <LiveMixinData>();

            mixin.health              = 100f;
            data.maxHealth            = 100f;
            data.destroyOnDeath       = false;
            data.weldable             = true;
            data.canResurrect         = false;
            data.invincibleInCreative = true;
            mixin.data          = data;
            sharkComp.liveMixin = mixin;

            Console.WriteLine("Adding forces");

            WorldForces worldForces = shark.EnsureComponent <WorldForces>();

            worldForces.aboveWaterGravity = 9.8f;
            worldForces.underwaterDrag    = 1f;
            worldForces.underwaterGravity = 0f;
            worldForces.aboveWaterDrag    = 0.5f;
            worldForces.useRigidbody      = shark.GetComponent <Rigidbody>();

            sharkComp.worldForces = worldForces;

            Console.WriteLine("Setting up other components");

            shark.EnsureComponent <LargeWorldEntity>().cellLevel = LargeWorldEntity.CellLevel.Global;
            shark.EnsureComponent <SkyApplier>().renderers       = shark.GetComponentsInChildren <Renderer>();
            shark.EnsureComponent <TechTag>().type             = TechType;
            shark.EnsureComponent <PrefabIdentifier>().ClassId = ClassID;
            var vfx        = shark.EnsureComponent <VFXConstructing>();
            var seamothvfx = sea.GetComponentInChildren <VFXConstructing>();

            vfx.blurOffset         = seamothvfx.blurOffset;
            vfx.lineWidth          = seamothvfx.lineWidth;
            vfx.alphaDetailTexture = seamothvfx.alphaDetailTexture;
            vfx.alphaEnd           = seamothvfx.alphaEnd;
            vfx.alphaScale         = seamothvfx.alphaScale;
            vfx.alphaTexture       = seamothvfx.alphaTexture;
            vfx.constructSound     = seamothvfx.constructSound;
            vfx.surfaceSplashSound = seamothvfx.surfaceSplashSound;
            vfx.delay                 = seamothvfx.delay;
            vfx.surfaceSplashFX       = seamothvfx.surfaceSplashFX;
            vfx.surfaceSplashVelocity = seamothvfx.surfaceSplashVelocity;

            var fx = sharkComp.fxControl = shark.EnsureComponent <SharkFXControl>();

            fx.shark   = sharkComp;
            fx.zoomFX  = shark.transform.Find("Scaler/FX/Boost").GetComponent <ParticleSystem>();
            fx.drillFX = shark.transform.Find("Scaler/FX/DrillParticleParent/DrillParticle").GetComponent <ParticleSystem>();
            fx.blinkFX = shark.transform.Find("Scaler/FX/BlinkParticles").GetComponent <ParticleSystem>();

            /*
             * VFXVolumetricLight lightfx = shark.EnsureComponent<VFXVolumetricLight>();
             * lightfx.volumGO = shark.transform.Find("Scaler/SharkMesh/VolumeLight").gameObject;
             * var seamothlight = sea.volumeticLights[0];
             * lightfx.coneMat = new Material(seamothlight.coneMat);
             * lightfx.sphereMat = new Material(seamothlight.sphereMat);
             * lightfx.volumGO.GetComponent<MeshRenderer>().material = lightfx.coneMat;
             * lightfx.intensity = seamothlight.intensity;
             * lightfx.startFallof = seamothlight.startFallof;
             * lightfx.startOffset = seamothlight.startOffset;
             * lightfx.softEdges = seamothlight.softEdges;
             * lightfx.nearClip = seamothlight.nearClip;
             * lightfx.lightSource = shark.transform.Find("Scaler/Headlights/Spot Light").GetComponent<Light>();
             */

            for (int i = 0; i < shark.transform.childCount; i++)
            {
                if (shark.transform.GetChild(i).name.Contains("buildbotpath"))
                {
                    GameObject.Destroy(shark.transform.GetChild(i).gameObject);
                }
            }

            foreach (BuildBotPath path in sea.GetComponentsInChildren <BuildBotPath>())
            {
                Transform newPathParent = new GameObject("buildbotpath").transform;
                newPathParent.parent           = shark.transform;
                newPathParent.localPosition    = Vector3.zero;
                newPathParent.localEulerAngles = Vector3.zero;
                BuildBotPath newPath = newPathParent.gameObject.AddComponent <BuildBotPath>();

                newPath.points = new Transform[path.points.Length];

                int num = 0;
                foreach (Transform trans in path.points)
                {
                    GameObject clone = new GameObject("pathnode" + num);
                    clone.transform.parent        = newPathParent;
                    clone.transform.localPosition = trans.localPosition;
                    clone.transform.localRotation = trans.localRotation;
                    newPath.points[num]           = clone.transform;
                    num++;
                }
            }

            Console.WriteLine("Setting up headlights");

            Transform headLightParent = shark.transform.Find("Scaler/Headlights");

            ToggleLights lights = shark.EnsureComponent <ToggleLights>();

            lights.lightsParent    = headLightParent.gameObject;
            lights.onSound         = sea.toggleLights.lightsOnSound.asset;
            lights.offSound        = sea.toggleLights.lightsOffSound.asset;
            lights.energyPerSecond = 0f;
            sharkComp.lights       = lights;

            Console.WriteLine("Adding smooth cam");

            SharkCameraSmooth camControl = shark.EnsureComponent <SharkCameraSmooth>();

            camControl.shark = sharkComp;
            control.cam      = camControl;

            Console.WriteLine("Adding battery power");

            Transform energyParent = shark.transform.Find("Scaler/BatteryPower").transform;



            sharkComp.energyInterface = shark.EnsureComponent <EnergyInterface>();

            EnergyMixin energy = energyParent.gameObject.EnsureComponent <EnergyMixin>();

            lights.energyMixin             = energy;
            energy.allowBatteryReplacement = true;
            energy.compatibleBatteries     = new List <TechType>
            {
                Shark.internalBattery
            };
            energy.defaultBattery = Shark.internalBattery;

            EnergyMixin.BatteryModels model = new EnergyMixin.BatteryModels();
            model.model = energyParent.Find("PowerCube").gameObject;
            model.model.GetComponent <MeshFilter>().mesh = MainPatch.bundle.LoadAsset <GameObject>("ioncube.obj").GetComponentInChildren <MeshFilter>().mesh;
            MeshRenderer meshRend = model.model.GetComponent <MeshRenderer>();

            meshRend.material = new Material(ionCrystal.GetComponentInChildren <MeshRenderer>().material);
            model.model.transform.localScale = ionCrystal.GetComponentInChildren <MeshFilter>().transform.lossyScale;
            model.techType       = Shark.internalBattery;
            energy.batteryModels = new EnergyMixin.BatteryModels[]
            {
                model,
            };

            energy.controlledObjects = new GameObject[] { };
            energy.storageRoot       = energyParent.gameObject.EnsureComponent <ChildObjectIdentifier>();

            sharkComp.energyInterface.sources = new EnergyMixin[]
            {
                energy
            };

            var energySlot = energyParent.Find("InteractionHandler").gameObject.EnsureComponent <SharkEnergySlot>();

            energySlot.shark = sharkComp;

            Console.WriteLine("Setting up upgrade modules");

            sharkComp.modulesRoot = shark.transform.Find("Scaler/UpgradeModules").gameObject.EnsureComponent <ChildObjectIdentifier>();

            sharkComp.weapons = shark.EnsureComponent <SharkGunControl>();
            sharkComp.weapons.weaponFXParent   = shark.transform.Find("Scaler/Weapons").gameObject;
            sharkComp.weapons.weaponModel      = shark.transform.Find("Scaler/SharkMesh/Lasers").gameObject;
            sharkComp.weapons.upgradeInstalled = false;

            sharkComp.blink                 = shark.EnsureComponent <SharkBlinkControl>();
            sharkComp.blink.blinkSound      = CraftData.GetPrefabForTechType(TechType.PropulsionCannon).GetComponent <PropulsionCannon>().shootSound;
            sharkComp.shield                = shark.EnsureComponent <SharkShieldControl>();
            sharkComp.shield.shieldRenderer = shark.transform.Find("Scaler/SharkMesh/Shield").gameObject;

            sharkComp.drill = shark.EnsureComponent <SharkDrillControl>();
            sharkComp.drill.upgradeModels = shark.transform.Find("Scaler/SharkMesh/DrillMeshes").gameObject;

            StorageContainer drillStorage = sharkComp.drill.storageContainer = shark.transform.Find("Scaler/StorageContainerParent").gameObject.EnsureComponent <StorageContainer>();

            drillStorage.storageRoot  = sharkComp.drill.storageContainer.gameObject.EnsureComponent <ChildObjectIdentifier>();
            drillStorage.width        = 4;
            drillStorage.height       = 5;
            drillStorage.storageLabel = "Drill Storage";
            drillStorage.hoverText    = "OpenStorage";
            drillStorage.container    = null;
            drillStorage.CreateContainer();

            var upgradeconsole = sharkComp.modulesRoot.gameObject.EnsureComponent <VehicleUpgradeConsoleInput>();

            sharkComp.upgradesInput = upgradeconsole;
            upgradeconsole.slots    = new VehicleUpgradeConsoleInput.Slot[4];

            Transform modules = sharkComp.modulesRoot.transform;

            upgradeconsole.flap      = modules.Find("Flap");
            upgradeconsole.collider  = modules.GetComponent <Collider>();
            upgradeconsole.timeClose = 0f;
            upgradeconsole.timeOpen  = 0f;

            int j = 0;

            foreach (string slot in sharkComp.slotIDs)
            {
                if (!Equipment.slotMapping.ContainsKey(slot))
                {
                    Equipment.slotMapping.Add(slot, (EquipmentType)MainPatch.sharkTech);
                }

                GameObject nextSlot = shark.transform.Find("Scaler/SharkMesh/Upgrades/Slot" + (j + 1)).gameObject;

                upgradeconsole.slots[j] = new VehicleUpgradeConsoleInput.Slot()
                {
                    id    = slot,
                    model = nextSlot
                };
                j++;
            }

            Console.WriteLine("Adding GUI");

            shark.EnsureComponent <SharkTestGUI>().shark = sharkComp;

            sharkComp.crushDamage                 = shark.EnsureComponent <CrushDamage>();
            sharkComp.crushDamage.crushDepth      = 500f;
            sharkComp.crushDamage.kBaseCrushDepth = 500f;
            sharkComp.crushDamage.liveMixin       = sharkComp.liveMixin;

            shark.EnsureComponent <SharkUIControl>().shark = sharkComp;

            sharkComp.impactdmg = shark.EnsureComponent <DealDamageOnImpact>();
            sharkComp.impactdmg.damageTerrain      = true;
            sharkComp.impactdmg.mirroredSelfDamage = true;

            Console.WriteLine("Beacon");

            PingType pingType = (PingType)MainPatch.sharkTech;

            GameObject   pingObj = Object.Instantiate(Resources.Load <GameObject>("VFX/xSignal"), shark.transform.position, Quaternion.identity);
            PingInstance ping    = pingObj.GetComponent <PingInstance>();

            ping.SetLabel("5H-4RK");
            ping.displayPingInManager = true;
            ping.pingType             = pingType;
            ping._label = "5H-4RK";
            ping.SetVisible(true);
            pingObj.transform.parent           = shark.transform;
            pingObj.transform.localPosition    = Vector3.zero;
            pingObj.transform.localEulerAngles = Vector3.zero;

            Console.WriteLine("Patching into cached pingtypestrings");

            if (!PingManager.sCachedPingTypeStrings.valueToString.ContainsKey(pingType))
            {
                PingManager.sCachedPingTypeStrings.valueToString.Add(pingType, "SharkPing");
            }

            sharkPrefabCache = shark;

            return(shark);
        }
コード例 #29
0
 public void OnInitialize(int id, PingType type, int colorIndex)
 {
     ping = PingManager.Get(id);
     Initialize();
 }