public void CheckSurroundings(GameComponent Body, DwarfTime gameTime, ChunkManager chunks) { if (Heat > Flashpoint) { var insideBodies = World.EnumerateIntersectingObjects(Body.GetBoundingBox()); foreach (var body in insideBodies.Where(b => b != Parent && b.Active && b.Parent == Manager.RootComponent)) { var flames = body.GetComponent <Flammable>(); if (flames != null) { flames.Heat += 100; } } SoundManager.PlaySound(ContentPaths.Audio.fire, Body.Position, true); } float expansion = Heat > Flashpoint ? 1.0f : 0.0f; foreach (var coordinate in VoxelHelpers.EnumerateCoordinatesInBoundingBox(Body.BoundingBox.Expand(expansion))) { var voxel = new VoxelHandle(chunks, coordinate); if (!voxel.IsValid) { continue; } if (Heat > Flashpoint && MathFunctions.RandEvent(0.5f)) { if (voxel.Type.IsFlammable) { if (MathFunctions.RandEvent(0.1f)) { var existingItems = World.EnumerateIntersectingObjects(voxel.GetBoundingBox().Expand(-0.1f)); if (!existingItems.Any(e => e is Fire)) { EntityFactory.CreateEntity <Fire>("Fire", voxel.GetBoundingBox().Center()); } SoundManager.PlaySound(ContentPaths.Audio.Oscar.sfx_env_lava_spread, voxel.GetBoundingBox().Center(), true, 1.0f); VoxelHelpers.KillVoxel(World, voxel); } } if (voxel.GrassType != 0x0) { if (MathFunctions.RandEvent(0.1f)) { var box = voxel.GetBoundingBox().Expand(-0.1f); box.Min += Vector3.One; // Todo: Why shifting one on every axis? box.Max += Vector3.One; if (!World.EnumerateIntersectingObjects(box).Any(e => e is Fire)) { EntityFactory.CreateEntity <Fire>("Fire", box.Center()); } } if (MathFunctions.RandEvent(0.5f)) { SoundManager.PlaySound(ContentPaths.Audio.Oscar.sfx_env_lava_spread, voxel.GetBoundingBox().Center(), true, 1.0f); voxel.GrassType = 0x0; } } } if (voxel.LiquidLevel <= 0) { continue; } if (voxel.LiquidType == LiquidType.Lava) { Heat += 100.0f; } else if (voxel.LiquidType == LiquidType.Water) { Heat = Heat * 0.25f; } } }
public override void Construct() { Border = "border-one"; Font = "font10"; OnConstruct = (sender) => { sender.Root.RegisterForUpdate(sender); AddChild(new Widget { AutoLayout = AutoLayout.DockBottom, MinimumSize = new Point(0, 32), Text = "CLOSE", ChangeColorOnHover = true, OnClick = (sender1, args) => sender.Close() }); ComponentProperties = AddChild(new Widget { AutoLayout = AutoLayout.DockBottom, MinimumSize = new Point(0, 128), }); ListView = AddChild(new WidgetListView { AutoLayout = AutoLayout.DockFill, SelectedItemForegroundColor = new Vector4(0, 0, 0, 1), ChangeColorOnSelected = false, Border = null, ItemHeight = 24 }) as WidgetListView; ListView.Border = null; // Can't make WidgetListView stop defaulting its border without breaking everywhere else its used. }; OnUpdate = (sender, time) => { if (sender.Hidden) { return; } if (SelectedEntity == null) { SelectedComponent = null; ListView.ClearItems(); return; } var components = SelectedEntity.EnumerateAll(); int i = 0; ListView.ClearItems(); foreach (var component in components) { i++; var tag = component.GuiTag as Widget; var lambdaCopy = component; if (tag != null) { ListView.AddItem(tag); } else { #region Create gui row tag = Root.ConstructWidget(new Widget { Text = component.GetType().Name, MinimumSize = new Point(0, 16), Padding = new Margin(0, 0, 4, 4), TextVerticalAlign = VerticalAlign.Center, Tag = lambdaCopy }); tag.OnClick = (sender1, args) => { if (tag.IsAnyParentHidden()) { return; } SelectedComponent = lambdaCopy; }; #endregion component.GuiTag = tag; ListView.AddItem(tag); } } ListView.Invalidate(); if (SelectedComponent != null) { Drawer3D.DrawBox(SelectedComponent.GetBoundingBox(), Color.White, 0.1f, true); ComponentProperties.Text = SelectedComponent.GetType().Name + "\n" + SelectedComponent.Position.ToString() + "\nBB Extents: " + SelectedComponent.BoundingBoxSize.ToString() + "\nBB Offset: " + SelectedComponent.LocalBoundingBoxOffset.ToString(); } else { ComponentProperties.Text = ""; } }; base.Construct(); }