FixedPoint2 ITileReaction.TileReact(TileRef tile, ReagentPrototype reagent, FixedPoint2 reactVolume) { var entities = IoCManager.Resolve <IEntityLookup>().GetEntitiesIntersecting(tile).ToArray(); var amount = FixedPoint2.Zero; var entMan = IoCManager.Resolve <IEntityManager>(); foreach (var entity in entities) { if (entMan.TryGetComponent(entity, out CleanableComponent? cleanable)) { var next = amount + (cleanable.CleanAmount * CleanAmountMultiplier); // Nothing left? if (reactVolume < next) { break; } amount = next; entMan.QueueDeleteEntity(entity); } } var decalSystem = EntitySystem.Get <DecalSystem>(); foreach (var uid in decalSystem.GetDecalsInRange(tile.GridIndex, tile.GridIndices + new Vector2(0.5f, 0.5f), validDelegate: x => x.Cleanable)) { decalSystem.RemoveDecal(tile.GridIndex, uid); } return(amount); }
public FixedPoint2 TileReact(TileRef tile, ReagentPrototype reagent, FixedPoint2 reactVolume) { if (reactVolume <= FixedPoint2.Zero || tile.Tile.IsEmpty) { return(FixedPoint2.Zero); } var atmosphereSystem = EntitySystem.Get <AtmosphereSystem>(); var environment = atmosphereSystem.GetTileMixture(tile.GridIndex, tile.GridIndices, true); if (environment == null || !atmosphereSystem.IsHotspotActive(tile.GridIndex, tile.GridIndices)) { return(FixedPoint2.Zero); } environment.Temperature = MathF.Max(MathF.Min(environment.Temperature - (_coolingTemperature * 1000f), environment.Temperature / _coolingTemperature), Atmospherics.TCMB); atmosphereSystem.React(tile.GridIndex, tile.GridIndices); atmosphereSystem.HotspotExtinguish(tile.GridIndex, tile.GridIndices); return(FixedPoint2.Zero); }
private ReagentUnit Reaction(ReagentPrototype reagent, ReagentUnit volume) { if ((volume > ReagentUnit.Zero) && (reagent.ID == _catalystPrototype)) { Expand(); } return(ReagentUnit.Zero); }
public ReagentUnit TileReact(TileRef tile, ReagentPrototype reagent, ReagentUnit reactVolume) { if (reactVolume < 5 || !tile.TryGetPuddle(null, out _)) { return(ReagentUnit.Zero); } return(tile.SpillAt(new Solution(reagent.ID, reactVolume), "PuddleSmear", true, false) != null ? reactVolume : ReagentUnit.Zero); }
ReagentUnit IReagentReaction.ReagentReactInjection(ReagentPrototype reagent, ReagentUnit volume) { if (_solutionContainer == null) { return(ReagentUnit.Zero); } _solutionContainer.TryAddReagent(reagent.ID, volume, out var accepted); return(accepted); }
public FixedPoint2 TileReact(TileRef tile, ReagentPrototype reagent, FixedPoint2 reactVolume) { var spillSystem = EntitySystem.Get <SpillableSystem>(); if (reactVolume < 5 || !spillSystem.TryGetPuddle(tile, out _)) { return(FixedPoint2.Zero); } return(spillSystem.SpillAt(tile, new Solution(reagent.ID, reactVolume), "PuddleSmear", true, false, true) != null ? reactVolume : FixedPoint2.Zero); }
public ReagentUnit TileReact(TileRef tile, ReagentPrototype reagent, ReagentUnit reactVolume) { if (reactVolume <= ReagentUnit.Zero || tile.Tile.IsEmpty) { return(ReagentUnit.Zero); } var tileAtmos = tile.GridIndices.GetTileAtmosphere(tile.GridIndex); if (tileAtmos == null || !tileAtmos.Hotspot.Valid) { return(ReagentUnit.Zero); } tileAtmos.Air.Temperature *= MathF.Max(_temperatureMultiplier * reactVolume.Float(), 1f); tileAtmos.Air.React(tileAtmos); return(reactVolume); }
public ReagentUnit TileReact(TileRef tile, ReagentPrototype reagent, ReagentUnit reactVolume) { if (reactVolume <= ReagentUnit.Zero || tile.Tile.IsEmpty) { return(ReagentUnit.Zero); } var tileAtmos = tile.GridPosition().GetTileAtmosphere(); if (tileAtmos?.Air == null || !tileAtmos.Hotspot.Valid) { return(ReagentUnit.Zero); } tileAtmos.Air.Temperature *= MathF.Max(_temperatureMultiplier * reactVolume.Float(), 1f); EntitySystem.Get <AtmosphereSystem>().React(tileAtmos.Air, tileAtmos); return(reactVolume); }
/// <summary> /// Returns the total heat capacity of the reagents in this solution. /// </summary> /// <returns>The total heat capacity of the reagents in this solution.</returns> private float GetHeatCapacity() { var heatCapacity = 0.0f; var prototypeManager = IoCManager.Resolve <IPrototypeManager>(); foreach (var reagent in Contents) { if (!prototypeManager.TryIndex(reagent.ReagentId, out ReagentPrototype? proto)) { proto = new ReagentPrototype(); } heatCapacity += (float)reagent.Quantity * proto.SpecificHeat; } return(heatCapacity); }
public void ReactionEntity(IEntity?entity, ReactionMethod method, ReagentPrototype reagent, ReagentUnit reactVolume, Solution?source) { if (entity == null || entity.Deleted || !entity.TryGetComponent(out ReactiveComponent? reactive)) { return; } foreach (var reaction in reactive.Reactions) { // If we have a source solution, use the reagent quantity we have left. Otherwise, use the reaction volume specified. reaction.React(method, entity, reagent, source?.GetReagentQuantity(reagent.ID) ?? reactVolume, source); // Make sure we still have enough reagent to go... if (source != null && !source.ContainsReagent(reagent.ID)) { break; } } }
public ReagentUnit ReagentReactTouch(ReagentPrototype reagent, ReagentUnit volume) { switch (reagent.ID) { case "chem.H2O": Extinguish(); AdjustFireStacks(-1.5f); return(ReagentUnit.Zero); case "chem.WeldingFuel": case "chem.Thermite": case "chem.Phoron": case "chem.Ethanol": AdjustFireStacks(volume.Float() / 10f); return(volume); default: return(ReagentUnit.Zero); } }
public ReagentUnit TileReact(TileRef tile, ReagentPrototype reagent, ReagentUnit reactVolume) { if (reactVolume <= ReagentUnit.Zero || tile.Tile.IsEmpty) { return(ReagentUnit.Zero); } var tileAtmos = tile.GridPosition().GetTileAtmosphere(); if (tileAtmos == null || !tileAtmos.Hotspot.Valid || tileAtmos.Air == null) { return(ReagentUnit.Zero); } tileAtmos.Air.Temperature = MathF.Max(MathF.Min(tileAtmos.Air.Temperature - (_coolingTemperature * 1000f), tileAtmos.Air.Temperature / _coolingTemperature), Atmospherics.TCMB); tileAtmos.Air.React(tileAtmos); tileAtmos.Hotspot = new Hotspot(); tileAtmos.UpdateVisuals(); return(ReagentUnit.Zero); }
public FixedPoint2 TileReact(TileRef tile, ReagentPrototype reagent, FixedPoint2 reactVolume) { if (reactVolume <= FixedPoint2.Zero || tile.Tile.IsEmpty) { return(FixedPoint2.Zero); } var atmosphereSystem = EntitySystem.Get <AtmosphereSystem>(); var environment = atmosphereSystem.GetTileMixture(tile.GridUid, null, tile.GridIndices, true); if (environment == null || !atmosphereSystem.IsHotspotActive(tile.GridUid, tile.GridIndices)) { return(FixedPoint2.Zero); } environment.Temperature *= MathF.Max(_temperatureMultiplier * reactVolume.Float(), 1f); atmosphereSystem.ReactTile(tile.GridUid, tile.GridIndices); return(reactVolume); }
public void DeserializeReagentPrototype() { using (TextReader stream = new StringReader(YamlReagentPrototype)) { var yamlStream = new YamlStream(); yamlStream.Load(stream); var document = yamlStream.Documents[0]; var rootNode = (YamlSequenceNode)document.RootNode; var proto = (YamlMappingNode)rootNode[0]; var defType = proto.GetNode("type").AsString(); var newReagent = new ReagentPrototype(); newReagent.LoadFrom(proto); Assert.That(defType, Is.EqualTo("reagent")); Assert.That(newReagent.ID, Is.EqualTo("chem.H2")); Assert.That(newReagent.Name, Is.EqualTo("Hydrogen")); Assert.That(newReagent.Description, Is.EqualTo("A light, flammable gas.")); Assert.That(newReagent.SubstanceColor, Is.EqualTo(Color.Teal)); } }
public ReagentUnit TileReact(TileRef tile, ReagentPrototype reagent, ReagentUnit reactVolume) { if (reactVolume < 5) { return(ReagentUnit.Zero); } // TODO Make this not puddle smear. var puddle = tile.SpillAt(new Solution(reagent.ID, reactVolume), "PuddleSmear", _overflow, false); if (puddle != null) { var slippery = puddle.Owner.GetComponent <SlipperyComponent>(); slippery.LaunchForwardsMultiplier = _launchForwardsMultiplier; slippery.RequiredSlipSpeed = _requiredSlipSpeed; slippery.ParalyzeTime = _paralyzeTime; return(reactVolume); } return(ReagentUnit.Zero); }
public FixedPoint2 TileReact(TileRef tile, ReagentPrototype reagent, FixedPoint2 reactVolume) { if (reactVolume < 5) { return(FixedPoint2.Zero); } // TODO Make this not puddle smear. var puddle = EntitySystem.Get <SpillableSystem>() .SpillAt(tile, new Solution(reagent.ID, reactVolume), "PuddleSmear", _overflow, false, true); if (puddle != null) { var slippery = IoCManager.Resolve <IEntityManager>().GetComponent <SlipperyComponent>(puddle.Owner); slippery.LaunchForwardsMultiplier = _launchForwardsMultiplier; slippery.RequiredSlipSpeed = _requiredSlipSpeed; slippery.ParalyzeTime = _paralyzeTime; return(reactVolume); } return(FixedPoint2.Zero); }
ReagentUnit ITileReaction.TileReact(TileRef tile, ReagentPrototype reagent, ReagentUnit reactVolume) { var entities = tile.GetEntitiesInTileFast().ToArray(); var amount = ReagentUnit.Zero; foreach (var entity in entities) { if (entity.TryGetComponent(out CleanableComponent cleanable)) { var next = amount + cleanable.CleanAmount; // Nothing left? if (reactVolume < next) { break; } amount = next; entity.Delete(); } } return(amount); }
public FixedPoint2 TileReact(TileRef tile, ReagentPrototype reagent, FixedPoint2 reactVolume) { if (reactVolume >= Usage) { // TODO probably pass this in args like reagenteffects do. var entMan = IoCManager.Resolve <IEntityManager>(); if (Whitelist != null) { int acc = 0; foreach (var ent in tile.GetEntitiesInTile()) { if (Whitelist.IsValid(ent)) { acc += 1; } if (acc >= MaxOnTile) { return(FixedPoint2.Zero); } } } var random = IoCManager.Resolve <IRobustRandom>(); var xoffs = random.NextFloat(-RandomOffsetMax, RandomOffsetMax); var yoffs = random.NextFloat(-RandomOffsetMax, RandomOffsetMax); var pos = tile.GridPosition().Offset(new Vector2(0.5f + xoffs, 0.5f + yoffs)); entMan.SpawnEntity(Entity, pos); return(Usage); } return(FixedPoint2.Zero); }
public string[] RemoveEachReagent(EntityUid uid, Solution solution, FixedPoint2 quantity) { var removedReagent = new string[solution.Contents.Count]; if (quantity <= 0) { return(Array.Empty <string>()); } var pos = 0; for (var i = 0; i < solution.Contents.Count; i++) { var(reagentId, curQuantity) = solution.Contents[i]; removedReagent[pos++] = reagentId; if (!_prototypeManager.TryIndex(reagentId, out ReagentPrototype? proto)) { proto = new ReagentPrototype(); } var newQuantity = curQuantity - quantity; if (newQuantity <= 0) { solution.Contents.RemoveSwap(i); solution.TotalVolume -= curQuantity; } else { solution.Contents[i] = new Solution.ReagentQuantity(reagentId, newQuantity); solution.TotalVolume -= quantity; } } UpdateChemicals(uid, solution); return(removedReagent); }
public FixedPoint2 TileReact(TileRef tile, ReagentPrototype reagent, FixedPoint2 reactVolume) { tile.PryTile(); return(reactVolume); }
protected override void OnReaction(Solution solution, ReactionPrototype reaction, ReagentPrototype randomReagent, EntityUid Owner, FixedPoint2 unitReactions) { base.OnReaction(solution, reaction, randomReagent, Owner, unitReactions); var coordinates = EntityManager.GetComponent <TransformComponent>(Owner).Coordinates; _logSystem.Add(LogType.ChemicalReaction, reaction.Impact, $"Chemical reaction {reaction.ID} occurred with strength {unitReactions:strength} on entity {Owner} at {coordinates}"); SoundSystem.Play(Filter.Pvs(Owner, entityManager: EntityManager), reaction.Sound.GetSound(), Owner); }
ReagentUnit IReagentReaction.ReagentReactInjection(ReagentPrototype reagent, ReagentUnit volume) => Reaction(reagent, volume);
ReagentUnit IReagentReaction.ReagentReactTouch(ReagentPrototype reagent, ReagentUnit volume) => Reaction(reagent, volume);
protected override void OnReaction(Solution solution, ReactionPrototype reaction, ReagentPrototype randomReagent, EntityUid owner, FixedPoint2 unitReactions) { base.OnReaction(solution, reaction, randomReagent, owner, unitReactions); var coordinates = Transform(owner).Coordinates; _logSystem.Add(LogType.ChemicalReaction, reaction.Impact, $"Chemical reaction {reaction.ID:reaction} occurred with strength {unitReactions:strength} on entity {ToPrettyString(owner):metabolizer} at {coordinates}"); SoundSystem.Play(Filter.Pvs(owner, entityManager:EntityManager), reaction.Sound.GetSound(), owner); }
protected virtual void OnReaction(Solution solution, ReactionPrototype reaction, ReagentPrototype randomReagent, EntityUid owner, FixedPoint2 unitReactions) { var args = new ReagentEffectArgs(owner, null, solution, randomReagent, unitReactions, EntityManager, null); foreach (var effect in reaction.Effects) { if (!effect.ShouldApply(args)) { continue; } if (effect.ShouldLog) { var entity = args.SolutionEntity; _logSystem.Add(LogType.ReagentEffect, effect.LogImpact, $"Reaction effect {effect.GetType().Name:effect} of reaction ${reaction.ID:reaction} applied on entity {ToPrettyString(entity):entity} at {Transform(entity).Coordinates:coordinates}"); } effect.Effect(args); } }