private static void doRemove(IVoxelHandle voxel, Town clickedTown) { if (clickedTown == null) { return; } if (clickedTown.CanRemove(voxel.GetInternalVoxel())) { clickedTown.RemoveVoxel(voxel.GetInternalVoxel()); voxel.MarkChanged(); voxel.Get8Connected().ForEach(v => v.MarkChanged()); } }
private static void randomizeColor(IVoxelHandle handle) { if (handle.Seeder.NextFloat(0, 100) > 1) { return; } var c = handle.Seeder.NextInt(1, 4); if (handle.Data.DataValue == c) { return; } handle.Data.DataValue = handle.Seeder.NextInt(1, 4); handle.GetInternalVoxel().World.NotifyVoxelChanged(handle.GetInternalVoxel()); // Cheat! }
public override void Tick(IVoxelHandle handle) { if (handle.GetInternalVoxel().GetPart <Ore>().IsDepleted()) { handle.ChangeType(Land); } }
public RangeVisualizer(IVoxelHandle handle, int range) { // WARNING: cannot keep handle because it can be shared across voxels!! // IDEA: should autoconvert between the gameplay voxel type and the rendering voxel type this.handle = handle.GetInternalVoxel(); this.range = range; }
public HighlightVoxelsVisualizer(IVoxelHandle handle, Func <IVoxelHandle, IEnumerable <IVoxelHandle> > getHighlights) { this.getHighlights = getHighlights; // WARNING: cannot keep handle because it can be shared across voxels!! // IDEA: should autoconvert between the gameplay voxel type and the rendering voxel type this.handle = handle.GetInternalVoxel(); }
public InventoryVisualizer(IVoxelHandle handle) { // WARNING: cannot keep handle because it can be shared across voxels!! // IDEA: should autoconvert between the gameplay voxel type and the rendering voxel type this.handle = handle.GetInternalVoxel(); ItemRelativeTransformationProvider = i => getItemCircleTransformation(i, this.handle, 1); }
public ValueControlVisualizer(IVoxelHandle handle, Func <int> getValue, Action <int> setValue, Matrix local) { this.getValue = getValue; this.setValue = setValue; this.local = local; ValueControl = new ValueControl(); voxel = handle.GetInternalVoxel(); }
public override System.Collections.Generic.IEnumerable <IRenderable> GetCustomVisualizers(IVoxelHandle handle) { var inv = new InventoryVisualizer(handle); inv.ItemRelativeTransformationProvider = i => { return(InventoryVisualizer.getItemCircleTransformation(i, handle.GetInternalVoxel(), 0.25f)); }; yield return(inv); }
/// <summary> /// Takes an item from source, and moves it to the given destination. The item enters the road at given startRoad /// </summary> public void DeliverItem(IVoxelHandle startRoad, IVoxelHandle sourceInventory, IVoxelHandle targetInventory, ItemType type) { if (!FindConnectedVoxels(startRoad, v => v.Equals(targetInventory)).Any()) { throw new InvalidOperationException("Target is not connected to given startRoad"); } sourceInventory.Data.Inventory.TransferItemsTo(startRoad.Data.Inventory, type, 1); sourceInventory.Data.Inventory.AddNewItems(itemTypesFactory.GetOutgoingKanban(type), 1); targetInventory.Data.Inventory.AddNewItems(itemTypesFactory.GetIncomingKanban(type), 1); startRoad.Data.Road.Items.Add(new TargetedItem(sourceInventory.GetInternalVoxel(), type, targetInventory.GetInternalVoxel())); }
public override void OnTargetChanged(IVoxelHandle voxel, TWKeyboard keyboard, TWMouse mouse) { var clickedTown = townCenterService.GetTownForVoxel(voxel.GetInternalVoxel()); if (mouse.LeftMousePressed) { doRemove(voxel, clickedTown); } else if (mouse.RightMousePressed) { doAdd(voxel, clickedTown); } }
public override void OnRightClick(PlayerState player, IVoxelHandle voxel) { int radius = 3; if (prevVoxel != null) { prevVoxel.GetRangeCircle(radius).ForEach(v => v.Data.MagicLevel = 0); } var handle = voxel; handle.GetRangeCircle(radius).Where(v => v.Type is InfestationVoxelType).ForEach(removeInfestation); prevVoxel = voxel.GetInternalVoxel(); }
public string GetDebugDescription(IVoxelHandle handle) { var ret = ""; ret += "Type: " + Name + "\n"; ret += getDebugDescription(handle) + "\n"; var voxelAddons = addons.Values.Where(v => v.Instances.ContainsKey(handle.GetInternalVoxel())).Select(v => v.Instances[handle.GetInternalVoxel()]).ToArray(); if (voxelAddons.Length > 0) { foreach (var addon in voxelAddons) { ret += "Addon: " + addon.GetType().Name + "\n"; ret += addon.GetDebugDescription() + "\n"; } } return(ret); }
public float DistanceTo(IVoxelHandle handle) { return(handle.GetInternalVoxel().GetOffset(handle.GetInternalVoxel()).GetLength()); }
public override IEnumerable <IRenderable> GetCustomVisualizers(IVoxelHandle handle) { return(getOrCreateMonument(handle.GetInternalVoxel()).GetCustomVisualizers()); }
public IWorkerProducer GetWorkerProducer(IVoxelHandle handle) { return(producers[handle.GetInternalVoxel()]); }
public WorkerCountVisualizer(IVoxelHandle handle, int maxWorkersNeeded) { this.handle = handle; this.maxWorkersNeeded = maxWorkersNeeded; translation = Matrix.Translation(new Vector3(0, 1, 0) + handle.GetInternalVoxel().GetBoundingBox().Minimum); }
public override void OnLeftClick(IVoxelHandle voxel) { doRemove(voxel, townCenterService.GetTownForVoxel(voxel.GetInternalVoxel())); }
private List <IVoxelHandle> GetVoxelsInRange(IVoxelHandle centerVoxel) { return(world.GetRange(centerVoxel.GetInternalVoxel(), Size).Cast <IVoxelHandle>().ToList()); }
private float yDiff(IVoxelHandle h1, IVoxelHandle h2) { return(Math.Abs(h1.GetInternalVoxel().Coord.Y - h2.GetInternalVoxel().Coord.Y)); }
public void SendMonumentRangeInput(IVoxelHandle monumentVoxel, int value) { pendingMonumentInputs.Add(new NumberInput(monumentVoxel.GetInternalVoxel().Coord, value)); }
private void tryAdd(IVoxelHandle voxel, Town town) { TryAddBorder(voxel.GetInternalVoxel(), town); }
public override void OnRightClick(IVoxelHandle voxel) { doAdd(voxel, townCenterService.GetTownForVoxel(voxel.GetInternalVoxel())); }