public override void Tick() { // Update the radar animation even when its closed // This avoids obviously stale data from being shown when first opened. // TODO: This delayed updating is a giant hack --updateTicks; if (updateTicks <= 0) { updateTicks = 12; customTerrainSprite.sheet.Texture.SetData(Minimap.CustomTerrainBitmap(world)); } if (updateTicks == 8) { actorSprite.sheet.Texture.SetData(Minimap.ActorsBitmap(world)); } if (updateTicks == 4) { shroudSprite.sheet.Texture.SetData(Minimap.ShroudBitmap(world)); } // Enable/Disable the radar var enabled = IsEnabled(); if (enabled != cachedEnabled) { Sound.Play(enabled ? RadarOnlineSound : RadarOfflineSound); } cachedEnabled = enabled; var targetFrame = enabled ? AnimationLength : 0; hasRadar = enabled && frame == AnimationLength; if (frame == targetFrame) { return; } frame += enabled ? 1 : -1; radarMinimapHeight = float2.Lerp(0, 1, (float)frame / AnimationLength); // Update map rectangle for event handling var ro = RenderOrigin; mapRect = new Rectangle(previewOrigin.X + ro.X, previewOrigin.Y + ro.Y, mapRect.Width, mapRect.Height); // Animation is complete if (frame == targetFrame) { if (enabled) { AfterOpen(); } else { AfterClose(); } } }
public override void Tick() { var hasRadarNew = world.LocalPlayer == null || world.LocalPlayer.WinState != WinState.Undefined || world.ActorsWithTrait <ProvidesRadar>().Any(a => a.Actor.Owner == world.LocalPlayer && a.Trait.IsActive); if (hasRadarNew != hasRadar) { animating = true; Sound.Play(hasRadarNew ? RadarOnlineSound : RadarOfflineSound); } hasRadar = hasRadarNew; // Build the radar image if (hasRadar) { --updateTicks; if (updateTicks <= 0) { updateTicks = 12; customTerrainSprite.sheet.Texture.SetData(Minimap.CustomTerrainBitmap(world)); } if (updateTicks == 8) { actorSprite.sheet.Texture.SetData(Minimap.ActorsBitmap(world)); } if (updateTicks == 4) { shroudSprite.sheet.Texture.SetData(Minimap.ShroudBitmap(world)); } } if (!animating) { return; } // Increment frame if (hasRadar) { AnimationFrame++; } else { AnimationFrame--; } // Minimap height radarMinimapHeight = float2.Lerp(0, 1, AnimationFrame * 1.0f / AnimationLength); // Animation is complete if (AnimationFrame == (hasRadar ? AnimationLength : 0)) { animating = false; } }
public override void Tick() { var hasRadarNew = world .ActorsWithTrait <ProvidesRadar>() .Any(a => a.Actor.Owner == world.LocalPlayer && a.Trait.IsActive); if (hasRadarNew != hasRadar) { radarAnimating = true; var eva = Rules.Info["world"].Traits.Get <EvaAlertsInfo>(); Sound.Play(hasRadarNew ? eva.RadarUp : eva.RadarDown); } hasRadar = hasRadarNew; // Build the radar image if (hasRadar) { --updateTicks; if (updateTicks <= 0) { updateTicks = 12; customTerrainSprite.sheet.Texture.SetData(Minimap.CustomTerrainBitmap(world)); } if (updateTicks == 8) { actorSprite.sheet.Texture.SetData(Minimap.ActorsBitmap(world)); } if (updateTicks == 4) { shroudSprite.sheet.Texture.SetData(Minimap.ShroudBitmap(world)); } } if (!radarAnimating) { return; } // Increment frame if (hasRadar) { radarAnimationFrame++; } else { radarAnimationFrame--; } // Calculate radar bin position if (radarAnimationFrame <= radarSlideAnimationLength) { radarOrigin = float2.Lerp(radarClosedOrigin, radarOpenOrigin, radarAnimationFrame * 1.0f / radarSlideAnimationLength); } // Minimap height if (radarAnimationFrame >= radarSlideAnimationLength) { radarMinimapHeight = float2.Lerp(0, 1, (radarAnimationFrame - radarSlideAnimationLength) * 1.0f / radarActivateAnimationLength); } // Animation is complete if (radarAnimationFrame == (hasRadar ? radarSlideAnimationLength + radarActivateAnimationLength : 0)) { radarAnimating = false; } }