public override void OnGameTick(float dt) { if (World.Side == EnumAppSide.Server) { base.OnGameTick(dt); return; } if (!AnimManager.ActiveAnimationsByAnimCode.ContainsKey("feed")) { if (ServerPos.Y < Pos.Y - 0.25 && !Collided) { SetAnimation("glide", 1); } else { SetAnimation("fly", 2); } } base.OnGameTick(dt); if (ServerPos.SquareDistanceTo(Pos.XYZ) > 0.01) { float desiredYaw = (float)Math.Atan2(ServerPos.X - Pos.X, ServerPos.Z - Pos.Z); float yawDist = GameMath.AngleRadDistance(LocalPos.Yaw, desiredYaw); Pos.Yaw += GameMath.Clamp(yawDist, -35 * dt, 35 * dt); Pos.Yaw = Pos.Yaw % GameMath.TWOPI; } }
public override void OnGameTick(float dt) { if (World.Side == EnumAppSide.Server) { base.OnGameTick(dt); return; } if (!AnimManager.ActiveAnimationsByAnimCode.ContainsKey("feed") && !AnimManager.ActiveAnimationsByAnimCode.ContainsKey("rest")) { if (ServerPos.Y < Pos.Y - 0.05 && !Collided) { SetAnimation("glide", 1); } if ((ServerPos.Y > Pos.Y - 0.02 || Collided) && !FeetInLiquid) { SetAnimation("fly", 2.5f); } if (FeetInLiquid) { (Properties.Client.Renderer as EntityShapeRenderer).AddRenderFlags |= 1 << 12; } else { (Properties.Client.Renderer as EntityShapeRenderer).AddRenderFlags &= ~(1 << 12); } if (FeetInLiquid && flapPauseDt <= 0 && Api.World.Rand.NextDouble() < 0.07) { flapPauseDt = 2 + 6 * (float)Api.World.Rand.NextDouble(); StopAnimation("fly"); } if (flapPauseDt > 0) { flapPauseDt -= dt; if (flapPauseDt <= 0) { SetAnimation("fly", 2.5f); } } else { if (FeetInLiquid) { EntityPos herepos = Pos; double width = SelectionBox.XSize * 0.75f; SplashParticleProps.BasePos.Set(herepos.X - width / 2, herepos.Y - 0.05, herepos.Z - width / 2); SplashParticleProps.AddPos.Set(width, 0, width); SplashParticleProps.AddVelocity.Set(0, 0, 0); SplashParticleProps.QuantityMul = 0.01f; World.SpawnParticles(SplashParticleProps); SpawnWaterMovementParticles(1, 0, +0.05, 0); } } } base.OnGameTick(dt); if (cnt++ > 30) { float affectedness = World.BlockAccessor.GetLightLevel(SidedPos.XYZ.AsBlockPos, EnumLightLevelType.OnlySunLight) < 14 ? 1 : 0; windMotion = Api.ModLoader.GetModSystem <WeatherSystemBase>().WeatherDataSlowAccess.GetWindSpeed(SidedPos.XYZ) * affectedness; cnt = 0; } if (AnimManager.ActiveAnimationsByAnimCode.ContainsKey("fly")) { SidedPos.X += Math.Max(0, (windMotion - 0.2) / 20.0); } if (ServerPos.SquareDistanceTo(Pos.XYZ) > 0.01 && !FeetInLiquid) { float desiredYaw = (float)Math.Atan2(ServerPos.X - Pos.X, ServerPos.Z - Pos.Z); float yawDist = GameMath.AngleRadDistance(SidedPos.Yaw, desiredYaw); Pos.Yaw += GameMath.Clamp(yawDist, -35 * dt, 35 * dt); Pos.Yaw = Pos.Yaw % GameMath.TWOPI; } }