Exemplo n.º 1
0
        public void ExposeHotspot(Vector3Int localPosition)
        {
            if (!hotspots.ContainsKey(localPosition) || hotspots[localPosition].Hotspot == null)
            {
                Profiler.BeginSample("MarkForAddition");
                MetaDataNode node   = metaDataLayer.Get(localPosition);
                GasMix       gasMix = node.GasMix;

                if (PlasmaFireReaction.CanHoldHotspot(gasMix))
                {
                    // igniting
                    //addition will be done later in Update
                    hotspotsToAdd.Add(new Hotspot(node));
                }

                Profiler.EndSample();
            }

            if (hotspots.ContainsKey(localPosition) && hotspots[localPosition].Hotspot != null)
            {
                //expose everything on this tile
                Expose(localPosition, localPosition);

                //expose impassable things on the adjacent tile
                Expose(localPosition, localPosition + Vector3Int.right);
                Expose(localPosition, localPosition + Vector3Int.left);
                Expose(localPosition, localPosition + Vector3Int.up);
                Expose(localPosition, localPosition + Vector3Int.down);
            }
        }
Exemplo n.º 2
0
        public void DoTick()
        {
            if (reactionTick == 0)
            {
                return;
            }

            reactionTick--;

            //process the current hotspots, removing ones that can't sustain anymore.
            //(but we actually perform the add / remove after this loop so we don't concurrently modify the dict)
            foreach (MetaDataNode node in hotspots.Values)
            {
                if (node.Hotspot != null)
                {
                    if (PlasmaFireReaction.CanHoldHotspot(node.GasMix))
                    {
                        node.Hotspot.Process();
                    }
                    else
                    {
                        RemoveHotspot(node);
                    }
                }
            }
        }
Exemplo n.º 3
0
 private bool Check()
 {
     if (Temperature > Reactions.PlasmaMaintainFire && Volume > 0.0001 && node.GasMix.GetMoles(Gas.Plasma) > 0.1f &&
         node.GasMix.GetMoles(Gas.Oxygen) > 0.1f)
     {
         if (PlasmaFireReaction.GetOxygenContact(node.GasMix) > Reactions.MinimumOxygenContact)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     else
     {
         return(false);
     }
 }
        public void DoTick()
        {
            if (reactionTick == 0)
            {
                return;
            }

            reactionTick--;

            //process the current hotspots, removing ones that can't sustain anymore.
            //(but we actually perform the add / remove after this loop so we don't concurrently modify the dict)
            foreach (MetaDataNode node in hotspots.Values)
            {
                if (node.Hotspot != null)
                {
                    if (PlasmaFireReaction.CanHoldHotspot(node.GasMix))
                    {
                        node.Hotspot.Process();
                    }
                    else
                    {
                        RemoveHotspot(node);
                    }
                }
            }

            Profiler.BeginSample("GasReactions");

            int gasReactionCount = addReaction.Count;

            if (gasReactionCount > 0)
            {
                for (int i = gasReactionCount; i >= 0; i--)
                {
                    if (addReaction.TryDequeue(out var addReactionNode))
                    {
                        var gasMix = addReactionNode.metaDataNode.GasMix;

                        addReactionNode.gasReaction.Reaction.React(gasMix, addReactionNode.metaDataNode.Position, addReactionNode.metaDataNode.PositionMatrix);

                        if (reactions.TryGetValue(addReactionNode.metaDataNode.Position, out var gasHashSet) &&
                            gasHashSet.Count == 1)
                        {
                            reactions.TryRemove(addReactionNode.metaDataNode.Position, out var value);
                            continue;
                        }

                        reactions[addReactionNode.metaDataNode.Position].Remove(addReactionNode.gasReaction);
                    }
                }
            }

            Profiler.EndSample();

            #region TileOverlays

            Profiler.BeginSample("FogModifyAdd");
            //Here we check to see if chemical fog fx needs to be applied, and if so, add them. If not, we remove them
            int addFogCount = addFog.Count;
            if (addFogCount > 0)
            {
                for (int i = 0; i < addFogCount; i++)
                {
                    if (addFog.TryDequeue(out var addFogNode))
                    {
                        if (fogTiles.ContainsKey(addFogNode.metaDataNode.Position))
                        {
                            if (fogTiles[addFogNode.metaDataNode.Position].Contains(addFogNode.gas))
                            {
                                continue;
                            }

                            fogTiles[addFogNode.metaDataNode.Position].Add(addFogNode.gas);                             //Add it to fogTiles
                        }
                        else
                        {
                            fogTiles.Add(addFogNode.metaDataNode.Position,
                                         new HashSet <Gas> {
                                addFogNode.gas
                            });                                                                       //Add it to fogTiles
                        }

                        tileChangeManager.UpdateTile(addFogNode.metaDataNode.Position, TileType.Effects, addFogNode.gas.TileName);
                    }
                }
            }

            Profiler.EndSample();
            Profiler.BeginSample("FogModifyRemove");

            //Similar to above, but for removing chemical fog fx
            int removeFogCount = removeFog.Count;
            if (removeFogCount > 0)
            {
                for (int i = 0; i < removeFogCount; i++)
                {
                    if (removeFog.TryDequeue(out var removeFogNode))
                    {
                        if (!fogTiles.ContainsKey(removeFogNode.metaDataNode.Position))
                        {
                            continue;
                        }

                        if (!fogTiles[removeFogNode.metaDataNode.Position].Contains(removeFogNode.gas))
                        {
                            continue;
                        }

                        tileChangeManager.RemoveTile(removeFogNode.metaDataNode.Position, LayerType.Effects, false);

                        if (fogTiles[removeFogNode.metaDataNode.Position].Count == 1)
                        {
                            fogTiles.Remove(removeFogNode.metaDataNode.Position);
                            continue;
                        }

                        fogTiles[removeFogNode.metaDataNode.Position].Remove(removeFogNode.gas);
                    }
                }
            }

            Profiler.EndSample();

            #endregion
        }