public void Start()
        {
            subroot = gameObject.GetComponentInParent <SubRoot>();

            subcontrol = subroot.GetComponentInParent <SubControl>();

            prev_multiplier = 1;
        }
        public void Start()
        {
            subroot = gameObject.GetComponentInParent <SubRoot>();

            subcontrol = subroot.GetComponentInParent <SubControl>();

            Main.Instance.onCyclopsSpeedValueChanged.AddHandler(this, new Event <object> .HandleFunction(OnCyclopsSpeedValueChanged));
            onCyclopsMotorModeChanged.AddHandler(this, new Event <CyclopsMotorMode.CyclopsMotorModes> .HandleFunction(OnCyclopsMotorModeChanged));
        }
Esempio n. 3
0
        private bool IsSwimming(Vector3 playerPosition, Optional <NitroxId> subId)
        {
            if (subId.HasValue)
            {
                Optional <GameObject> sub = NitroxEntity.GetObjectFrom(subId.Value);
                SubRoot subroot           = null;
                sub.Value.TryGetComponent <SubRoot>(out subroot);
                // Set the animation for the remote player to standing instead of swimming if player is not in a flooded subroot
                // or in a waterpark
                if (subroot)
                {
                    if (subroot.IsUnderwater(playerPosition))
                    {
                        return(true);
                    }
                    if (subroot.isCyclops)
                    {
                        return(false);
                    }
                    // We know that we are in a subroot. But we can also be in a waterpark in a subroot, where we would swim
                    BaseRoot baseRoot = subroot.GetComponentInParent <BaseRoot>();
                    if (baseRoot)
                    {
                        WaterPark[] waterParks = baseRoot.GetComponentsInChildren <WaterPark>();
                        foreach (WaterPark waterPark in waterParks)
                        {
                            if (waterPark.IsPointInside(playerPosition))
                            {
                                return(true);
                            }
                        }
                        return(false);
                    }
                }

                Log.Debug($"Trying to find escape pod for {subId}.");
                EscapePod escapePod = null;
                sub.Value.TryGetComponent <EscapePod>(out escapePod);
                if (escapePod)
                {
                    Log.Debug("Found escape pod for player. Will add him and update animation.");
                    return(false);
                }
            }
            // Player can be above ocean level.
            float oceanLevel = Ocean.main.GetOceanLevel();

            return(playerPosition.y < oceanLevel);
        }