コード例 #1
0
        private IEnumerator GetItemsContainer(string slotName)
        {
            SNLogger.Log($"[SeamothArms] GetItemsContainer coroutine started for this Seamoth: {ThisSeamoth.GetInstanceID()}");

            while (container == null)
            {
                container = ThisSeamoth.GetStorageInSlot(ThisSeamoth.GetSlotIndex(slotName), SeamothTorpedoArmPrefab.TechTypeID);

                SNLogger.Log($"[SeamothArms] ItemsContainer is not ready for this Seamoth: {ThisSeamoth.GetInstanceID()}");
                yield return(null);
            }

            SNLogger.Log($"[SeamothArms] ItemsContainer is ready for this Seamoth: {ThisSeamoth.GetInstanceID()}");
            SNLogger.Log($"[SeamothArms] GetItemsContainer coroutine stopped for this Seamoth: {ThisSeamoth.GetInstanceID()}");

            if (container != null)
            {
                container.SetAllowedTechTypes(GetTorpedoTypes());
                container.onAddItem    += OnAddItem;
                container.onRemoveItem += OnRemoveItem;
                UpdateVisuals();
            }

            yield break;
        }
コード例 #2
0
        public void OnPickup()
        {
            SeamothArmManager control      = ThisSeamoth.GetComponent <SeamothArmManager>();
            GameObject        activeTarget = control.GetActiveTarget();

            if (activeTarget)
            {
                Pickupable pickupable = activeTarget.GetComponent <Pickupable>();
                PickPrefab component  = activeTarget.GetComponent <PickPrefab>();

                ItemsContainer container = control.GetRoomForItem(pickupable);

                if (pickupable != null && pickupable.isPickupable && container != null)
                {
                    pickupable = pickupable.Initialize();
                    InventoryItem item = new InventoryItem(pickupable);
                    container.UnsafeAdd(item);
                    Utils.PlayFMODAsset(pickupSound, front, 5f);
                }
                else if (component != null && component.AddToContainer(container))
                {
                    component.SetPickedUp();
                }
            }
        }
コード例 #3
0
        void ISeamothArmControl.SetRotation(SeamothArm arm, bool isDocked)
        {
            if (ThisSeamoth == null)
            {
                return;
            }

            if (isDocked)
            {
                SubRoot subRoot = ThisSeamoth.GetComponentInParent <SubRoot>();

                if (subRoot.isCyclops)
                {
                    if (arm == SeamothArm.Right)
                    {
                        transform.localRotation = Quaternion.Euler(32, 336, 310);
                    }
                    else
                    {
                        transform.localRotation = Quaternion.Euler(32, 24, 50);
                    }
                }
                else
                {
                    transform.localRotation = Quaternion.Euler(346, 0, 0);
                }
            }
            else
            {
                transform.localRotation = Quaternion.Euler(346, 0, 0);
            }
        }
コード例 #4
0
        private bool TryUse(out float cooldownDuration)
        {
            if (Time.time - timeUsed >= cooldownTime)
            {
                SeamothArmManager control = ThisSeamoth.GetComponent <SeamothArmManager>();

                Pickupable pickupable = null;
                PickPrefab x          = null;

                GameObject activeTarget = control.GetActiveTarget();

                if (activeTarget)
                {
                    pickupable = activeTarget.GetComponent <Pickupable>();
                    x          = activeTarget.GetComponent <PickPrefab>();
                }
                if (pickupable != null && pickupable.isPickupable)
                {
                    if (control.GetRoomForItem(pickupable) != null)
                    {
                        animator.SetTrigger("use_tool");
                        cooldownTime            = (cooldownDuration = cooldownPickup);
                        shownNoRoomNotification = false;
                        return(true);
                    }
                    if (!shownNoRoomNotification)
                    {
                        ErrorMessage.AddMessage(Language.main.Get("ContainerCantFit"));
                        shownNoRoomNotification = true;
                    }
                }
                else
                {
                    if (x != null)
                    {
                        animator.SetTrigger("use_tool");
                        cooldownTime = (cooldownDuration = cooldownPickup);
                        return(true);
                    }
                    animator.SetTrigger("bash");
                    cooldownTime = (cooldownDuration = cooldownPunch);
                    fxControl.Play(0);
                    return(true);
                }
            }
            cooldownDuration = 0f;
            return(false);
        }
コード例 #5
0
        void ISeamothArmControl.SetRotation(SeamothArm arm, bool isDocked)
        {
            if (ThisSeamoth == null)
            {
                return;
            }

            if (isDocked)
            {
                SubRoot subRoot = ThisSeamoth.GetComponentInParent <SubRoot>();

                if (subRoot.isCyclops)
                {
                    if (arm == SeamothArm.Right)
                    {
                        transform.localRotation = Quaternion.Euler(37, 327, 300);
                    }
                    else
                    {
                        transform.localRotation = Quaternion.Euler(37, 33, 60);
                    }
                }
                else
                {
                    if (arm == SeamothArm.Right)
                    {
                        transform.localRotation = Quaternion.Euler(20, 352, 20);
                    }
                    else
                    {
                        transform.localRotation = Quaternion.Euler(20, 8, 340);
                    }
                }
            }
            else
            {
                if (arm == SeamothArm.Right)
                {
                    transform.localRotation = Quaternion.Euler(355, 343, 19);
                }
                else
                {
                    transform.localRotation = Quaternion.Euler(355, 17, 341);
                }
            }
        }
コード例 #6
0
        public void OnHit()
        {
            if (ThisSeamoth.CanPilot() && ThisSeamoth.GetPilotingMode())
            {
                Vector3    position     = default(Vector3);
                GameObject targetObject = null;

                UWE.Utils.TraceFPSTargetPosition(ThisSeamoth.gameObject, 6.5f, ref targetObject, ref position, true);

                if (targetObject == null)
                {
                    InteractionVolumeUser component = Player.main.gameObject.GetComponent <InteractionVolumeUser>();
                    if (component != null && component.GetMostRecent() != null)
                    {
                        targetObject = component.GetMostRecent().gameObject;
                    }
                }
                if (targetObject)
                {
                    LiveMixin liveMixin = targetObject.FindAncestor <LiveMixin>();
                    if (liveMixin)
                    {
                        bool flag = liveMixin.IsAlive();
                        liveMixin.TakeDamage(50f, position, DamageType.Normal, null);
                        Utils.PlayFMODAsset(hitFishSound, front, 50f);
                    }
                    else
                    {
                        Utils.PlayFMODAsset(hitTerrainSound, front, 50f);
                    }
                    VFXSurface component2 = targetObject.GetComponent <VFXSurface>();
                    Vector3    euler      = MainCameraControl.main.transform.eulerAngles + new Vector3(300f, 90f, 0f);
                    VFXSurfaceTypeManager.main.Play(component2, vfxEventType, position, Quaternion.Euler(euler), ThisSeamoth.gameObject.transform);
                    targetObject.SendMessage("BashHit", this, SendMessageOptions.DontRequireReceiver);
                }
            }
        }
コード例 #7
0
        public void FixedUpdate()
        {
            if (hook.attached)
            {
                grapplingLoopSound.Play();

                Vector3 value     = hook.transform.position - front.position;
                Vector3 a         = Vector3.Normalize(value);
                float   magnitude = value.magnitude;

                if (magnitude > 1f)
                {
                    if (!IsUnderwater() && ThisSeamoth.transform.position.y + 0.2f >= grapplingStartPos.y)
                    {
                        a.y = Mathf.Min(a.y, 0f);
                    }

                    ThisSeamoth.GetComponent <Rigidbody>().AddForce(a * seamothGrapplingAccel, ForceMode.Acceleration);
                    hook.GetComponent <Rigidbody>().AddForce(-a * 400f, ForceMode.Force);
                }

                rope.SetIsHooked();
            }
            else if (hook.flying)
            {
                if ((hook.transform.position - front.position).magnitude > maxDistance)
                {
                    ResetHook();
                }
                grapplingLoopSound.Play();
            }
            else
            {
                grapplingLoopSound.Stop();
            }
        }
コード例 #8
0
 private void Start()
 {
     worldForces = ThisSeamoth.GetComponent <WorldForces>();
 }