static GuiStyle() { int[] colors = new int[] { ColorUtil.Hex2Int("#A7251F"), ColorUtil.Hex2Int("#F01700"), ColorUtil.Hex2Int("#F04900"), ColorUtil.Hex2Int("#F07100"), ColorUtil.Hex2Int("#F0D100"), ColorUtil.Hex2Int("#F0ED00"), ColorUtil.Hex2Int("#E2F000"), ColorUtil.Hex2Int("#AAF000"), ColorUtil.Hex2Int("#71F000"), ColorUtil.Hex2Int("#33F000"), ColorUtil.Hex2Int("#00F06B"), }; DamageColorGradient = new int[100]; for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { DamageColorGradient[10 * i + j] = ColorUtil.ColorOverlay(colors[i], colors[i + 1], j / 10f); } } }
void genLabelMesh() { ItemStack stack = labelStack; if (LabelProps?.EditableShape != null && stack != null) { var capi = Api as ICoreClientAPI; int hashCode = stack.GetHashCode(GlobalConstants.IgnoredStackAttributes) + 23 * labelColor.GetHashCode(); if (ownBlock.itemStackRenders.TryGetValue(hashCode, out var val)) { val.UsedCounter.Add(Pos.GetHashCode()); GenLabelMeshWithItemStack(val.TextureSubId); return; } capi.Render.RenderItemStackToAtlas(stack, capi.BlockTextureAtlas, 52, (texSubid) => { ownBlock.itemStackRenders[hashCode] = new ItemStackRenderCacheItem() { TextureSubId = texSubid, UsedCounter = new HashSet <int>() }; ownBlock.itemStackRenders[hashCode].UsedCounter.Add(Pos.GetHashCode()); GenLabelMeshWithItemStack(texSubid); capi.BlockTextureAtlas.RegenMipMaps(capi.BlockTextureAtlas.Positions[texSubid].atlasNumber); MarkDirty(true); }, ColorUtil.ColorOverlay(labelColor, ColorUtil.WhiteArgb, 0.65f), 0.5f, 1f); } }
private void SpawnSnowParticles(IAsyncParticleManager manager, WeatherDataSnapshot weatherData, ClimateCondition conds, EntityPos plrPos, float plevel) { snowParticle.WindAffected = true; snowParticle.WindAffectednes = 1f; float wetness = 2.5f * GameMath.Clamp(ws.clientClimateCond.Temperature + 1, 0, 4) / 4f; float dx = (float)(plrPos.Motion.X * 40) - (30 - 9 * wetness) * 2 * weatherData.curWindSpeed.X; float dy = (float)(plrPos.Motion.Y * 40); float dz = (float)(plrPos.Motion.Z * 40); snowParticle.MinVelocity.Set(-0.5f + 5 * weatherData.curWindSpeed.X, -1f, -0.5f); snowParticle.AddVelocity.Set(1f + 5 * weatherData.curWindSpeed.X, 0.05f, 1f); snowParticle.Color = ColorUtil.ToRgba(255, 255, 255, 255); snowParticle.MinQuantity = 100 * plevel * (1 + wetness / 3); snowParticle.AddQuantity = 25 * plevel * (1 + wetness / 3); snowParticle.ParentVelocity = parentVeloSnow; snowParticle.ShouldDieInLiquid = true; snowParticle.LifeLength = Math.Max(1f, 4f - wetness); snowParticle.Color = ColorUtil.ColorOverlay(ColorUtil.ToRgba(255, 255, 255, 255), rainParticle.Color, wetness / 4f); snowParticle.GravityEffect = 0.005f * (1 + 20 * wetness); snowParticle.MinSize = 0.1f * conds.Rainfall; snowParticle.MaxSize = 0.3f * conds.Rainfall / (1 + wetness); float hrange = 40; float vrange = 23; snowParticle.MinPos.Set(particlePos.X - hrange + dx, particlePos.Y + vrange + dy, particlePos.Z - hrange + dz); snowParticle.AddPos.Set(2 * hrange + dx, -0.66f * vrange + dy, 2 * hrange + dz); manager.Spawn(snowParticle); }
public override int GetColor(ICoreClientAPI capi, BlockPos pos) { string grasscover = LastCodePart(); if (grasscover == "none") { return(base.GetColorWithoutTint(capi, pos)); } int?textureSubId = grassTex?.Baked.TextureSubId; if (textureSubId == null) { return(ColorUtil.WhiteArgb); } int grassColor = capi.BlockTextureAtlas.GetAverageColor((int)textureSubId); if (ClimateColorMapResolved != null) { grassColor = capi.World.ApplyColorMapOnRgba(ClimateColorMapResolved, SeasonColorMapResolved, grassColor, pos.X, pos.Y, pos.Z, false); } if (grasscover == "normal") { return(grassColor); } else { int soilColor = capi.BlockTextureAtlas.GetAverageColor((int)Textures["up"].Baked.TextureSubId); return(ColorUtil.ColorOverlay(soilColor, grassColor, grasscover == "verysparse" ? 0.5f : 0.75f)); } }
public override int GetColorWithoutTint(ICoreClientAPI capi, BlockPos pos) { string grasscover = LastCodePart(); if (grasscover == "none") { return(base.GetColorWithoutTint(capi, pos)); } int?textureSubId = grassTex?.Baked.TextureSubId; if (textureSubId == null) { return(ColorUtil.WhiteArgb); } int grassColor = capi.BlockTextureAtlas.GetRandomColor((int)textureSubId); if (grasscover == "normal") { return(grassColor); } else { int soilColor = capi.BlockTextureAtlas.GetRandomColor((int)Textures["up"].Baked.TextureSubId); return(ColorUtil.ColorOverlay(soilColor, grassColor, grasscover == "verysparse" ? 0.5f : 0.75f)); } }
public override int GetColor(ICoreClientAPI capi, BlockPos pos) { float grassLevel = Variant["grass"].ToInt() / 7f; if (grassLevel == 0) { return(base.GetColorWithoutTint(capi, pos)); } int?textureSubId = grassTex?.Baked.TextureSubId; if (textureSubId == null) { return(ColorUtil.WhiteArgb); } int grassColor = capi.BlockTextureAtlas.GetAverageColor((int)textureSubId); if (ClimateColorMapResolved != null) { grassColor = capi.World.ApplyColorMapOnRgba(ClimateColorMapResolved, SeasonColorMapResolved, grassColor, pos.X, pos.Y, pos.Z, false); } int soilColor = capi.BlockTextureAtlas.GetAverageColor((int)Textures["up"].Baked.TextureSubId); return(ColorUtil.ColorOverlay(soilColor, grassColor, grassLevel)); }
private void OnWaterModifierChanged() { if (!_enabled) { return; } var waterModifier = _mod.CApi.Ambient.CurrentModifiers["water"]; waterModifier.AmbientColor = _ambient; var ambient = _ambient.Value; ambient[0] = 1.5f; ambient[1] = 1.5f; ambient[2] = 2.0f; waterModifier.FogColor.Weight = _ambient.Weight; var fog = waterModifier.FogColor.Value; var fogInt = (int)(fog[0] * 255) | ((int)(fog[1] * 255) << 8) | ((int)(fog[2] * 255) << 16); const int blueInt = 0xd68100; fogInt = ColorUtil.ColorOverlay(fogInt, blueInt, 0.5f); fog[0] = (fogInt & 255) / 255.0f; fog[1] = ((fogInt >> 8) & 255) / 255.0f; fog[2] = ((fogInt >> 16) & 255) / 255.0f; }
public override int GetColorWithoutTint(ICoreClientAPI capi, BlockPos pos) { string grasscover = LastCodePart(); if (grasscover == "none") { return(base.GetColorWithoutTint(capi, pos)); } CompositeTexture tex; if (Textures == null || !Textures.TryGetValue("specialSecondTexture", out tex)) { tex = Textures?.First().Value; } int?textureSubId = tex?.Baked.TextureSubId; if (textureSubId == null) { return(ColorUtil.WhiteArgb); } int grassColor = capi.BlockTextureAtlas.GetRandomColor((int)textureSubId); if (grasscover == "normal") { return(grassColor); } else { int soilColor = capi.BlockTextureAtlas.GetRandomColor((int)Textures["up"].Baked.TextureSubId); return(ColorUtil.ColorOverlay(soilColor, grassColor, grasscover == "verysparse" ? 0.5f : 0.75f)); } }
static bool Prefix(Entity __instance, ref int __result) { if ((__instance as EntityAgent)?.WatchedAttributes.GetBool("frosted") == true) { float frostms = (__instance as EntityAgent).WatchedAttributes.GetFloat("frostms"); __result = ColorUtil.ColorOverlay(ColorUtil.ToRgba(255, 100, 100, 255), ColorUtil.WhiteArgb, 1 / 250f); return(false); } return(true); }
public override int GetColorWithoutTint(ICoreClientAPI capi, BlockPos pos) { int texSubId = Textures["wood"].Baked.TextureSubId; return(ColorUtil.ReverseColorBytes( ColorUtil.ColorOverlay( capi.BlockTextureAtlas.GetPixelAt(texSubId, 0.4f, 0.4f), capi.BlockTextureAtlas.GetPixelAt(texSubId, 0.6f, 0.6f), 0.5f ) )); }
public override int GetColor(ICoreClientAPI capi, BlockPos pos) { string grasscover = LastCodePart(); if (grasscover == "none") { return(base.GetColor(capi, pos)); } CompositeTexture tex; if (Textures == null || !Textures.TryGetValue("specialSecondTexture", out tex)) { tex = Textures?.First().Value; } int?textureSubId = tex?.Baked.TextureSubId; if (textureSubId == null) { return(ColorUtil.WhiteArgb); } int grassColor = ColorUtil.ReverseColorBytes(capi.BlockTextureAtlas.GetPixelAt((int)textureSubId, 0.5f, 0.5f)); if (TintIndex > 0) { grassColor = capi.ApplyColorTintOnRgba(TintIndex, grassColor, pos.X, pos.Y, pos.Z, false); } if (grasscover == "normal") { return(grassColor); } else { int soilColor = ColorUtil.ReverseColorBytes(capi.BlockTextureAtlas.GetPixelAt((int)Textures["up"].Baked.TextureSubId, 0.5f, 0.5f)); return(ColorUtil.ColorOverlay(soilColor, grassColor, grasscover == "verysparse" ? 0.5f : 0.75f)); } }
private bool asyncParticleSpawn(float dt, IAsyncParticleManager manager) { WeatherDataSnapshot weatherData = ws.BlendedWeatherData; ClimateCondition conds = ws.clientClimateCond; if (conds == null || !ws.playerChunkLoaded) { return(true); } EntityPos plrPos = capi.World.Player.Entity.Pos; float precIntensity = conds.Rainfall; float plevel = precIntensity * capi.Settings.Int["particleLevel"] / 100f; tmpPos.Set((int)plrPos.X, (int)plrPos.Y, (int)plrPos.Z); //float plevel = weatherData.PrecIntensity * capi.Settings.Int["particleLevel"] / 100f; EnumPrecipitationType precType = weatherData.BlendedPrecType; if (precType == EnumPrecipitationType.Auto) { precType = conds.Temperature < weatherData.snowThresholdTemp ? EnumPrecipitationType.Snow : EnumPrecipitationType.Rain; } particlePos.Set(capi.World.Player.Entity.Pos.X, capi.World.Player.Entity.Pos.Y, capi.World.Player.Entity.Pos.Z); int onwaterSplashParticleColor = capi.World.ApplyColorMapOnRgba(lblock.ClimateColorMapForMap, lblock.SeasonColorMapForMap, ColorUtil.WhiteArgb, (int)particlePos.X, (int)particlePos.Y, (int)particlePos.Z, false); byte[] col = ColorUtil.ToBGRABytes(onwaterSplashParticleColor); onwaterSplashParticleColor = ColorUtil.ToRgba(94, col[0], col[1], col[2]); centerPos.Set((int)particlePos.X, 0, (int)particlePos.Z); for (int lx = 0; lx < 16; lx++) { int dx = (lx - 8) * 4; for (int lz = 0; lz < 16; lz++) { int dz = (lz - 8) * 4; lowResRainHeightMap[lx, lz] = capi.World.BlockAccessor.GetRainMapHeightAt(centerPos.X + dx, centerPos.Z + dz); } } int rainYPos = capi.World.BlockAccessor.GetRainMapHeightAt((int)particlePos.X, (int)particlePos.Z); parentVeloSnow.X = -Math.Max(0, weatherData.curWindSpeed.X / 2 - 0.15f); parentVeloSnow.Y = 0; parentVeloSnow.Z = 0; // Don't spawn if wind speed below 70% or if the player is 10 blocks above ground if (weatherData.curWindSpeed.X > 0.7f && particlePos.Y - rainYPos < 10) { float dx = (float)(plrPos.Motion.X * 40) - 50 * weatherData.curWindSpeed.X; float dy = (float)(plrPos.Motion.Y * 40); float dz = (float)(plrPos.Motion.Z * 40); dustParticles.MinPos.Set(particlePos.X - 40 + dx, particlePos.Y + 15 + dy, particlePos.Z - 40 + dz); dustParticles.AddPos.Set(80, -20, 80); dustParticles.GravityEffect = -0.1f - (float)rand.NextDouble() * 0.1f; dustParticles.ParticleModel = EnumParticleModel.Quad; dustParticles.LifeLength = 1f; dustParticles.DieOnRainHeightmap = true; dustParticles.WindAffectednes = 8f; dustParticles.MinQuantity = 0; dustParticles.AddQuantity = 6 * (weatherData.curWindSpeed.X - 0.7f); dustParticles.MinSize = 0.1f; dustParticles.MaxSize = 0.4f; dustParticles.MinVelocity.Set(-0.025f + 8 * weatherData.curWindSpeed.X, -0.2f, -0.025f); dustParticles.AddVelocity.Set(0.05f + 4 * weatherData.curWindSpeed.X, 0.05f, 0.05f); for (int i = 0; i < 6; i++) { double px = particlePos.X + dx + (rand.NextDouble() * rand.NextDouble()) * 60 * (1 - 2 * rand.Next(2)); double pz = particlePos.Z + dz + (rand.NextDouble() * rand.NextDouble()) * 60 * (1 - 2 * rand.Next(2)); int py = capi.World.BlockAccessor.GetRainMapHeightAt((int)px, (int)pz); Block block = capi.World.BlockAccessor.GetBlock((int)px, py, (int)pz); if (block.IsLiquid()) { continue; } tmpPos.Set((int)px, py, (int)pz); dustParticles.Color = ColorUtil.ReverseColorBytes(block.GetColor(capi, tmpPos)); dustParticles.Color |= 255 << 24; manager.Spawn(dustParticles); } } if (precIntensity <= 0.02) { return(true); } if (precType == EnumPrecipitationType.Hail) { float dx = (float)(plrPos.Motion.X * 40) - 4 * weatherData.curWindSpeed.X; float dy = (float)(plrPos.Motion.Y * 40); float dz = (float)(plrPos.Motion.Z * 40); hailParticle.MinPos.Set(particlePos.X + dx, particlePos.Y + 15 + dy, particlePos.Z + dz); hailParticle.MinSize = 0.3f * (0.5f + conds.Rainfall); // * weatherData.PrecParticleSize; hailParticle.MaxSize = 1f * (0.5f + conds.Rainfall); // * weatherData.PrecParticleSize; //hailParticle.AddPos.Set(80, 5, 80); hailParticle.Color = ColorUtil.ToRgba(220, 210, 230, 255); hailParticle.MinQuantity = 100 * plevel; hailParticle.AddQuantity = 25 * plevel; hailParticle.MinVelocity.Set(-0.025f + 7.5f * weatherData.curWindSpeed.X, -5f, -0.025f); hailParticle.AddVelocity.Set(0.05f + 7.5f * weatherData.curWindSpeed.X, 0.05f, 0.05f); manager.Spawn(hailParticle); return(true); } if (precType == EnumPrecipitationType.Rain) { float dx = (float)(plrPos.Motion.X * 80); float dy = (float)(plrPos.Motion.Y * 80); float dz = (float)(plrPos.Motion.Z * 80); rainParticle.MinPos.Set(particlePos.X - 30 + dx, particlePos.Y + 15 + dy, particlePos.Z - 30 + dz); rainParticle.WithTerrainCollision = false; rainParticle.MinQuantity = 1000 * plevel; rainParticle.LifeLength = 1f; rainParticle.AddQuantity = 25 * plevel; rainParticle.MinSize = 0.15f * (0.5f + conds.Rainfall); // * weatherData.PrecParticleSize; rainParticle.MaxSize = 0.22f * (0.5f + conds.Rainfall); // weatherData.PrecParticleSize; rainParticle.Color = rainParticleColor; rainParticle.MinVelocity.Set(-0.025f + 8 * weatherData.curWindSpeed.X, -10f, -0.025f); rainParticle.AddVelocity.Set(0.05f + 8 * weatherData.curWindSpeed.X, 0.05f, 0.05f); manager.Spawn(rainParticle); splashParticles.MinVelocity = new Vec3f(-1f, 3, -1f); splashParticles.AddVelocity = new Vec3f(2, 0, 2); splashParticles.LifeLength = 0.1f; splashParticles.MinSize = 0.07f * (0.5f + 0.65f * conds.Rainfall); // weatherData.PrecParticleSize; splashParticles.MaxSize = 0.2f * (0.5f + 0.65f * conds.Rainfall); // weatherData.PrecParticleSize; splashParticles.ShouldSwimOnLiquid = true; splashParticles.Color = rainParticleColor; float cnt = 100 * plevel; for (int i = 0; i < cnt; i++) { double px = particlePos.X + (rand.NextDouble() * rand.NextDouble()) * 60 * (1 - 2 * rand.Next(2)); double pz = particlePos.Z + (rand.NextDouble() * rand.NextDouble()) * 60 * (1 - 2 * rand.Next(2)); int py = capi.World.BlockAccessor.GetRainMapHeightAt((int)px, (int)pz); Block block = capi.World.BlockAccessor.GetBlock((int)px, py, (int)pz); if (block.IsLiquid()) { splashParticles.MinPos.Set(px, py + block.TopMiddlePos.Y - 1 / 8f, pz); splashParticles.AddVelocity.Y = 1.5f; splashParticles.LifeLength = 0.17f; splashParticles.Color = onwaterSplashParticleColor; } else { double b = 0.75 + 0.25 * rand.NextDouble(); int ca = 230 - rand.Next(100); int cr = (int)(((rainParticleColor >> 16) & 0xff) * b); int cg = (int)(((rainParticleColor >> 8) & 0xff) * b); int cb = (int)(((rainParticleColor >> 0) & 0xff) * b); splashParticles.Color = (ca << 24) | (cr << 16) | (cg << 8) | cb; splashParticles.AddVelocity.Y = 0f; splashParticles.LifeLength = 0.1f; splashParticles.MinPos.Set(px, py + block.TopMiddlePos.Y + 0.05, pz); } manager.Spawn(splashParticles); } } if (precType == EnumPrecipitationType.Snow) { float wetness = 2.5f * GameMath.Clamp(ws.clientClimateCond.Temperature + 1, 0, 4) / 4f; float dx = (float)(plrPos.Motion.X * 40) - (30 - 9 * wetness) * weatherData.curWindSpeed.X; float dy = (float)(plrPos.Motion.Y * 40); float dz = (float)(plrPos.Motion.Z * 40); snowParticle.MinVelocity.Set(-0.5f + 5 * weatherData.curWindSpeed.X, -1f, -0.5f); snowParticle.AddVelocity.Set(1f + 5 * weatherData.curWindSpeed.X, 0.05f, 1f); snowParticle.Color = ColorUtil.ToRgba(255, 255, 255, 255); snowParticle.MinQuantity = 90 * plevel * (1 + wetness / 3); snowParticle.AddQuantity = 15 * plevel * (1 + wetness / 3); snowParticle.ParentVelocity = parentVeloSnow; snowParticle.ShouldDieInLiquid = true; snowParticle.LifeLength = Math.Max(1f, 4f - wetness); snowParticle.Color = ColorUtil.ColorOverlay(ColorUtil.ToRgba(255, 255, 255, 255), rainParticle.Color, wetness / 4f); snowParticle.GravityEffect = 0.005f * (1 + 20 * wetness); snowParticle.MinSize = 0.1f * conds.Rainfall; // weatherData.PrecParticleSize; snowParticle.MaxSize = 0.3f * conds.Rainfall / (1 + wetness); // weatherData.PrecParticleSize / (1 + wetness); float hrange = 40; float vrange = 20; snowParticle.MinPos.Set(particlePos.X - hrange + dx, particlePos.Y + vrange + dy, particlePos.Z - hrange + dz); snowParticle.AddPos.Set(2 * hrange + dx, -0.66f * vrange + dy, 2 * hrange + dz); manager.Spawn(snowParticle); } return(true); }
public override void OnGameTick(float deltaTime) { if (!enabled) { return; } if (requireInitSounds) { initSoundsAndEffects(); requireInitSounds = false; } if (entity.World.Side == EnumAppSide.Client) { if (!(entity.World.Api as ICoreClientAPI).PlayerReadyFired) { return; } } else { IServerPlayer player = entity.World.PlayerByUid(((EntityPlayer)entity).PlayerUID) as IServerPlayer; if (player != null && player.ConnectionState != EnumClientState.Playing) { return; } } deltaTime = GameMath.Min(0.5f, deltaTime); float changeSpeed = deltaTime / 3; double hereStability = stabilityOffset + tempStabilitySystem.GetTemporalStability(entity.SidedPos.X, entity.SidedPos.Y, entity.SidedPos.Z); entity.Attributes.SetDouble("tempStabChangeVelocity", TempStabChangeVelocity); double gain = TempStabChangeVelocity > 0 ? (TempStabChangeVelocity / 200.0) : (TempStabChangeVelocity / 800.0); OwnStability = GameMath.Clamp(OwnStability + gain, 0f, 1); double ownStability = OwnStability; TempStabChangeVelocity = (hereTempStabChangeVelocity - TempStabChangeVelocity) * deltaTime; float glitchEffectExtraStrength = tempStabilitySystem.GetGlitchEffectExtraStrength(); double targetGlitchEffectStrength = Math.Max(0, Math.Max(0, (0.2f - ownStability) * 1 / 0.2f) + glitchEffectExtraStrength); glitchEffectStrength += (targetGlitchEffectStrength - glitchEffectStrength) * changeSpeed; glitchEffectStrength = GameMath.Clamp(glitchEffectStrength, 0, 1.1f); double targetFogEffectStrength = Math.Max(0, Math.Max(0, (0.3f - ownStability) * 1 / 0.3f) + glitchEffectExtraStrength); fogEffectStrength += (targetFogEffectStrength - fogEffectStrength) * changeSpeed; fogEffectStrength = GameMath.Clamp(fogEffectStrength, 0, 1.1f); double targetRustPrecipStrength = Math.Max(0, Math.Max(0, (0.3f - ownStability) * 1 / 0.3f) + glitchEffectExtraStrength); rustPrecipColorStrength += (targetRustPrecipStrength - rustPrecipColorStrength) * changeSpeed; rustPrecipColorStrength = GameMath.Clamp(rustPrecipColorStrength, 0, 1f); if (precipParticleSys != null) { precipParticleSys.rainParticleColor = ColorUtil.ColorOverlay(WeatherSimulationParticles.waterColor, WeatherSimulationParticles.lowStabColor, (float)rustPrecipColorStrength); } hereTempStabChangeVelocity = hereStability - 1; oneSecAccum += deltaTime; if (oneSecAccum > 1) { oneSecAccum = 0; updateSoundsAndEffects(hereStability, Math.Max(0, ownStability - 1.5f * glitchEffectExtraStrength)); } threeSecAccum += deltaTime; if (threeSecAccum > 4) { threeSecAccum = 0; if (entity.World.Side == EnumAppSide.Server && ownStability < 0.13) { entity.ReceiveDamage(new DamageSource() { DamageTier = 0, Source = EnumDamageSource.Machine, Type = EnumDamageType.Poison }, (float)(0.15 - ownStability)); } } if (isSelf) { capi.Render.ShaderUniforms.GlitchStrength = 0; } if (isSelf && (fogEffectStrength > 0.05 || glitchEffectStrength > 0.05)) { capi.Render.ShaderUniforms.GlitchStrength = (float)glitchEffectStrength; capi.Render.ShaderUniforms.GlobalWorldWarp = (float)(capi.World.Rand.NextDouble() < 0.015 ? (Math.Max(0, glitchEffectStrength - 0.05f) * capi.World.Rand.NextDouble() * capi.World.Rand.NextDouble()) : 0); capi.Render.ShaderUniforms.WindWaveCounter += (float)(capi.World.Rand.NextDouble() < 0.015 ? 9 * capi.World.Rand.NextDouble() : 0); capi.Render.ShaderUniforms.WaterWaveCounter += (float)(capi.World.Rand.NextDouble() < 0.015 ? 9 * capi.World.Rand.NextDouble() : 0); if (capi.World.Rand.NextDouble() < 0.002) { capi.Input.MouseYaw += (float)capi.World.Rand.NextDouble() * 0.125f - 0.125f / 2; capi.Input.MousePitch += (float)capi.World.Rand.NextDouble() * 0.125f - 0.125f / 2; } tmpPos.Set((int)entity.Pos.X, (int)entity.Pos.Y, (int)entity.Pos.Z); float sunb = capi.World.BlockAccessor.GetLightLevel(tmpPos, EnumLightLevelType.OnlySunLight) / 22f; float strength = Math.Min(1, (float)(glitchEffectStrength)); double fognoise = fogEffectStrength * Math.Abs(fogNoise.Noise(0, capi.InWorldEllapsedMilliseconds / 1000f)) / 60f; rainfogAmbient.FogDensity.Value = 0.05f + (float)fognoise; rainfogAmbient.AmbientColor.Weight = strength; rainfogAmbient.FogColor.Weight = strength; rainfogAmbient.FogDensity.Weight = (float)Math.Pow(strength, 2); rainfogAmbient.FogColor.Value[0] = sunb * 116 / 255f; rainfogAmbient.FogColor.Value[1] = sunb * 77 / 255f; rainfogAmbient.FogColor.Value[2] = sunb * 49 / 255f; rainfogAmbient.AmbientColor.Value[0] = 0.5f * 116 / 255f; rainfogAmbient.AmbientColor.Value[1] = 0.5f * 77 / 255f; rainfogAmbient.AmbientColor.Value[2] = 0.5f * 49 / 255f; rustParticles.MinVelocity.Set(-0.1f, 0.1f, 0.1f); rustParticles.AddVelocity.Set(0.2f, 0.2f, 0.2f); rustParticles.Color = ColorUtil.ToRgba((int)(strength * 150), 50, 25, 15); rustParticles.MaxSize = 0.25f; rustParticles.RandomVelocityChange = false; rustParticles.MinVelocity.Set(0, 0, 0); rustParticles.AddVelocity.Set(0, 1, 0); Vec3d position = new Vec3d(); EntityPos plrPos = capi.World.Player.Entity.Pos; float tries = 20 * strength; while (tries-- > 0) { float offX = (float)capi.World.Rand.NextDouble() * 24 - 12; float offY = (float)capi.World.Rand.NextDouble() * 24 - 12; float offZ = (float)capi.World.Rand.NextDouble() * 24 - 12; position.Set(plrPos.X + offX, plrPos.Y + offY, plrPos.Z + offZ); BlockPos pos = new BlockPos((int)position.X, (int)position.Y, (int)position.Z); if (!capi.World.BlockAccessor.IsValidPos(pos)) { continue; } rustParticles.MinPos = position; capi.World.SpawnParticles(rustParticles); } } }
public int[] GenerateChunkImage(Vec2i chunkPos, IMapChunk mc, bool withSnow = true) { ICoreClientAPI capi = api as ICoreClientAPI; BlockPos tmpPos = new BlockPos(); Vec2i localpos = new Vec2i(); // Prefetch chunks for (int cy = 0; cy < chunksTmp.Length; cy++) { chunksTmp[cy] = capi.World.BlockAccessor.GetChunk(chunkPos.X, cy, chunkPos.Y); if (chunksTmp[cy] == null || !(chunksTmp[cy] as IClientChunk).LoadedFromServer) { return(null); } } // Prefetch map chunks IMapChunk[] mapChunks = new IMapChunk[] { capi.World.BlockAccessor.GetMapChunk(chunkPos.X - 1, chunkPos.Y - 1), capi.World.BlockAccessor.GetMapChunk(chunkPos.X - 1, chunkPos.Y), capi.World.BlockAccessor.GetMapChunk(chunkPos.X, chunkPos.Y - 1) }; int[] texDataTmp = new int[chunksize * chunksize]; for (int i = 0; i < texDataTmp.Length; i++) { int y = mc.RainHeightMap[i]; int cy = y / chunksize; if (cy >= chunksTmp.Length) { continue; } MapUtil.PosInt2d(i, chunksize, localpos); int lx = localpos.X; int lz = localpos.Y; float b = 1; int leftTop, rightTop, leftBot; IMapChunk leftTopMapChunk = mc; IMapChunk rightTopMapChunk = mc; IMapChunk leftBotMapChunk = mc; int topX = lx - 1; int botX = lx; int leftZ = lz - 1; int rightZ = lz; if (topX < 0 && leftZ < 0) { leftTopMapChunk = mapChunks[0]; rightTopMapChunk = mapChunks[1]; leftBotMapChunk = mapChunks[2]; } else { if (topX < 0) { leftTopMapChunk = mapChunks[1]; rightTopMapChunk = mapChunks[1]; } if (leftZ < 0) { leftTopMapChunk = mapChunks[2]; leftBotMapChunk = mapChunks[2]; } } topX = GameMath.Mod(topX, chunksize); leftZ = GameMath.Mod(leftZ, chunksize); leftTop = leftTopMapChunk == null ? 0 : Math.Sign(y - leftTopMapChunk.RainHeightMap[leftZ * chunksize + topX]); rightTop = rightTopMapChunk == null ? 0 : Math.Sign(y - rightTopMapChunk.RainHeightMap[rightZ * chunksize + topX]); leftBot = leftBotMapChunk == null ? 0 : Math.Sign(y - leftBotMapChunk.RainHeightMap[leftZ * chunksize + botX]); float slopeness = (leftTop + rightTop + leftBot); if (slopeness > 0) { b = 1.18f; } if (slopeness < 0) { b = 0.82f; } int blockId = chunksTmp[cy].Unpack_AndReadBlock(MapUtil.Index3d(localpos.X, y % chunksize, localpos.Y, chunksize, chunksize)); Block block = api.World.Blocks[blockId]; if (!withSnow && block.BlockMaterial == EnumBlockMaterial.Snow) { y--; cy = y / chunksize; blockId = chunksTmp[cy].Unpack_AndReadBlock(MapUtil.Index3d(localpos.X, y % chunksize, localpos.Y, chunksize, chunksize)); block = api.World.Blocks[blockId]; } tmpPos.Set(chunksize * chunkPos.X + localpos.X, y, chunksize * chunkPos.Y + localpos.Y); int avgCol = block.GetColor(capi, tmpPos); int rndCol = block.GetRandomColor(capi, tmpPos, BlockFacing.UP, GameMath.MurmurHash3Mod(tmpPos.X, tmpPos.Y, tmpPos.Z, 30)); // Why the eff is r and b flipped rndCol = ((rndCol & 0xff) << 16) | (((rndCol >> 8) & 0xff) << 8) | (((rndCol >> 16) & 0xff) << 0); // Add a bit of randomness to each pixel int col = ColorUtil.ColorOverlay(avgCol, rndCol, 0.6f); texDataTmp[i] = ColorUtil.ColorMultiply3Clamped(col, b) | 255 << 24; } for (int cy = 0; cy < chunksTmp.Length; cy++) { chunksTmp[cy] = null; } return(texDataTmp); }
public int[] GenerateChunkImage(Vec2i chunkPos, IMapChunk mc, bool withSnow = true) { ICoreClientAPI capi = api as ICoreClientAPI; //capi.Logger.Notification("GenImg @{0}/{1}", chunkPos.X, chunkPos.Y); BlockPos tmpPos = new BlockPos(); Vec2i localpos = new Vec2i(); // Prefetch chunks for (int cy = 0; cy < chunksTmp.Length; cy++) { chunksTmp[cy] = capi.World.BlockAccessor.GetChunk(chunkPos.X, cy, chunkPos.Y); if (chunksTmp[cy] == null) { return(null); } } // Prefetch map chunks IMapChunk[] mapChunks = new IMapChunk[] { capi.World.BlockAccessor.GetMapChunk(chunkPos.X - 1, chunkPos.Y - 1), capi.World.BlockAccessor.GetMapChunk(chunkPos.X - 1, chunkPos.Y), capi.World.BlockAccessor.GetMapChunk(chunkPos.X, chunkPos.Y - 1) }; int[] texDataTmp = new int[chunksize * chunksize]; for (int i = 0; i < texDataTmp.Length; i++) { int y = mc.RainHeightMap[i]; int cy = y / chunksize; if (cy >= chunksTmp.Length) { continue; } MapUtil.PosInt2d(i, chunksize, localpos); int lx = localpos.X; int lz = localpos.Y; float b = 1; int leftTop, rightTop, leftBot; IMapChunk leftTopMapChunk = mc; IMapChunk rightTopMapChunk = mc; IMapChunk leftBotMapChunk = mc; int topX = lx - 1; int botX = lx; int leftZ = lz - 1; int rightZ = lz; if (topX < 0 && leftZ < 0) { leftTopMapChunk = mapChunks[0]; rightTopMapChunk = mapChunks[1]; leftBotMapChunk = mapChunks[2]; } else { if (topX < 0) { leftTopMapChunk = mapChunks[1]; rightTopMapChunk = mapChunks[1]; } if (leftZ < 0) { leftTopMapChunk = mapChunks[2]; leftBotMapChunk = mapChunks[2]; } } topX = GameMath.Mod(topX, chunksize); leftZ = GameMath.Mod(leftZ, chunksize); leftTop = leftTopMapChunk == null ? 0 : Math.Sign(y - leftTopMapChunk.RainHeightMap[leftZ * chunksize + topX]); rightTop = rightTopMapChunk == null ? 0 : Math.Sign(y - rightTopMapChunk.RainHeightMap[rightZ * chunksize + topX]); leftBot = leftBotMapChunk == null ? 0 : Math.Sign(y - leftBotMapChunk.RainHeightMap[leftZ * chunksize + botX]); float slopeness = (leftTop + rightTop + leftBot); if (slopeness > 0) { b = 1.18f; } if (slopeness < 0) { b = 0.82f; } chunksTmp[cy].Unpack(); int blockId = chunksTmp[cy].Blocks[MapUtil.Index3d(localpos.X, y % chunksize, localpos.Y, chunksize, chunksize)]; Block block = api.World.Blocks[blockId]; /*if (i == 0) * { * capi.Logger.Notification("GenImg @{0}/{1}, first block is {2}", chunkPos.X, chunkPos.Y, block.Code); * }*/ if (!withSnow && block.BlockMaterial == EnumBlockMaterial.Snow) { y--; cy = y / chunksize; chunksTmp[cy].Unpack(); blockId = chunksTmp[cy].Blocks[MapUtil.Index3d(localpos.X, y % chunksize, localpos.Y, chunksize, chunksize)]; block = api.World.Blocks[blockId]; } tmpPos.Set(chunksize * chunkPos.X + localpos.X, y, chunksize * chunkPos.Y + localpos.Y); int avgCol = block.GetColor(capi, tmpPos); int rndCol = block.GetRandomColor(capi, tmpPos, BlockFacing.UP); // Add a bit of randomness to each pixel int col = ColorUtil.ColorOverlay(avgCol, rndCol, 0.2f); texDataTmp[i] = ColorUtil.ColorMultiply3Clamped(col, b) | 255 << 24; } for (int cy = 0; cy < chunksTmp.Length; cy++) { chunksTmp[cy] = null; } return(texDataTmp); }
private bool asyncParticleSpawn(float dt, IAsyncParticleManager manager) { WeatherDataSnapshot weatherData = ws.blendedWeatherData; float plevel = weatherData.PrecIntensity * capi.Settings.Int["particleLevel"] / 100f; EnumPrecipitationType precType = weatherData.nowPrecType; particlePos.Set(capi.World.Player.Entity.Pos.X, capi.World.Player.Entity.Pos.Y, capi.World.Player.Entity.Pos.Z); EntityPos plrPos = capi.World.Player.Entity.Pos; centerPos.Set((int)particlePos.X, 0, (int)particlePos.Z); for (int lx = 0; lx < 16; lx++) { int dx = (lx - 8) * 4; for (int lz = 0; lz < 16; lz++) { int dz = (lz - 8) * 4; lowResRainHeightMap[lx, lz] = capi.World.BlockAccessor.GetRainMapHeightAt(centerPos.X + dx, centerPos.Z + dz); } } int rainYPos = capi.World.BlockAccessor.GetRainMapHeightAt((int)particlePos.X, (int)particlePos.Z); parentVeloSnow.X = -Math.Max(0, weatherData.curWindSpeed.X / 2 - 0.15f); parentVeloSnow.Y = 0; parentVeloSnow.Z = 0; // Don't spawn if wind speed below 70% or if the player is 10 blocks above ground if (weatherData.curWindSpeed.X > 0.7f && particlePos.Y - rainYPos < 10) { float dx = (float)(plrPos.Motion.X * 40) - 50 * weatherData.curWindSpeed.X; float dy = (float)(plrPos.Motion.Y * 40); float dz = (float)(plrPos.Motion.Z * 40); dustParticles.MinPos.Set(particlePos.X - 40 + dx, particlePos.Y + 15 + dy, particlePos.Z - 40 + dz); dustParticles.AddPos.Set(80, -20, 80); dustParticles.GravityEffect = -0.1f - (float)rand.NextDouble() * 0.1f; dustParticles.ParticleModel = EnumParticleModel.Quad; dustParticles.LifeLength = 1f; dustParticles.DieOnRainHeightmap = true; dustParticles.WindAffectednes = 8f; dustParticles.MinQuantity = 0; dustParticles.AddQuantity = 6 * (weatherData.curWindSpeed.X - 0.7f); dustParticles.MinSize = 0.1f; dustParticles.MaxSize = 0.4f; dustParticles.MinVelocity.Set(-0.025f + 8 * weatherData.curWindSpeed.X, -0.2f, -0.025f); dustParticles.AddVelocity.Set(0.05f + 4 * weatherData.curWindSpeed.X, 0.05f, 0.05f); for (int i = 0; i < 6; i++) { double px = particlePos.X + dx + (rand.NextDouble() * rand.NextDouble()) * 60 * (1 - 2 * rand.Next(2)); double pz = particlePos.Z + dz + (rand.NextDouble() * rand.NextDouble()) * 60 * (1 - 2 * rand.Next(2)); int py = capi.World.BlockAccessor.GetRainMapHeightAt((int)px, (int)pz); Block block = capi.World.BlockAccessor.GetBlock((int)px, py, (int)pz); if (block.IsLiquid()) { continue; } tmpPos.Set((int)px, py, (int)pz); dustParticles.Color = ColorUtil.ReverseColorBytes(block.GetColor(capi, tmpPos)); dustParticles.Color |= 255 << 24; manager.Spawn(dustParticles); } } if (weatherData.PrecIntensity <= 0.02) { return(true); } if (precType == EnumPrecipitationType.Hail) { float dx = (float)(plrPos.Motion.X * 40) - 4 * weatherData.curWindSpeed.X; float dy = (float)(plrPos.Motion.Y * 40); float dz = (float)(plrPos.Motion.Z * 40); hailParticle.MinPos.Set(particlePos.X - 30 + dx, particlePos.Y + 15 + dy, particlePos.Z - 30 + dz); hailParticle.GravityEffect = 1f; hailParticle.ParticleModel = EnumParticleModel.Cube; hailParticle.LifeLength = 3f; hailParticle.MinSize = 0.3f * weatherData.PrecParticleSize; hailParticle.MaxSize = 1f * weatherData.PrecParticleSize; hailParticle.AddPos.Set(60, 5, 60); hailParticle.DieOnRainHeightmap = false; hailParticle.WithTerrainCollision = true; hailParticle.MinQuantity = 100 * plevel; hailParticle.AddQuantity = 25 * plevel; hailParticle.WindAffectednes = 0f; hailParticle.ParentVelocity = null; hailParticle.Bouncy = true; hailParticle.MinVelocity.Set(-0.025f + 7.5f * weatherData.curWindSpeed.X, -5f, -0.025f); hailParticle.AddVelocity.Set(0.05f + 7.5f * weatherData.curWindSpeed.X, 0.05f, 0.05f); manager.Spawn(hailParticle); return(true); } if (precType == EnumPrecipitationType.Rain) { float dx = (float)(plrPos.Motion.X * 80); float dy = (float)(plrPos.Motion.Y * 80); float dz = (float)(plrPos.Motion.Z * 80); rainParticle.MinPos.Set(particlePos.X - 30 + dx, particlePos.Y + 15 + dy, particlePos.Z - 30 + dz); rainParticle.WithTerrainCollision = false; rainParticle.MinQuantity = 1000 * plevel; rainParticle.LifeLength = 1f; rainParticle.AddQuantity = 25 * plevel; rainParticle.MinSize = 0.15f * weatherData.PrecParticleSize; rainParticle.MaxSize = 0.22f * weatherData.PrecParticleSize; rainParticle.MinVelocity.Set(-0.025f + 8 * weatherData.curWindSpeed.X, -10f, -0.025f); rainParticle.AddVelocity.Set(0.05f + 8 * weatherData.curWindSpeed.X, 0.05f, 0.05f); manager.Spawn(rainParticle); splashParticles.MinVelocity = new Vec3f(-1f, 3, -1f); splashParticles.AddVelocity = new Vec3f(2, 0, 2); splashParticles.LifeLength = 0.1f; splashParticles.MinSize = 0.07f * weatherData.PrecParticleSize; splashParticles.MaxSize = 0.2f * weatherData.PrecParticleSize; splashParticles.ShouldSwimOnLiquid = true; float cnt = 75 * plevel; for (int i = 0; i < cnt; i++) { double px = particlePos.X + (rand.NextDouble() * rand.NextDouble()) * 60 * (1 - 2 * rand.Next(2)); double pz = particlePos.Z + (rand.NextDouble() * rand.NextDouble()) * 60 * (1 - 2 * rand.Next(2)); int py = capi.World.BlockAccessor.GetRainMapHeightAt((int)px, (int)pz); Block block = capi.World.BlockAccessor.GetBlock((int)px, py, (int)pz); if (block.IsLiquid()) { splashParticles.MinPos.Set(px, py + block.TopMiddlePos.Y - 1 / 8f, pz); splashParticles.AddVelocity.Y = 1.5f; splashParticles.LifeLength = 0.17f; } else { splashParticles.AddVelocity.Y = 0f; splashParticles.LifeLength = 0.1f; splashParticles.MinPos.Set(px, py + block.TopMiddlePos.Y + 0.05, pz); } manager.Spawn(splashParticles); } } if (precType == EnumPrecipitationType.Snow) { float wetness = 2.5f * GameMath.Clamp(ws.clientClimateCond.Temperature + 1, 0, 4) / 4f; float dx = (float)(plrPos.Motion.X * 40) - (30 - 9 * wetness) * weatherData.curWindSpeed.X; float dy = (float)(plrPos.Motion.Y * 40); float dz = (float)(plrPos.Motion.Z * 40); snowParticle.MinVelocity.Set(-0.5f + 5 * weatherData.curWindSpeed.X, -1f, -0.5f); snowParticle.AddVelocity.Set(1f + 5 * weatherData.curWindSpeed.X, 0.05f, 1f); snowParticle.Color = ColorUtil.ToRgba(255, 255, 255, 255); snowParticle.MinQuantity = 90 * plevel * (1 + wetness / 3); snowParticle.AddQuantity = 15 * plevel * (1 + wetness / 3); snowParticle.ParentVelocity = parentVeloSnow; snowParticle.ShouldDieInLiquid = true; snowParticle.LifeLength = Math.Max(1f, 4f - wetness); snowParticle.Color = ColorUtil.ColorOverlay(ColorUtil.ToRgba(255, 255, 255, 255), rainParticle.Color, wetness / 4f); snowParticle.GravityEffect = 0.005f * (1 + 20 * wetness); snowParticle.MinSize = 0.1f * weatherData.PrecParticleSize; snowParticle.MaxSize = 0.3f * weatherData.PrecParticleSize / (1 + wetness); float hrange = 40; float vrange = 20; snowParticle.MinPos.Set(particlePos.X - hrange + dx, particlePos.Y + vrange + dy, particlePos.Z - hrange + dz); snowParticle.AddPos.Set(2 * hrange + dx, -0.66f * vrange + dy, 2 * hrange + dz); manager.Spawn(snowParticle); } return(true); }
private static bool SpawnParticleAsync(float dt, IAsyncParticleManager manager) { var weatherData = _ws.BlendedWeatherData; var conds = _ws.clientClimateCond; if (conds == null || !_ws.playerChunkLoaded) { return(true); } EntityPos plrPos = Api.World.Player.Entity.Pos; var precIntensity = conds.Rainfall; var plevel = precIntensity * Api.Settings.Int["particleLevel"] / 100f; _tmpPos.Set((int)plrPos.X, (int)plrPos.Y, (int)plrPos.Z); var precType = weatherData.BlendedPrecType; if (precType == EnumPrecipitationType.Auto) { precType = conds.Temperature < weatherData.snowThresholdTemp ? EnumPrecipitationType.Snow : EnumPrecipitationType.Rain; } _particlePos.Set(Api.World.Player.Entity.Pos.X, Api.World.Player.Entity.Pos.Y, Api.World.Player.Entity.Pos.Z); var onwaterSplashParticleColor = Api.World.ApplyColorMapOnRgba(_lblock.ClimateColorMapForMap, _lblock.SeasonColorMapForMap, ColorUtil.WhiteArgb, (int)_particlePos.X, (int)_particlePos.Y, (int)_particlePos.Z, false); var col = ColorUtil.ToBGRABytes(onwaterSplashParticleColor); onwaterSplashParticleColor = ColorUtil.ToRgba(94, col[0], col[1], col[2]); _centerPos.Set((int)_particlePos.X, 0, (int)_particlePos.Z); for (var lx = 0; lx < 16; lx++) { var dx = (lx - 8) * 4; for (var lz = 0; lz < 16; lz++) { var dz = (lz - 8) * 4; _lowResRainHeightMap[lx, lz] = Api.World.BlockAccessor.GetRainMapHeightAt(_centerPos.X + dx, _centerPos.Z + dz); } } var rainYPos = Api.World.BlockAccessor.GetRainMapHeightAt((int)_particlePos.X, (int)_particlePos.Z); _parentVeloSnow.X = -Math.Max(0, weatherData.curWindSpeed.X / 2 - 0.15f); _parentVeloSnow.Y = 0; _parentVeloSnow.Z = 0; if (weatherData.curWindSpeed.X > 0.7f && _particlePos.Y - rainYPos < 10) { var dx = (float)(plrPos.Motion.X * 40) - 50 * weatherData.curWindSpeed.X; var dy = (float)(plrPos.Motion.Y * 40); var dz = (float)(plrPos.Motion.Z * 40); _dustParticles.MinPos.Set(_particlePos.X - 40 + dx, _particlePos.Y + 15 + dy, _particlePos.Z - 40 + dz); _dustParticles.AddPos.Set(80, -20, 80); _dustParticles.GravityEffect = -0.1f - (float)_rand.NextDouble() * 0.1f; _dustParticles.ParticleModel = EnumParticleModel.Quad; _dustParticles.LifeLength = 1f; _dustParticles.DieOnRainHeightmap = true; _dustParticles.WindAffectednes = 8f; _dustParticles.MinQuantity = 0; _dustParticles.AddQuantity = 6 * (weatherData.curWindSpeed.X - 0.7f); _dustParticles.MinSize = 0.1f; _dustParticles.MaxSize = 0.4f; _dustParticles.MinVelocity.Set(-0.025f + 8 * weatherData.curWindSpeed.X, -0.2f, -0.025f); _dustParticles.AddVelocity.Set(0.05f + 4 * weatherData.curWindSpeed.X, 0.05f, 0.05f); for (var i = 0; i < 6; i++) { var px = _particlePos.X + dx + _rand.NextDouble() * _rand.NextDouble() * 60 * (1 - 2 * _rand.Next(2)); var pz = _particlePos.Z + dz + _rand.NextDouble() * _rand.NextDouble() * 60 * (1 - 2 * _rand.Next(2)); var py = Api.World.BlockAccessor.GetRainMapHeightAt((int)px, (int)pz); var block = Api.World.BlockAccessor.GetBlock((int)px, py, (int)pz); if (block.IsLiquid()) { continue; } _tmpPos.Set((int)px, py, (int)pz); _dustParticles.Color = ColorUtil.ReverseColorBytes(block.GetColor(Api, _tmpPos)); _dustParticles.Color |= 255 << 24; manager.Spawn(_dustParticles); } } if (precIntensity <= 0.02) { return(true); } if (Settings.AllowHail && precType == EnumPrecipitationType.Hail) { var dx = (float)(plrPos.Motion.X * 40) - 4 * weatherData.curWindSpeed.X; var dy = (float)(plrPos.Motion.Y * 40); var dz = (float)(plrPos.Motion.Z * 40); _hailParticle.MinPos.Set(_particlePos.X + dx, _particlePos.Y + 15 + dy, _particlePos.Z + dz); _hailParticle.MinSize = 0.3f * (0.5f + conds.Rainfall); _hailParticle.MaxSize = 1f * (0.5f + conds.Rainfall); _hailParticle.Color = ColorUtil.ToRgba(220, 210, 230, 255); _hailParticle.MinQuantity = 100 * plevel; _hailParticle.AddQuantity = 25 * plevel; _hailParticle.MinVelocity.Set(-0.025f + 7.5f * weatherData.curWindSpeed.X, -5f, -0.025f); _hailParticle.AddVelocity.Set(0.05f + 7.5f * weatherData.curWindSpeed.X, 0.05f, 0.05f); manager.Spawn(_hailParticle); return(true); } if (Settings.AllowRain && precType == EnumPrecipitationType.Rain) { var dx = (float)(plrPos.Motion.X * 80); var dy = (float)(plrPos.Motion.Y * 80); var dz = (float)(plrPos.Motion.Z * 80); _rainParticle.MinPos.Set(_particlePos.X - 30 + dx, _particlePos.Y + 15 + dy, _particlePos.Z - 30 + dz); _rainParticle.WithTerrainCollision = false; _rainParticle.MinQuantity = 1000 * plevel; _rainParticle.LifeLength = 1f; _rainParticle.AddQuantity = 25 * plevel; _rainParticle.MinSize = 0.15f * (0.5f + conds.Rainfall); _rainParticle.MaxSize = 0.22f * (0.5f + conds.Rainfall); _rainParticle.Color = _rainParticleColor; _rainParticle.MinVelocity.Set(-0.025f + 8 * weatherData.curWindSpeed.X, -10f, -0.025f); _rainParticle.AddVelocity.Set(0.05f + 8 * weatherData.curWindSpeed.X, 0.05f, 0.05f); manager.Spawn(_rainParticle); _splashParticles.MinVelocity = new Vec3f(-1f, 3, -1f); _splashParticles.AddVelocity = new Vec3f(2, 0, 2); _splashParticles.LifeLength = 0.1f; _splashParticles.MinSize = 0.07f * (0.5f + 0.65f * conds.Rainfall); _splashParticles.MaxSize = 0.2f * (0.5f + 0.65f * conds.Rainfall); _splashParticles.ShouldSwimOnLiquid = true; _splashParticles.Color = _rainParticleColor; var cnt = 100 * plevel; for (var i = 0; i < cnt; i++) { var px = _particlePos.X + _rand.NextDouble() * _rand.NextDouble() * 60 * (1 - 2 * _rand.Next(2)); var pz = _particlePos.Z + _rand.NextDouble() * _rand.NextDouble() * 60 * (1 - 2 * _rand.Next(2)); var py = Api.World.BlockAccessor.GetRainMapHeightAt((int)px, (int)pz); var block = Api.World.BlockAccessor.GetBlock((int)px, py, (int)pz); if (block.IsLiquid()) { _splashParticles.MinPos.Set(px, py + block.TopMiddlePos.Y - 1 / 8f, pz); _splashParticles.AddVelocity.Y = 1.5f; _splashParticles.LifeLength = 0.17f; _splashParticles.Color = onwaterSplashParticleColor; } else { var b = 0.75 + 0.25 * _rand.NextDouble(); var ca = 230 - _rand.Next(100); var cr = (int)(((_rainParticleColor >> 16) & 0xff) * b); var cg = (int)(((_rainParticleColor >> 8) & 0xff) * b); var cb = (int)(((_rainParticleColor >> 0) & 0xff) * b); _splashParticles.Color = (ca << 24) | (cr << 16) | (cg << 8) | cb; _splashParticles.AddVelocity.Y = 0f; _splashParticles.LifeLength = 0.1f; _splashParticles.MinPos.Set(px, py + block.TopMiddlePos.Y + 0.05, pz); } manager.Spawn(_splashParticles); } } if (Settings.AllowSnow && precType == EnumPrecipitationType.Snow) { var wetness = 2.5f * GameMath.Clamp(_ws.clientClimateCond.Temperature + 1, 0, 4) / 4f; var dx = (float)(plrPos.Motion.X * 40) - (30 - 9 * wetness) * weatherData.curWindSpeed.X; var dy = (float)(plrPos.Motion.Y * 40); var dz = (float)(plrPos.Motion.Z * 40); _snowParticle.MinVelocity.Set(-0.5f + 5 * weatherData.curWindSpeed.X, -1f, -0.5f); _snowParticle.AddVelocity.Set(1f + 5 * weatherData.curWindSpeed.X, 0.05f, 1f); _snowParticle.Color = ColorUtil.ToRgba(255, 255, 255, 255); _snowParticle.MinQuantity = 90 * plevel * (1 + wetness / 3); _snowParticle.AddQuantity = 15 * plevel * (1 + wetness / 3); _snowParticle.ParentVelocity = _parentVeloSnow; _snowParticle.ShouldDieInLiquid = true; _snowParticle.LifeLength = Math.Max(1f, 4f - wetness); _snowParticle.Color = ColorUtil.ColorOverlay(ColorUtil.ToRgba(255, 255, 255, 255), _rainParticle.Color, wetness / 4f); _snowParticle.GravityEffect = 0.005f * (1 + 20 * wetness); _snowParticle.MinSize = 0.1f * conds.Rainfall; _snowParticle.MaxSize = 0.3f * conds.Rainfall / (1 + wetness); const float hrange = 40f; const float vrange = 20f; _snowParticle.MinPos.Set(_particlePos.X - hrange + dx, _particlePos.Y + vrange + dy, _particlePos.Z - hrange + dz); _snowParticle.AddPos.Set(2 * hrange + dx, -0.66f * vrange + dy, 2 * hrange + dz); manager.Spawn(_snowParticle); } return(true); }