Esempio n. 1
0
        public override void OnVoxelsSelected(SpellTree tree, List <VoxelHandle> voxels)
        {
            bool placed = false;

            foreach (var selected in voxels)
            {
                if (selected.IsValid && ((!Transmute && selected.IsEmpty) || Transmute && !selected.IsEmpty) && OnCast(tree))
                {
                    Vector3 p = selected.WorldPosition + Vector3.One * 0.5f;
                    IndicatorManager.DrawIndicator("-" + ManaCost + " M", p, 1.0f, GameSettings.Default.Colors.GetColor("Negative", Color.Red));
                    World.ParticleManager.Trigger("star_particle", p, Color.White, 4);
                    var lSelected = selected;
                    lSelected.Type = VoxelLibrary.GetVoxelType(VoxelType);
                    lSelected.QuickSetLiquid(LiquidType.None, 0);

                    if (VoxelType == "Magic")
                    {
                        World.ComponentManager.RootComponent.AddChild(new DestroyOnTimer(World.ComponentManager, World.ChunkManager, selected)
                        {
                            DestroyTimer = new Timer(5.0f + MathFunctions.Rand(-0.5f, 0.5f), true)
                        });
                    }
                    placed = true;
                }
            }

            if (placed)
            {
                SoundManager.PlaySound(ContentPaths.Audio.tinkle, World.CursorLightPos, true, 1.0f);
            }

            RechargeTimer.Reset(RechargeTimer.TargetTimeSeconds);
            base.OnVoxelsSelected(tree, voxels);
        }
Esempio n. 2
0
        public override void OnVoxelsSelected(SpellTree tree, List <Voxel> voxels)
        {
            HashSet <Point3> chunksToRebuild = new HashSet <Point3>();
            bool             placed          = false;

            foreach (Voxel selected in voxels)
            {
                if (selected != null && ((!Transmute && selected.IsEmpty) || Transmute && !selected.IsEmpty) && OnCast(tree))
                {
                    Vector3 p = selected.Position + Vector3.One * 0.5f;
                    IndicatorManager.DrawIndicator("-" + ManaCost + " M", p, 1.0f, Color.Red);
                    World.ParticleManager.Trigger("star_particle", p, Color.White, 4);
                    VoxelLibrary.PlaceType(VoxelLibrary.GetVoxelType(VoxelType), selected);

                    if (VoxelType == "Magic")
                    {
                        new VoxelListener(World.ComponentManager, World.ComponentManager.RootComponent, World.ChunkManager, selected)
                        {
                            DestroyOnTimer = true,
                            DestroyTimer   = new Timer(5.0f + MathFunctions.Rand(-0.5f, 0.5f), true)
                        };
                    }
                    placed = true;
                    chunksToRebuild.Add(selected.ChunkID);
                }
            }

            foreach (Point3 point in chunksToRebuild)
            {
                VoxelChunk chunk = World.ChunkManager.ChunkData.ChunkMap[point];
                chunk.ShouldRebuild = true;
                chunk.NotifyTotalRebuild(true);
            }

            if (placed)
            {
                SoundManager.PlaySound(ContentPaths.Audio.tinkle, World.CursorLightPos, true, 1.0f);
            }

            RechargeTimer.Reset(RechargeTimer.TargetTimeSeconds);
            base.OnVoxelsSelected(tree, voxels);
        }