Exemplo n.º 1
0
    /// <summary>
    /// Release reagents at provided coordinates, making them react with world
    /// </summary>
    public void ReagentReact(Dictionary <string, float> reagents, Vector3Int worldPosInt, Vector3Int localPosInt)
    {
        if (MatrixManager.IsTotallyImpassable(worldPosInt, true))
        {
            return;
        }

        bool didSplat = false;

        foreach (KeyValuePair <string, float> reagent in reagents)
        {
            if (reagent.Value < 1)
            {
                continue;
            }
            if (reagent.Key == "water")
            {
                matrix.ReactionManager.ExtinguishHotspot(localPosInt);

                foreach (var livingHealthBehaviour in matrix.Get <LivingHealthBehaviour>(localPosInt, true))
                {
                    livingHealthBehaviour.Extinguish();
                }

                Clean(worldPosInt, localPosInt, true);
            }
            else if (reagent.Key == "cleaner")
            {
                Clean(worldPosInt, localPosInt, false);
            }
            else if (reagent.Key == "welding_fuel")
            {
                //temporary: converting spilled fuel to plasma
                Get(localPosInt).GasMix.AddGas(Gas.Plasma, reagent.Value);
            }
            else if (reagent.Key == "lube")
            {             //( ͡° ͜ʖ ͡°)
                if (!Get(localPosInt).IsSlippery)
                {
                    EffectsFactory.WaterSplat(worldPosInt);
                    MakeSlipperyAt(localPosInt, false);
                }
            }
            else
            {             //for all other things leave a chem splat
                if (!didSplat)
                {
                    EffectsFactory.ChemSplat(worldPosInt);
                    didSplat = true;
                }
            }
        }
    }
Exemplo n.º 2
0
    public void Clean(Vector3Int worldPosInt, Vector3Int localPosInt, bool makeSlippery)
    {
        var floorDecals = MatrixManager.GetAt <FloorDecal>(worldPosInt, isServer: true);

        for (var i = 0; i < floorDecals.Count; i++)
        {
            floorDecals[i].TryClean();
        }

        if (!MatrixManager.IsSpaceAt(worldPosInt, true) && makeSlippery)
        {
            // Create a WaterSplat Decal (visible slippery tile)
            EffectsFactory.WaterSplat(worldPosInt);

            // Sets a tile to slippery
            MakeSlipperyAt(localPosInt);
        }
    }
Exemplo n.º 3
0
    public void CleanTile(Vector3 worldPos, bool makeSlippery)
    {
        var worldPosInt = worldPos.CutToInt();
        var matrix      = AtPoint(worldPosInt, true);
        var localPosInt = WorldToLocalInt(worldPosInt, matrix);
        var floorDecals = GetAt <FloorDecal>(worldPosInt, isServer: true);

        for (var i = 0; i < floorDecals.Count; i++)
        {
            floorDecals[i].TryClean();
        }

        if (!IsSpaceAt(worldPosInt, true) && makeSlippery)
        {
            // Create a WaterSplat Decal (visible slippery tile)
            EffectsFactory.WaterSplat(worldPosInt);

            // Sets a tile to slippery
            matrix.MetaDataLayer.MakeSlipperyAt(localPosInt);
        }
    }
Exemplo n.º 4
0
    public void Clean(Vector3Int worldPosInt, Vector3Int localPosInt, bool makeSlippery)
    {
        Get(localPosInt).IsSlippery = false;
        var floorDecals = MatrixManager.GetAt <FloorDecal>(worldPosInt, isServer: true);

        for (var i = 0; i < floorDecals.Count; i++)
        {
            floorDecals[i].TryClean();
        }

        //check for any moppable overlays
        matrix.TileChangeManager.RemoveFloorWallOverlaysOfType(localPosInt, OverlayType.Cleanable);

        if (MatrixManager.IsSpaceAt(worldPosInt, true, matrix.MatrixInfo) == false && makeSlippery)
        {
            // Create a WaterSplat Decal (visible slippery tile)
            EffectsFactory.WaterSplat(worldPosInt);

            // Sets a tile to slippery
            MakeSlipperyAt(localPosInt);
        }
    }
Exemplo n.º 5
0
    /// <summary>
    /// Release reagents at provided coordinates, making them react with world
    /// </summary>
    public void ReagentReact(ReagentMix reagents, Vector3Int worldPosInt, Vector3Int localPosInt)
    {
        if (MatrixManager.IsTotallyImpassable(worldPosInt, true))
        {
            return;
        }

        bool didSplat = false;

        foreach (var reagent in reagents)
        {
            if (reagent.Value < 1)
            {
                continue;
            }

            switch (reagent.Key.name)
            {
            case "Water":
            {
                matrix.ReactionManager.ExtinguishHotspot(localPosInt);

                foreach (var livingHealthBehaviour in matrix.Get <LivingHealthBehaviour>(localPosInt, true))
                {
                    livingHealthBehaviour.Extinguish();
                }

                Clean(worldPosInt, localPosInt, true);
                break;
            }

            case "SpaceCleaner":
                Clean(worldPosInt, localPosInt, false);
                break;

            case "WeldingFuel":
                //temporary: converting spilled fuel to plasma
                Get(localPosInt).GasMix.AddGas(Gas.Plasma, reagent.Value);
                break;

            case "SpaceLube":
            {
                //( ͡° ͜ʖ ͡°)
                if (!Get(localPosInt).IsSlippery)
                {
                    EffectsFactory.WaterSplat(worldPosInt);
                    MakeSlipperyAt(localPosInt, false);
                }

                break;
            }

            default:
            {
                //for all other things leave a chem splat
                if (!didSplat)
                {
                    EffectsFactory.ChemSplat(worldPosInt, reagents.MixColor);
                    didSplat = true;
                }

                break;
            }
            }
        }
    }
Exemplo n.º 6
0
    /// <summary>
    /// Release reagents at provided coordinates, making them react with world
    /// </summary>
    public void ReagentReact(ReagentMix reagents, Vector3Int worldPosInt, Vector3Int localPosInt)
    {
        if (MatrixManager.IsTotallyImpassable(worldPosInt, true))
        {
            return;
        }

        bool didSplat   = false;
        bool paintBlood = false;

        //Find all reagents on this tile (including current reagent)
        var reagentContainer = MatrixManager.GetAt <ReagentContainer>(worldPosInt, true);
        var existingSplats   = MatrixManager.GetAt <FloorDecal>(worldPosInt, true);

        for (var i = 0; i < existingSplats.Count; i++)
        {
            if (existingSplats[i].GetComponent <ReagentContainer>())
            {
                existingSplat = existingSplats[i];
            }
        }

        //Loop though all reagent containers and add the passed in reagents
        foreach (ReagentContainer chem in reagentContainer)
        {
            //If the reagent tile is a pool/puddle/splat
            if (chem.ExamineAmount == ReagentContainer.ExamineAmountMode.UNKNOWN_AMOUNT)
            {
                reagents.Add(chem.CurrentReagentMix);
            }
            //TODO: could allow you to add this to other container types like beakers but would need some balance and perhaps knocking over the beaker
        }

        if (reagents.Total > 0)
        {
            //Force clean the tile
            Clean(worldPosInt, localPosInt, false);

            lock (reagents.reagents)
            {
                foreach (var reagent in reagents.reagents.m_dict)
                {
                    switch (reagent.Key.name)
                    {
                    case "HumanBlood":
                    {
                        paintBlood = true;
                        break;
                    }

                    case "Water":
                    {
                        MakeSlipperyAt(localPosInt);
                        matrix.ReactionManager.ExtinguishHotspot(localPosInt);
                        foreach (var livingHealthBehaviour in matrix.Get <LivingHealthMasterBase>(localPosInt, true))
                        {
                            livingHealthBehaviour.Extinguish();
                        }
                        break;
                    }

                    case "SpaceCleaner":
                        Clean(worldPosInt, localPosInt, false);
                        didSplat = true;
                        break;

                    case "SpaceLube":
                    {
                        // ( ͡° ͜ʖ ͡°)
                        if (Get(localPosInt).IsSlippery == false)
                        {
                            EffectsFactory.WaterSplat(worldPosInt);
                            MakeSlipperyAt(localPosInt, false);
                        }
                        break;
                    }

                    default:
                        break;
                    }
                }
            }

            if (didSplat == false)
            {
                if (paintBlood)
                {
                    PaintBlood(worldPosInt, reagents);
                }
                else
                {
                    Paintsplat(worldPosInt, localPosInt, reagents);
                }
            }
        }
    }