Beispiel #1
0
 public void Start()
 {
     if (CNetwork.IsServer)
     {
         // Debug: Atmosphere starts at half the total volume
         m_AtmosphereQuantity.Set(AtmosphereVolume / 2);
     }
 }
Beispiel #2
0
 public void Start()
 {
     // Set the boarding state if it is still invalid
     if (CNetwork.IsServer && BoardingState == EBoardingState.INVALID)
     {
         m_BoardingState.Set(m_InitialBoardingState);
     }
 }
Beispiel #3
0
    public void TakeControl(ulong _ulPlayerId)
    {
        //Debug.Log(string.Format("Player ({0}) mounted turret", _ulPlayerId));

        m_ulControllerPlayerId.Set(_ulPlayerId);

        if (EventTakenControl != null)
        {
            EventTakenControl();
        }
    }
Beispiel #4
0
    private void OnEventClientAxisControlTurret(CUserInput.EAxis _eAxis, ulong _ulPlayerId, float _fValue)
    {
        if (_ulPlayerId == m_ulControllerPlayerId.Get())
        {
            if (transform.FindChild("MechanicalComponent").GetComponent <CActorHealth>().health > 0)
            {
                switch (_eAxis)
                {
                case CUserInput.EAxis.MouseX:
                {
                    Vector2 vRotation = new Vector2(m_cBarrel.transform.eulerAngles.x, transform.rotation.eulerAngles.y);

                    // Update rotation
                    vRotation.y += _fValue;

                    // Apply rotations to turret
                    transform.localEulerAngles           = new Vector3(0.0f, vRotation.y, 0.0f);
                    m_cBarrel.transform.localEulerAngles = new Vector3(vRotation.x, 0.0f, 0.0f);

                    // Server updates the rotation for other clients
                    m_tRotation.Set(new Vector2(vRotation.x, vRotation.y));
                    break;
                }

                case CUserInput.EAxis.MouseY:
                {
                    Vector2 vRotation = new Vector2(m_cBarrel.transform.eulerAngles.x, transform.rotation.eulerAngles.y);

                    // Update rotation
                    vRotation.x += _fValue;
                    vRotation.x  = Mathf.Clamp(vRotation.x, m_fMinRotationX, m_fMaxRotationX);

                    // Apply rotations to turret
                    transform.localEulerAngles           = new Vector3(0.0f, vRotation.y, 0.0f);
                    m_cBarrel.transform.localEulerAngles = new Vector3(vRotation.x, 0.0f, 0.0f);

                    // Server updates the rotation for other clients
                    m_tRotation.Set(new Vector2(vRotation.x, vRotation.y));
                    break;
                }

                default:
                    Debug.LogError("Unknown input");
                    break;
                }
            }
        }
    }
Beispiel #5
0
    public void ActorEnteredGravityTrigger(GameObject _Facility)
    {
        if (m_FacilitiesInfluencingGravity.Count == 0)
        {
            m_UnderGravityInfluence.Set(true);

            if (EventEnteredGravityZone != null)
            {
                EventEnteredGravityZone();
            }
        }

        if (!m_FacilitiesInfluencingGravity.Contains(_Facility))
        {
            m_FacilitiesInfluencingGravity.Add(_Facility);
        }
    }
    public void SyncTransform()
    {
        if (m_SyncPosition)
        {
            m_Position.Set(transform.position);
        }

        if (m_SyncRotation)
        {
            m_EulerAngles.Set(transform.eulerAngles);
        }
    }
Beispiel #7
0
    public void SwitchToPanel(CDUIPanel _Panel)
    {
        CNetworkView nv = _Panel.GetComponent <CNetworkView>();

        if (nv == null)
        {
            Debug.LogError("CNetworkView was not found in panel");
        }
        else
        {
            m_ActivePanelId.Set(nv.ViewId);
        }
    }
    void OnPlayerEnterCockpit(ulong _ulPlayerId)
    {
        CModuleInterface cSelfModuleInterface = GetComponent <CModuleInterface>();

        List <GameObject> acTurrets = null;

        switch (cSelfModuleInterface.ModuleType)
        {
        case CModuleInterface.EType.LaserCockpit:
            acTurrets = cSelfModuleInterface.ParentFacility.GetComponent <CFacilityInterface>().FindModulesByType(CModuleInterface.EType.LaserTurret);
            break;

        case CModuleInterface.EType.MiningCockpit:
            acTurrets = cSelfModuleInterface.ParentFacility.GetComponent <CFacilityInterface>().FindModulesByType(CModuleInterface.EType.MiningTurret);
            break;

        default:
            Debug.LogError("Unknown module cockpit type");
            break;
        }

        if (acTurrets != null &&
            acTurrets.Count > 0)
        {
            foreach (GameObject cTurretObject in acTurrets)
            {
                if (!cTurretObject.GetComponent <CTurretBehaviour>().IsUnderControl)
                {
                    // Notify turret that it has been mounted by player
                    cTurretObject.GetComponent <CTurretBehaviour>().TakeControl(_ulPlayerId);

                    m_cActiveTurretViewId.Set(cTurretObject.GetComponent <CNetworkView>().ViewId);

                    break;
                }
            }
        }
    }
Beispiel #9
0
    private void OpenDui(GameObject _InteractableObject)
    {
        if (_InteractableObject != null && !IsDUIActive && !m_Transitioning)
        {
            // Only conserned with selecting module ports
            CModulePortInterface mpi = _InteractableObject.GetComponent <CModulePortInterface>();
            if (mpi != null)
            {
                // Register movement events
                CUserInput.SubscribeClientInputChange(CUserInput.EInput.MoveGround_Forward, OnPlayerMovement);
                CUserInput.SubscribeClientInputChange(CUserInput.EInput.MoveGround_Backwards, OnPlayerMovement);
                CUserInput.SubscribeClientInputChange(CUserInput.EInput.MoveGround_StrafeLeft, OnPlayerMovement);
                CUserInput.SubscribeClientInputChange(CUserInput.EInput.MoveGround_StrafeRight, OnPlayerMovement);
                CUserInput.SubscribeClientInputChange(CUserInput.EInput.MoveGround_Jump, OnPlayerMovement);

                // Change the port selected on the UI
                m_DUIModuleCreationRoot.SetSelectedPort(_InteractableObject.GetComponent <CNetworkView>().ViewId);

                // Make the UI active
                m_DUIActive.Set(true);
            }
        }
    }
Beispiel #10
0
    public GameObject CreateModule(CModuleInterface.EType _eType)
    {
        GameObject cModuleObject = null;

        if (!IsModuleAttached)
        {
            cModuleObject = CNetwork.Factory.CreateObject(CModuleInterface.GetPrefabType(_eType));
            cModuleObject.GetComponent <CNetworkView>().SetPosition(m_Positioner.transform.position);
            cModuleObject.GetComponent <CNetworkView>().SetEulerAngles(m_Positioner.transform.rotation.eulerAngles);
            cModuleObject.GetComponent <CNetworkView>().SetParent(GetComponent <CNetworkView>().ViewId);

            m_cAttachedModuleViewId.Set(cModuleObject.GetComponent <CNetworkView>().ViewId);
        }
        return(cModuleObject);
    }
Beispiel #11
0
    void Update()
    {
        if (CNetwork.IsServer)
        {
            timeUntilNextNetworkSync -= Time.deltaTime;
            if (timeUntilNextNetworkSync <= 0.0f && (syncNetworkHealth || syncNetworkState))
            {
                if (syncNetworkHealth && health_current != health_internal.Get())
                {
                    health_internal.Set(health_current);
                }

                if (syncNetworkState && state_current != state_internal.Get())
                {
                    state_internal.Set(state_current);
                }

                timeUntilNextNetworkSync = timeBetweenNetworkSyncs;
            }
        }
    }
Beispiel #12
0
    public void UpdateNetworkVars()
    {
        System.Diagnostics.Debug.Assert(CNetwork.IsServer, "Only the server can update network vars!");

        if (Position)
        {
            Vector3 position = transform.position;
            mPositionX.Set(position.x);
            mPositionY.Set(position.y);
            mPositionZ.Set(position.z);
        }

        if (Angle)
        {
            Vector3 angle = transform.eulerAngles;
            mAngleX.Set(angle.x);
            mAngleY.Set(angle.y);
            mAngleZ.Set(angle.z);
        }

        if (PositionalVelocity)
        {
            Vector3 positionalVelocity = rigidbody.velocity;
            mPositionalVelocityX.Set(positionalVelocity.x);
            mPositionalVelocityY.Set(positionalVelocity.y);
            mPositionalVelocityZ.Set(positionalVelocity.z);
        }

        if (AngularVelocity)
        {
            Vector3 angularVelocity = rigidbody.angularVelocity;
            mAngularVelocityX.Set(angularVelocity.x);
            mAngularVelocityY.Set(angularVelocity.y);
            mAngularVelocityZ.Set(angularVelocity.z);
        }
    }
Beispiel #13
0
    void Update()
    {
        if (CNetwork.IsServer)
        {
            GameObject currentFacility = gameObject.GetComponent <CActorLocator>().LastEnteredFacility;

            // Control visor state
            if (currentFacility == null)
            {
                m_EnviromentalOxygen.Set(false);
            }
            else
            {
                if (currentFacility.GetComponent <CFacilityAtmosphere>().AtmospherePercentage < 25.0f)
                {
                    m_AtmosphereConsumer.SetAtmosphereConsumption(false);
                    m_EnviromentalOxygen.Set(false);
                }
                else
                {
                    // Set the origninal consumption rate
                    m_AtmosphereConsumer.AtmosphericConsumptionRate = m_AtmosphereConsumer.InitialAtmosphericConsumptionRate;

                    m_AtmosphereConsumer.SetAtmosphereConsumption(true);
                    m_EnviromentalOxygen.Set(true);
                }
            }

            if (!m_EnviromentalOxygen.Value)
            {
                // Consume oxygen
                float fOxygen = OxygenSupply - k_fOxygenDepleteRate * Time.deltaTime;

                if (!CHUDRoot.Visor.IsVisorDown)
                {
                    fOxygen = OxygenSupply;
                }

                if (fOxygen < 0.0f)
                {
                    fOxygen = 0.0f;
                }
                else if (fOxygen > k_fOxygenCapacity)
                {
                    fOxygen = k_fOxygenCapacity;
                }

                m_fOxygen.Set(fOxygen);

                if (fOxygen == 0.0f)
                {
                    GetComponent <CPlayerHealth>().ApplyDamage(10.0f * Time.deltaTime);
                }
                else if (!CHUDRoot.Visor.IsVisorDown)
                {
                    GetComponent <CPlayerHealth>().ApplyDamage(500.0f * Time.deltaTime);
                }
            }
            else
            {
                // Refill oxygen
                if (OxygenSupply != k_fOxygenCapacity)
                {
                    // Set the updated consumption rate
                    m_AtmosphereConsumer.AtmosphericConsumptionRate = k_fOxygenRefillRate;

                    // Add to current oxygen to suit
                    m_fOxygen.Set(OxygenSupply + k_fOxygenRefillRate * Time.deltaTime);

                    if (OxygenSupply > k_fOxygenCapacity)
                    {
                        m_fOxygen.Set(k_fOxygenCapacity);
                    }
                }
            }
        }
    }
 public void ActivateNaniteAvailability()
 {
     m_bNanitesAvailable.Set(true);
 }
Beispiel #15
0
 public void SetSelectedPort(CNetworkViewId _PortViewId)
 {
     m_CurrentPortSelected.Set(_PortViewId);
 }
Beispiel #16
0
 public void ActivatePowerGeneration()
 {
     m_PowerGenerationActive.Set(true);
 }
Beispiel #17
0
 public void ActivatePropulsionGeneration()
 {
     m_PropulsionGeneratorActive.Set(true);
 }
Beispiel #18
0
 public void ChangeFacilityType(CFacilityInterface.EType _FacilityType)
 {
     m_CurrentFacilityType.Set(_FacilityType);
 }
Beispiel #19
0
 public void SetSelectedModuleType(CModuleInterface.EType _ModuleType)
 {
     m_CurrentModuleType.Set(_ModuleType);
 }
 void UpdateCurrentGravityOutput(float _fNewCurrentGravityOutput)
 {
     m_fCurrentGravityOutput.Set(_fNewCurrentGravityOutput);
 }
Beispiel #21
0
 protected void SetSliderValue(float _Value)
 {
     m_Value.Set(_Value);
 }
Beispiel #22
0
 public void SetSelectedToolType(CToolInterface.EType _ToolType)
 {
     m_CurrentToolType.Set(_ToolType);
 }
Beispiel #23
0
 public void ActivatePower()
 {
     m_PowerActive.Set(true);
 }
 public void ActivateConditioning()
 {
     m_AtmosphereConditioningActive.Set(true);
 }
 public void ActivateGeneration()
 {
     m_AtmosphereGenerationActive.Set(true);
 }
 void UpdateTriggerRadius(float _fNewTriggerRadius)
 {
     m_fTriggerRadius.Set(_fNewTriggerRadius);
 }
Beispiel #27
0
 public void ActivateBatteryChargeAvailability()
 {
     m_BatteryChargeAvailable.Set(true);
 }