예제 #1
0
    public void CalcAndApplyExplosionDamage(string thanksTo)
    {
        Vector2 explosionPos = objectBehaviour.AssumedWorldPosition().To2Int();

        //trigger a hotspot caused by grenade explosion
        registerItem.Matrix.ReactionManager.ExposeHotspotWorldPosition(explosionPos.To2Int(), 3200, 0.005f);

        //apply damage to each damaged thing
        foreach (var damagedObject in damagedObjects)
        {
            int calculatedDamage = CalculateDamage(damagedObject.gameObject.TileWorldPosition(), explosionPos.To2Int());
            if (calculatedDamage <= 0)
            {
                continue;
            }
            damagedObject.ApplyDamage(calculatedDamage, AttackType.Bomb, DamageType.Burn);
        }
        foreach (var damagedLiving in damagedLivingThings)
        {
            int calculatedDamage = CalculateDamage(damagedLiving.gameObject.TileWorldPosition(), explosionPos.To2Int());
            if (calculatedDamage <= 0)
            {
                continue;
            }
            damagedLiving.ApplyDamage(gameObject, calculatedDamage, AttackType.Bomb, DamageType.Burn);
        }
    }
예제 #2
0
    private void MonitorSystem()
    {
        if (!livingHealthBehaviour.IsDead)
        {
            Vector3Int   position = objectBehaviour.AssumedWorldPosition().RoundToInt();
            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;
            }
        }
    }
예제 #3
0
    // Handles rendering logic, only runs when this sprite is on camera
    private void OnWillRenderObject()
    {
        //don't run check until player is created
        if (PlayerManager.LocalPlayer == null)
        {
            return;
        }
        //Allows getting parent's assumed position if inside object
        ObjectBehaviour objectBehaviour = PlayerManager.LocalPlayerScript.pushPull;


        //recalculate if it is facing the player
        //objectBehavior will be null if player is a ghost
        bool visible = objectBehaviour != null?
                       wallmountBehavior.IsFacingPosition(objectBehaviour.AssumedWorldPosition()) :
                           wallmountBehavior.IsFacingPosition(PlayerManager.LocalPlayer.transform.position);

        spriteRenderer.color = new Color(spriteRenderer.color.r, spriteRenderer.color.g, spriteRenderer.color.b, visible ? 1 : 0);
    }
예제 #4
0
    /// <summary>
    /// World position of highest object this object is contained in
    /// </summary>
    /// <returns></returns>
    public Vector3 AssumedWorldPosition()
    {
        //If this object is contained in another, run until highest layer layer is reached
        if (parentContainer != null)
        {
            lastNonHiddenPosition = parentContainer.AssumedWorldPosition();
        }
        //Last condition checks if the player wasn't closed in a closet.
        //While in a closet the player gets teleported out of the map, which causes the lastNonHiddenPosition to be assumed incorrectly.
        else if (registerTile.WorldPosition != TransformState.HiddenPos && lastReliablePos != TransformState.HiddenPos)
        {
            lastNonHiddenPosition = registerTile.WorldPosition;
        }
        else if (lastNonHiddenPosition == TransformState.HiddenPos)
        { //If not initialized yet
            lastNonHiddenPosition = transform.position;
        }

        return(lastNonHiddenPosition);
    }