private void MonitorSystem()
    {
        if (livingHealthBehaviour.IsDead)
        {
            return;
        }

        Vector3Int   position = objectBehaviour.AssumedWorldPositionServer();
        MetaDataNode node     = MatrixManager.GetMetaDataAt(position);

        if (!IsEVACompatible())
        {
            temperature = node.GasMix.Temperature;
            pressure    = node.GasMix.Pressure;
            CheckPressureDamage();
        }
        else
        {
            pressure    = 101.325f;
            temperature = 293.15f;
        }

        if (livingHealthBehaviour.OverallHealth >= HealthThreshold.SoftCrit)
        {
            if (Breathe(node))
            {
                AtmosManager.Update(node);
            }
        }
        else
        {
            bloodSystem.OxygenDamage += 1;
        }
    }
Esempio n. 2
0
        private void MonitorSystem()
        {
            if (!healthMaster.IsDead)
            {
                Vector3Int   position = objectBehaviour.AssumedWorldPositionServer();
                MetaDataNode node     = MatrixManager.GetMetaDataAt(position);

                if (!IsEVACompatible())
                {
                    healthStateController.SetTemperature(node.GasMix.Temperature);
                    healthStateController.SetPressure(node.GasMix.Pressure);
                    CheckPressureDamage();
                }
                else
                {
                    healthStateController.SetPressure(101.325f);
                    healthStateController.SetTemperature(293.15f);
                }

                // if(healthMaster.OverallHealth >= HealthThreshold.SoftCrit)
                // {
                //  if (Breathe(node))
                //  {
                //      AtmosManager.Update(node);
                //  }
                // }
            }
        }
Esempio n. 3
0
        public void Explode()
        {
            if (hasExploded)
            {
                return;
            }
            hasExploded = true;

            if (isServer)
            {
                // Get data from grenade before despawning
                var explosionMatrix = registerItem.Matrix;
                var worldPos        = objectBehaviour.AssumedWorldPositionServer();

                // If the grenade was in a closet before despawning it,
                // it would be useful to remove it from the closet item list to avoid NullReferenceExceptions
                ClosetControl closetControl = null;
                if ((objectBehaviour.parentContainer != null) && (objectBehaviour.parentContainer.TryGetComponent(out closetControl)))
                {
                    closetControl.ServerHeldItems.Remove(objectBehaviour);
                }

                // Despawn grenade
                _ = Despawn.ServerSingle(gameObject);

                // Explosion here
                var explosionGO = Instantiate(explosionPrefab, explosionMatrix.transform);
                explosionGO.transform.position = worldPos;
                explosionGO.Explode(explosionMatrix);
            }
        }
Esempio n. 4
0
        private void MonitorSystem()
        {
            if (healthMaster.IsDead)
            {
                return;
            }

            if (IsEVACompatible())
            {
                healthStateController.SetPressure(AtmosConstants.ONE_ATMOSPHERE);
                healthStateController.SetTemperature(293.15f);
                return;
            }

            GasMix ambientGasMix;

            if (objectBehaviour.parentContainer != null &&
                objectBehaviour.parentContainer.TryGetComponent <GasContainer>(out var gasContainer))
            {
                ambientGasMix = gasContainer.GasMix;
            }
            else
            {
                var        matrix        = healthMaster.RegisterTile.Matrix;
                Vector3Int localPosition = MatrixManager.WorldToLocalInt(objectBehaviour.AssumedWorldPositionServer(), matrix);
                ambientGasMix = matrix.MetaDataLayer.Get(localPosition).GasMix;
            }

            healthStateController.SetTemperature(ambientGasMix.Temperature);
            healthStateController.SetPressure(ambientGasMix.Pressure);
            CheckPressureDamage();
        }
Esempio n. 5
0
        private void Ignite()
        {
            SparkUtil.TrySpark(gameObject, expose: false);

            var worldPos = objectBehaviour.AssumedWorldPositionServer();

            //Try start fire if possible
            var reactionManager = MatrixManager.AtPoint(worldPos, true).ReactionManager;

            reactionManager.ExposeHotspotWorldPosition(worldPos.To2Int(), 1000, true);
        }
Esempio n. 6
0
        public void ServerPerformInteraction(HandActivate interaction)
        {
            SparkUtil.TrySpark(objectBehaviour, expose: false);

            var worldPos = objectBehaviour.AssumedWorldPositionServer();

            //Try start fire if possible
            var reactionManager = MatrixManager.AtPoint(worldPos, true).ReactionManager;

            reactionManager.ExposeHotspotWorldPosition(worldPos.To2Int(), 1000, true);
        }
Esempio n. 7
0
        public void Explode()
        {
            if (hasExploded)
            {
                return;
            }

            hasExploded = true;

            if (!CustomNetworkManager.IsServer)
            {
                return;
            }

            if (lemonPotencyOverride == 0)
            {
                lemonPotency = grownFood.GetPlantData().Potency;
            }
            else
            {
                lemonPotency = lemonPotencyOverride;
            }

            finalDamage = maxDamage * (lemonPotency / 100f);
            finalRadius = Convert.ToSingle(Math.Ceiling(maxRadius * (lemonPotency / 100f)));

            // Get data from grenade before despawning
            var explosionMatrix = registerItem.Matrix;
            var worldPos        = objectBehaviour.AssumedWorldPositionServer();

            // Despawn grenade
            Despawn.ServerSingle(gameObject);

            // Explosion here
            var explosionGO = Instantiate(explosionPrefab, explosionMatrix.transform);

            explosionGO.transform.position = worldPos;
            explosionGO.SetExplosionData(Mathf.RoundToInt(finalDamage), finalRadius);
            explosionGO.Explode(explosionMatrix);
        }
Esempio n. 8
0
        public void Explode()
        {
            if (hasExploded)
            {
                return;
            }
            hasExploded = true;

            if (isServer)
            {
                // Get data from grenade before despawning
                var explosionMatrix = registerItem.Matrix;
                var worldPos        = objectBehaviour.AssumedWorldPositionServer();

                // Despawn grenade
                _ = Despawn.ServerSingle(gameObject);

                // Explosion here
                var explosionGO = Instantiate(explosionPrefab, explosionMatrix.transform);
                explosionGO.transform.position = worldPos;
                explosionGO.Explode(explosionMatrix);
            }
        }
Esempio n. 9
0
        /// <summary>
        /// Try spark using object's register tile
        /// </summary>
        /// <returns>Null if the spark failed, else the new spark object.</returns>
        public static GameObject TrySpark(ObjectBehaviour sourceObjectBehaviour, float chanceToSpark = 75, bool expose = true)
        {
            if (sourceObjectBehaviour == null)
            {
                return(null);
            }

            //Clamp just in case
            chanceToSpark = Mathf.Clamp(chanceToSpark, 1, 100);

            //E.g will have 25% chance to not spark when chanceToSpark = 75
            if (DMMath.Prob(100 - chanceToSpark))
            {
                return(null);
            }

            var worldPos = sourceObjectBehaviour.AssumedWorldPositionServer();

            var result = Spawn.ServerPrefab(CommonPrefabs.Instance.SparkEffect, worldPos, sourceObjectBehaviour.gameObject.transform.parent);

            if (result.Successful)
            {
                if (expose)
                {
                    //Try start fire if possible
                    var reactionManager = MatrixManager.AtPoint(worldPos, true).ReactionManager;
                    reactionManager.ExposeHotspotWorldPosition(worldPos.To2Int(), 1000);
                }

                SoundManager.PlayNetworkedAtPos(SingletonSOSounds.Instance.Sparks, worldPos, sourceObj: sourceObjectBehaviour.gameObject);

                return(result.GameObject);
            }

            return(null);
        }