public static void Process() { if (prefabsToSpawn.IsEmpty) { return; } Tuple <Vector3, GameObject> tuple; while (prefabsToSpawn.TryDequeue(out tuple)) { Spawn.ServerPrefab(tuple.Item2, tuple.Item1, MatrixManager.GetDefaultParent(tuple.Item1, true)); } }
public static void Process() { if (!prefabsToSpawn.IsEmpty) { SpawnSafeThreadData data; while (prefabsToSpawn.TryDequeue(out data)) { var result = Spawn.ServerPrefab(data.Prefab, data.WorldPosition, data.ParentTransform == null ? MatrixManager.GetDefaultParent(data.WorldPosition, true) : data.ParentTransform, count: data.Amount); //Greater than one as most items start stacked at 1 if (result.Successful && data.AmountIfStackable > 1 && result.GameObject.TryGetComponent <Stackable>(out var stackable)) { // -1 as we are adding, eg if we want 10 in stack, item already starts at 1 so we add 9 stackable.ServerIncrease(data.AmountIfStackable - 1); } } } if (!tilesToUpdate.IsEmpty) { Tuple <uint, Vector3Int, TileType, string, Matrix4x4, Color, LayerType> tuple; while (tilesToUpdate.TryDequeue(out tuple)) { UpdateTileMessage.Send(tuple.Item1, tuple.Item2, tuple.Item3, tuple.Item4, tuple.Item5, tuple.Item6, tuple.Item7); } } if (!tilesToRemove.IsEmpty) { Tuple <uint, Vector3Int, LayerType> tuple; while (tilesToRemove.TryDequeue(out tuple)) { RemoveTileMessage.Send(tuple.Item1, tuple.Item2, tuple.Item3); } } }
public static void Process() { if (!prefabsToSpawn.IsEmpty) { Tuple <Vector3, GameObject> tuple; while (prefabsToSpawn.TryDequeue(out tuple)) { Spawn.ServerPrefab(tuple.Item2, tuple.Item1, MatrixManager.GetDefaultParent(tuple.Item1, true)); } } if (!tilesToUpdate.IsEmpty) { Tuple <uint, Vector3Int, TileType, string, Matrix4x4, Color> tuple; while (tilesToUpdate.TryDequeue(out tuple)) { UpdateTileMessage.Send(tuple.Item1, tuple.Item2, tuple.Item3, tuple.Item4, tuple.Item5, tuple.Item6); } } }
public float React(ref GasMix gasMix, Vector3 tilePos) { if (gasMix.Temperature <= AtmosDefines.WATER_VAPOR_FREEZE) { if (gasMix.GetMoles(Gas.WaterVapor) < 2f) { //Not enough moles to freeze return(0f); } var numberOfIceToSpawn = Mathf.Floor(gasMix.GetMoles(Gas.WaterVapor) / 2f); for (var i = 0; i < numberOfIceToSpawn; i++) { Spawn.ServerPrefab(AtmosManager.Instance.iceShard, tilePos, MatrixManager.GetDefaultParent(tilePos, true)); } gasMix.RemoveGas(Gas.WaterVapor, numberOfIceToSpawn * 2f); } return(0f); }
public static void Process() { if (!prefabsToSpawn.IsEmpty) { SpawnSafeThreadData data; while (prefabsToSpawn.TryDequeue(out data)) { var result = Spawn.ServerPrefab(data.Prefab, data.WorldPosition, data.ParentTransform == null ? MatrixManager.GetDefaultParent(data.WorldPosition, true) : data.ParentTransform, count: data.Amount); //Greater than one as most items start stacked at 1 if (result.Successful && data.AmountIfStackable > 1 && result.GameObject.TryGetComponent <Stackable>(out var stackable)) { // -1 as we are adding, eg if we want 10 in stack, item already starts at 1 so we add 9 stackable.ServerIncrease(data.AmountIfStackable - 1); } } } }
private static Transform DefaultParent(Transform parent, Vector3?worldPos) { return(parent != null ? parent : MatrixManager.GetDefaultParent(worldPos, true)); }
public float React(ref GasMix gasMix, Vector3 tilePos) { var energyReleased = 0f; var oldHeatCap = gasMix.WholeHeatCapacity; var temperatureScale = 1f; if (gasMix.Temperature < AtmosDefines.FREON_LOWER_TEMPERATURE) { temperatureScale = 0; } else { temperatureScale = (AtmosDefines.FREON_MAXIMUM_BURN_TEMPERATURE - gasMix.Temperature) / (AtmosDefines.FREON_MAXIMUM_BURN_TEMPERATURE - AtmosDefines.FREON_LOWER_TEMPERATURE); } if (temperatureScale >= 0) { var oxygenBurnRate = AtmosDefines.OXYGEN_BURN_RATE_BASE - temperatureScale; var freonBurnRate = 0f; if (gasMix.GetMoles(Gas.Oxygen) > gasMix.GetMoles(Gas.Freon) * AtmosDefines.FREON_OXYGEN_FULLBURN) { freonBurnRate = gasMix.GetMoles(Gas.Freon) * temperatureScale / AtmosDefines.FREON_BURN_RATE_DELTA; } else { freonBurnRate = (temperatureScale * (gasMix.GetMoles(Gas.Oxygen) / AtmosDefines.FREON_OXYGEN_FULLBURN) / AtmosDefines.FREON_BURN_RATE_DELTA); } if (freonBurnRate > 0.0001f) { freonBurnRate = Mathf.Min(freonBurnRate, gasMix.GetMoles(Gas.Freon), gasMix.GetMoles(Gas.Oxygen)); gasMix.RemoveGas(Gas.Freon, freonBurnRate); gasMix.RemoveGas(Gas.Oxygen, freonBurnRate * oxygenBurnRate); gasMix.AddGas(Gas.CarbonDioxide, freonBurnRate); if (gasMix.Temperature < 160 && gasMix.Temperature > 120 && UnityEngine.Random.Range(0, 2) == 0) { Spawn.ServerPrefab(AtmosManager.Instance.hotIce, tilePos, MatrixManager.GetDefaultParent(tilePos, true)); } energyReleased += AtmosDefines.FIRE_FREON_ENERGY_RELEASED * freonBurnRate; } } if (energyReleased < 0) { var newHeatCap = gasMix.WholeHeatCapacity; if (newHeatCap > 0.0003f) { gasMix.Temperature = (gasMix.Temperature * oldHeatCap + energyReleased) / newHeatCap; } } return(0f); }