public override bool OnUse(Ray3 ray, ComponentMiner componentMiner) { TerrainRaycastResult?terrainRaycastResult = componentMiner.Raycast <TerrainRaycastResult>(ray, RaycastMode.Interaction); if (terrainRaycastResult.HasValue && terrainRaycastResult.Value.CellFace.Face == 4) { int y = terrainRaycastResult.Value.CellFace.Y; for (int i = terrainRaycastResult.Value.CellFace.X - 1; i <= terrainRaycastResult.Value.CellFace.X + 1; i++) { for (int j = terrainRaycastResult.Value.CellFace.Z - 1; j <= terrainRaycastResult.Value.CellFace.Z + 1; j++) { int cellValue = m_subsystemTerrain.Terrain.GetCellValue(i, y, j); if (Terrain.ExtractContents(cellValue) == 168) { int data = SoilBlock.SetNitrogen(Terrain.ExtractData(cellValue), 3); int value = Terrain.ReplaceData(cellValue, data); m_subsystemTerrain.ChangeCell(i, y, j, value); } } } m_subsystemAudio.PlayRandomSound("Audio/Impacts/Dirt", 0.5f, 0f, new Vector3(terrainRaycastResult.Value.CellFace.X, terrainRaycastResult.Value.CellFace.Y, terrainRaycastResult.Value.CellFace.Z), 3f, autoDelay: true); Vector3 position = new Vector3((float)terrainRaycastResult.Value.CellFace.X + 0.5f, (float)terrainRaycastResult.Value.CellFace.Y + 1.5f, (float)terrainRaycastResult.Value.CellFace.Z + 0.5f); Block block = BlocksManager.Blocks[Terrain.ExtractContents(componentMiner.ActiveBlockValue)]; m_subsystemParticles.AddParticleSystem(block.CreateDebrisParticleSystem(m_subsystemTerrain, position, componentMiner.ActiveBlockValue, 1.25f)); componentMiner.RemoveActiveTool(1); return(true); } return(false); }
public static int GetDirectionXZ(ComponentMiner componentMiner) { Vector3 forward = componentMiner.ComponentCreature.ComponentCreatureModel.EyeRotation.ToForwardVector(); float num = Vector3.Dot(forward, Vector3.UnitZ); float num2 = Vector3.Dot(forward, Vector3.UnitX); float num3 = Vector3.Dot(forward, -Vector3.UnitZ); float num4 = Vector3.Dot(forward, -Vector3.UnitX); float max = MathUtils.Max(num, num2, num3, num4); if (num == max) { return(2); } if (num2 == max) { return(3); } if (num3 == max) { return(0); } if (num4 == max) { return(1); } return(0); }
public override void Load(ValuesDictionary valuesDictionary, IdToEntityMap idToEntityMap) { m_subsystemTerrain = base.Project.FindSubsystem <SubsystemTerrain>(throwOnError: true); m_componentPlayer = base.Entity.FindComponent <ComponentPlayer>(throwOnError: true); m_componentMiner = base.Entity.FindComponent <ComponentMiner>(throwOnError: true); m_vrHandModel = ContentManager.Get <Model>(valuesDictionary.GetValue <string>("VrHandModelName")); }
public override bool OnInteract(TerrainRaycastResult raycastResult, ComponentMiner componentMiner) { var blockEntity = Utils.GetBlockEntity(raycastResult.CellFace.Point); if (blockEntity == null || componentMiner.ComponentPlayer == null) { return(false); } switch (Terrain.ExtractContents(raycastResult.Value)) { case BlastFurnaceBlock.Index: componentMiner.ComponentPlayer.ComponentGui.ModalPanelWidget = new BlastFurnaceWidget(componentMiner.Inventory, blockEntity.Entity.FindComponent <ComponentBlastFurnace>(true)); break; case CovenBlock.Index: componentMiner.ComponentPlayer.ComponentGui.ModalPanelWidget = new CovenWidget(componentMiner.Inventory, blockEntity.Entity.FindComponent <ComponentCoven>(true)); break; case HearthFurnaceBlock.Index: componentMiner.ComponentPlayer.ComponentGui.ModalPanelWidget = new CovenWidget(componentMiner.Inventory, blockEntity.Entity.FindComponent <ComponentHearthFurnace>(true), "Widgets/HearthFurnaceWidget"); break; case TankBlock.Index: if (TankBlock.GetType(raycastResult.Value) == TankBlock.Type.FractionatingTower) { componentMiner.ComponentPlayer.ComponentGui.ModalPanelWidget = new FractionalTowerWidget(componentMiner.Inventory, blockEntity.Entity.FindComponent <ComponentFractionalTower>(true)); break; } return(false); default: return(false); } AudioManager.PlaySound("Audio/UI/ButtonClick", 1f, 0f, 0f); return(true); }
public override bool OnUse(Ray3 ray, ComponentMiner componentMiner) { _ = componentMiner.Inventory; if (Terrain.ExtractContents(componentMiner.ActiveBlockValue) == 178) { TerrainRaycastResult?terrainRaycastResult = componentMiner.Raycast <TerrainRaycastResult>(ray, RaycastMode.Digging); if (terrainRaycastResult.HasValue) { Vector3 position = terrainRaycastResult.Value.HitPoint(); DynamicArray <ComponentBody> dynamicArray = new DynamicArray <ComponentBody>(); m_subsystemBodies.FindBodiesInArea(new Vector2(position.X, position.Z) - new Vector2(8f), new Vector2(position.X, position.Z) + new Vector2(8f), dynamicArray); if (dynamicArray.Count((ComponentBody b) => b.Entity.ValuesDictionary.DatabaseObject.Name == "Boat") < 6) { Entity entity = DatabaseManager.CreateEntity(base.Project, "Boat", throwIfNotFound: true); entity.FindComponent <ComponentFrame>(throwOnError: true).Position = position; entity.FindComponent <ComponentFrame>(throwOnError: true).Rotation = Quaternion.CreateFromAxisAngle(Vector3.UnitY, m_random.Float(0f, (float)Math.PI * 2f)); entity.FindComponent <ComponentSpawn>(throwOnError: true).SpawnDuration = 0f; base.Project.AddEntity(entity); componentMiner.RemoveActiveTool(1); m_subsystemAudio.PlaySound("Audio/BlockPlaced", 1f, 0f, position, 3f, autoDelay: true); } else { componentMiner.ComponentPlayer?.ComponentGui.DisplaySmallMessage(LanguageControl.Get(fName, 1), Color.White, blinking: true, playNotificationSound: false); } return(true); } } return(false); }
public override bool OnUse(Engine.Vector3 start, Engine.Vector3 direction, ComponentMiner componentMiner) { var bodyResult = componentMiner.PickBody(start, direction); if (bodyResult.HasValue) { var creature = bodyResult.Value.ComponentBody.Entity.FindComponent <ComponentCreature>(); if (creature != null) { string name = creature.DisplayName.Replace(' ', '_').ToLower(); ClipboardManager.ClipboardString = name; componentMiner.ComponentPlayer.ComponentGui.DisplaySmallMessage(name + "is copied to the clipboard", false, false); return(false); } } var terrainResult = componentMiner.PickTerrainForDigging(start, direction); if (terrainResult.HasValue) { var val = terrainResult.Value.Value.ToString(); ClipboardManager.ClipboardString = val; componentMiner.ComponentPlayer.ComponentGui.DisplaySmallMessage(val + "is copied to the clipboard", false, false); } return(false); }
public override bool OnUse(Ray3 ray, ComponentMiner componentMiner) { BodyRaycastResult?bodyRaycastResult = componentMiner.Raycast <BodyRaycastResult>(ray, RaycastMode.Interaction); if (bodyRaycastResult.HasValue) { ComponentHealth componentHealth = bodyRaycastResult.Value.ComponentBody.Entity.FindComponent <ComponentHealth>(); if (componentHealth == null || componentHealth.Health > 0f) { string entityTemplateName = bodyRaycastResult.Value.ComponentBody.Entity.ValuesDictionary.DatabaseObject.Name + "_Saddled"; Entity entity = DatabaseManager.CreateEntity(base.Project, entityTemplateName, throwIfNotFound: false); if (entity != null) { ComponentBody componentBody = entity.FindComponent <ComponentBody>(throwOnError: true); componentBody.Position = bodyRaycastResult.Value.ComponentBody.Position; componentBody.Rotation = bodyRaycastResult.Value.ComponentBody.Rotation; componentBody.Velocity = bodyRaycastResult.Value.ComponentBody.Velocity; entity.FindComponent <ComponentSpawn>(throwOnError: true).SpawnDuration = 0f; base.Project.RemoveEntity(bodyRaycastResult.Value.ComponentBody.Entity, disposeEntity: true); base.Project.AddEntity(entity); m_subsystemAudio.PlaySound("Audio/BlockPlaced", 1f, m_random.Float(-0.1f, 0.1f), ray.Position, 1f, autoDelay: true); componentMiner.RemoveActiveTool(1); } } return(true); } return(false); }
public override bool OnInteract(TerrainRaycastResult raycastResult, ComponentMiner componentMiner) { if (AddFuel(raycastResult.CellFace.X, raycastResult.CellFace.Y, raycastResult.CellFace.Z, componentMiner.ActiveBlockValue, 1)) { componentMiner.RemoveActiveTool(1); } return(true); }
public static BlockPlacementData GetPlacementValue(int index, ComponentMiner componentMiner, int value, TerrainRaycastResult raycastResult) { return(new BlockPlacementData { Value = Terrain.ReplaceData(value, Terrain.ExtractData(value) & -229377 | Utils.GetDirectionXZ(componentMiner) << 15 | index), CellFace = raycastResult.CellFace }); }
public override bool OnInteract(TerrainRaycastResult raycastResult, ComponentMiner componentMiner) { if (base.OnInteract(raycastResult, componentMiner) && Terrain.ExtractData(Utils.Terrain.GetCellValueFast(raycastResult.CellFace.X, raycastResult.CellFace.Y, raycastResult.CellFace.Z)) >> 10 != 0 && componentMiner.ComponentPlayer.ComponentGui.ModalPanelWidget is StoveWidget widget) { widget.Children.Find <LabelWidget>("Label", false).Text = "SteamTurbine"; } return(true); }
public override bool OnInteract(TerrainRaycastResult raycastResult, ComponentMiner componentMiner) { CellFace cellFace = base.CellFaces[0]; base.SubsystemElectricity.SubsystemTerrain.SubsystemFurnitureBlockBehavior.SwitchToNextState(cellFace.X, cellFace.Y, cellFace.Z, playSound: false); base.SubsystemElectricity.SubsystemAudio.PlaySound("Audio/Click", 1f, 0f, new Vector3(cellFace.X, cellFace.Y, cellFace.Z), 2f, autoDelay: true); return(true); }
public override bool OnAim(Ray3 aim, ComponentMiner componentMiner, AimState state) { switch (state) { case AimState.InProgress: { componentMiner.ComponentCreature.ComponentCreatureModel.AimHandAngleOrder = 3.2f; Block block2 = BlocksManager.Blocks[Terrain.ExtractContents(componentMiner.ActiveBlockValue)]; ComponentFirstPersonModel componentFirstPersonModel = componentMiner.Entity.FindComponent <ComponentFirstPersonModel>(); if (componentFirstPersonModel != null) { componentMiner.ComponentPlayer?.ComponentAimingSights.ShowAimingSights(aim.Position, aim.Direction); componentFirstPersonModel.ItemOffsetOrder = new Vector3(0f, 0.35f, 0.17f); if (block2 is SpearBlock) { componentFirstPersonModel.ItemRotationOrder = new Vector3(-1.5f, 0f, 0f); } } if (block2 is SpearBlock) { componentMiner.ComponentCreature.ComponentCreatureModel.InHandItemOffsetOrder = new Vector3(0f, -0.25f, 0f); componentMiner.ComponentCreature.ComponentCreatureModel.InHandItemRotationOrder = new Vector3(3.14159f, 0f, 0f); } break; } case AimState.Completed: { Vector3 vector = componentMiner.ComponentCreature.ComponentCreatureModel.EyePosition + componentMiner.ComponentCreature.ComponentBody.Matrix.Right * 0.4f; Vector3 v = Vector3.Normalize(vector + aim.Direction * 10f - vector); if (componentMiner.Inventory == null) { break; } int activeSlotIndex = componentMiner.Inventory.ActiveSlotIndex; int slotValue = componentMiner.Inventory.GetSlotValue(activeSlotIndex); int slotCount = componentMiner.Inventory.GetSlotCount(activeSlotIndex); int num = Terrain.ExtractContents(slotValue); Block block = BlocksManager.Blocks[num]; if (slotCount > 0) { float num2 = block.ProjectileSpeed; if (componentMiner.ComponentPlayer != null) { num2 *= 0.5f * (componentMiner.ComponentPlayer.ComponentLevel.StrengthFactor - 1f) + 1f; } if (m_subsystemProjectiles.FireProjectile(slotValue, vector, v * num2, m_random.Vector3(5f, 10f), componentMiner.ComponentCreature) != null) { componentMiner.Inventory.RemoveSlotItems(activeSlotIndex, 1); m_subsystemAudio.PlaySound("Audio/Throw", m_random.Float(0.2f, 0.3f), m_random.Float(-0.2f, 0.2f), aim.Position, 2f, autoDelay: true); componentMiner.Poke(forceRestart: false); } } break; } } return(false); }
public bool OnInteract(TerrainRaycastResult raycastResult, ComponentMiner componentMiner) { ComponentPlayer = componentMiner.ComponentPlayer; if (!Powered || ComponentPlayer == null) { return(false); } DialogsManager.ShowDialog(ComponentPlayer.View.GameWidget, new TextBoxDialog("Enter Code", lastcode, int.MaxValue, Execute)); return(true); }
public override bool OnInteract(TerrainRaycastResult raycastResult, ComponentMiner componentMiner) { CellFace cellFace = base.CellFaces[0]; int cellValue = base.SubsystemElectricity.SubsystemTerrain.Terrain.GetCellValue(cellFace.X, cellFace.Y, cellFace.Z); int value = SwitchBlock.SetLeverState(cellValue, !SwitchBlock.GetLeverState(cellValue)); base.SubsystemElectricity.SubsystemTerrain.ChangeCell(cellFace.X, cellFace.Y, cellFace.Z, value); base.SubsystemElectricity.SubsystemAudio.PlaySound("Audio/Click", 1f, 0f, new Vector3(cellFace.X, cellFace.Y, cellFace.Z), 2f, autoDelay: true); return(true); }
public override bool OnUse(Ray3 ray, ComponentMiner componentMiner) { TerrainRaycastResult?terrainRaycastResult = componentMiner.Raycast <TerrainRaycastResult>(ray, RaycastMode.Digging); if (terrainRaycastResult.HasValue) { m_subsystemFurnitureBlockBehavior.ScanDesign(terrainRaycastResult.Value.CellFace, ray.Direction, componentMiner); return(true); } return(false); }
public override bool OnInteract(TerrainRaycastResult raycastResult, ComponentMiner componentMiner) { var entity = Utils.GetBlockEntity(raycastResult.CellFace.Point); if (entity == null || componentMiner.ComponentPlayer == null) { return(false); } componentMiner.ComponentPlayer.ComponentGui.ModalPanelWidget = GetWidget(componentMiner.Inventory, entity.Entity.FindComponent <T>(true)); AudioManager.PlaySound("Audio/UI/ButtonClick", 1f, 0f, 0f); return(true); }
public override void Load(ValuesDictionary valuesDictionary, IdToEntityMap idToEntityMap) { m_subsystemTerrain = base.Project.FindSubsystem <SubsystemTerrain>(throwOnError: true); m_subsystemSky = base.Project.FindSubsystem <SubsystemSky>(throwOnError: true); m_componentMiner = base.Entity.FindComponent <ComponentMiner>(throwOnError: true); m_shader = ContentManager.Get <Shader>("Shaders/AlphaTested"); m_textures = new Texture2D[8]; for (int i = 0; i < 8; i++) { m_textures[i] = ContentManager.Get <Texture2D>($"Textures/Cracks{i + 1}"); } }
public override bool OnAim(Vector3 start, Vector3 direction, ComponentMiner componentMiner, AimState state) { int value = componentMiner.ActiveBlockValue; if (!(BlocksManager.Blocks[Terrain.ExtractContents(value)] is ItemBlock block)) { return(false); } var item = block.GetItem(ref value); return((item is OreChunk || (item is Mould && !(item is Mine)) || value == ItemBlock.IdTable["RefractoryBrick"] || value == ItemBlock.IdTable["ScrapIron"]) && base.OnAim(start, direction, componentMiner, state)); }
public override bool OnInteract(TerrainRaycastResult raycastResult, ComponentMiner componentMiner) { ComponentBlockEntity blockEntity = base.SubsystemTerrain.Project.FindSubsystem <SubsystemBlockEntities>(throwOnError: true).GetBlockEntity(raycastResult.CellFace.X, raycastResult.CellFace.Y, raycastResult.CellFace.Z); if (blockEntity != null && componentMiner.ComponentPlayer != null) { ComponentCraftingTable componentCraftingTable = blockEntity.Entity.FindComponent <ComponentCraftingTable>(throwOnError: true); componentMiner.ComponentPlayer.ComponentGui.ModalPanelWidget = new CraftingTableWidget(componentMiner.Inventory, componentCraftingTable); AudioManager.PlaySound("Audio/UI/ButtonClick", 1f, 0f, 0f); return(true); } return(false); }
public override bool OnInteract(TerrainRaycastResult raycastResult, ComponentMiner componentMiner) { ComponentBlockEntity blockEntity = m_subsystemBlockEntities.GetBlockEntity(raycastResult.CellFace.X, raycastResult.CellFace.Y, raycastResult.CellFace.Z); if (blockEntity != null && componentMiner.ComponentPlayer != null) { ComponentChest componentChest = blockEntity.Entity.FindComponent <ComponentChest>(throwOnError: true); componentMiner.ComponentPlayer.ComponentGui.ModalPanelWidget = new ChestWidget(componentMiner.Inventory, componentChest); AudioManager.PlaySound("Audio/UI/ButtonClick", 1f, 0f, 0f); return(true); } return(false); }
public override bool OnInteract(TerrainRaycastResult raycastResult, ComponentMiner componentMiner) { CellFace cellFace = raycastResult.CellFace; int cellValue = base.SubsystemTerrain.Terrain.GetCellValue(cellFace.X, cellFace.Y, cellFace.Z); int num = Terrain.ExtractContents(cellValue); int data = Terrain.ExtractData(cellValue); if (num == 56 || !IsDoorElectricallyConnected(cellFace.X, cellFace.Y, cellFace.Z)) { bool open = DoorBlock.GetOpen(data); return(OpenCloseDoor(cellFace.X, cellFace.Y, cellFace.Z, !open)); } return(true); }
public bool Milk(ComponentMiner milker) { if (milker != null) { base.Entity.FindComponent <ComponentHerdBehavior>()?.CallNearbyCreaturesHelp(milker.ComponentCreature, 20f, 20f, isPersistent: true); } if (HasMilk) { m_componentCreature.ComponentCreatureSounds.PlayIdleSound(skipIfRecentlyPlayed: false); m_lastMilkingTime = m_subsystemGameInfo.TotalElapsedGameTime; return(true); } m_componentCreature.ComponentCreatureSounds.PlayPainSound(); return(false); }
public override void Load(ValuesDictionary valuesDictionary, IdToEntityMap idToEntityMap) { base.Load(valuesDictionary, idToEntityMap); m_subsystemTerrain = base.Project.FindSubsystem <SubsystemTerrain>(throwOnError: true); m_subsystemModelsRenderer = base.Project.FindSubsystem <SubsystemModelsRenderer>(throwOnError: true); m_subsystemNoise = base.Project.FindSubsystem <SubsystemNoise>(throwOnError: true); m_subsystemAudio = base.Project.FindSubsystem <SubsystemAudio>(throwOnError: true); m_componentMiner = base.Entity.FindComponent <ComponentMiner>(); m_componentRider = base.Entity.FindComponent <ComponentRider>(); m_componentSleep = base.Entity.FindComponent <ComponentSleep>(); m_componentPlayer = base.Entity.FindComponent <ComponentPlayer>(); m_walkAnimationSpeed = valuesDictionary.GetValue <float>("WalkAnimationSpeed"); m_walkBobHeight = valuesDictionary.GetValue <float>("WalkBobHeight"); m_walkLegsAngle = valuesDictionary.GetValue <float>("WalkLegsAngle"); }
public override bool OnInteract(TerrainRaycastResult raycastResult, ComponentMiner componentMiner) { if (m_subsystemGameInfo.WorldSettings.GameMode != GameMode.Adventure) { ComponentBlockEntity blockEntity = m_subsystemBlockEntities.GetBlockEntity(raycastResult.CellFace.X, raycastResult.CellFace.Y, raycastResult.CellFace.Z); if (blockEntity != null && componentMiner.ComponentPlayer != null) { ComponentDispenser componentDispenser = blockEntity.Entity.FindComponent <ComponentDispenser>(throwOnError: true); componentMiner.ComponentPlayer.ComponentGui.ModalPanelWidget = new DispenserWidget(componentMiner.Inventory, componentDispenser); AudioManager.PlaySound("Audio/UI/ButtonClick", 1f, 0f, 0f); return(true); } } return(false); }
public override bool OnInteract(TerrainRaycastResult raycastResult, ComponentMiner componentMiner) { int x = raycastResult.CellFace.X; int y = raycastResult.CellFace.Y; int z = raycastResult.CellFace.Z; for (int i = 0; i < 6; i++) { ElectricElement electricElement = m_subsystemElectricity.GetElectricElement(x, y, z, i); if (electricElement != null) { return(electricElement.OnInteract(raycastResult, componentMiner)); } } return(false); }
public override bool OnInteract(TerrainRaycastResult raycastResult, ComponentMiner componentMiner) { int cellValue = base.SubsystemTerrain.Terrain.GetCellValue(raycastResult.CellFace.X, raycastResult.CellFace.Y, raycastResult.CellFace.Z); if (Terrain.ExtractContents(cellValue) == 227) { int designIndex = FurnitureBlock.GetDesignIndex(Terrain.ExtractData(cellValue)); FurnitureDesign design = GetDesign(designIndex); if (design != null && (design.InteractionMode == FurnitureInteractionMode.Multistate || design.InteractionMode == FurnitureInteractionMode.ConnectedMultistate)) { SwitchToNextState(raycastResult.CellFace.X, raycastResult.CellFace.Y, raycastResult.CellFace.Z, playSound: true); return(true); } } return(false); }
public override bool OnUse(Ray3 ray3, ComponentMiner componentMiner) { try { player = componentMiner.ComponentPlayer; if (xjJEIWidget == null) { xjJEIWidget = new XjJEIWidget(this); } player.ComponentGui.ModalPanelWidget = xjJEIWidget; } catch (Exception e) { toast(e.ToString()); } return(true); }
public override bool OnInteract(TerrainRaycastResult raycastResult, ComponentMiner componentMiner) { AudioManager.PlaySound("Audio/UI/ButtonClick", 1f, 0f, 0f); Point3 point = new Point3(raycastResult.CellFace.X, raycastResult.CellFace.Y, raycastResult.CellFace.Z); if (m_subsystemGameInfo.WorldSettings.GameMode == GameMode.Adventure) { SignData signData = GetSignData(point); if (signData != null && !string.IsNullOrEmpty(signData.Url)) { WebBrowserManager.LaunchBrowser(signData.Url); } } else if (componentMiner.ComponentPlayer != null) { DialogsManager.ShowDialog(componentMiner.ComponentPlayer.GuiWidget, new EditSignDialog(this, point)); } return(true); }
public override bool OnUse(Ray3 ray, ComponentMiner componentMiner) { TerrainRaycastResult?terrainRaycastResult = componentMiner.Raycast <TerrainRaycastResult>(ray, RaycastMode.Interaction); if (terrainRaycastResult.HasValue) { if (terrainRaycastResult.Value.CellFace.Face == 4) { int cellValue = m_subsystemTerrain.Terrain.GetCellValue(terrainRaycastResult.Value.CellFace.X, terrainRaycastResult.Value.CellFace.Y, terrainRaycastResult.Value.CellFace.Z); int num = Terrain.ExtractContents(cellValue); Block block = BlocksManager.Blocks[num]; switch (num) { case 2: { int value2 = Terrain.ReplaceContents(cellValue, 168); m_subsystemTerrain.ChangeCell(terrainRaycastResult.Value.CellFace.X, terrainRaycastResult.Value.CellFace.Y, terrainRaycastResult.Value.CellFace.Z, value2); m_subsystemAudio.PlayRandomSound("Audio/Impacts/Dirt", 0.5f, 0f, new Vector3(terrainRaycastResult.Value.CellFace.X, terrainRaycastResult.Value.CellFace.Y, terrainRaycastResult.Value.CellFace.Z), 3f, autoDelay: true); Vector3 position2 = new Vector3((float)terrainRaycastResult.Value.CellFace.X + 0.5f, (float)terrainRaycastResult.Value.CellFace.Y + 1.25f, (float)terrainRaycastResult.Value.CellFace.Z + 0.5f); m_subsystemParticles.AddParticleSystem(block.CreateDebrisParticleSystem(m_subsystemTerrain, position2, cellValue, 0.5f)); break; } case 8: { int value = Terrain.ReplaceContents(cellValue, 2); m_subsystemTerrain.ChangeCell(terrainRaycastResult.Value.CellFace.X, terrainRaycastResult.Value.CellFace.Y, terrainRaycastResult.Value.CellFace.Z, value); m_subsystemAudio.PlayRandomSound("Audio/Impacts/Plant", 0.5f, 0f, new Vector3(terrainRaycastResult.Value.CellFace.X, terrainRaycastResult.Value.CellFace.Y, terrainRaycastResult.Value.CellFace.Z), 3f, autoDelay: true); Vector3 position = new Vector3((float)terrainRaycastResult.Value.CellFace.X + 0.5f, (float)terrainRaycastResult.Value.CellFace.Y + 1.2f, (float)terrainRaycastResult.Value.CellFace.Z + 0.5f); m_subsystemParticles.AddParticleSystem(block.CreateDebrisParticleSystem(m_subsystemTerrain, position, cellValue, 0.75f)); break; } } } componentMiner.DamageActiveTool(1); return(true); } return(false); }
public override bool OnUse(Ray3 ray, ComponentMiner componentMiner) { m_subsystemAudio.PlayRandomSound("Audio/Whistle", 1f, m_random.Float(-0.2f, 0f), ray.Position, 4f, autoDelay: true); m_subsystemNoise.MakeNoise(componentMiner.ComponentCreature.ComponentBody, 0.5f, 30f); DynamicArray <ComponentBody> dynamicArray = new DynamicArray <ComponentBody>(); m_subsystemBodies.FindBodiesAroundPoint(new Vector2(componentMiner.ComponentCreature.ComponentBody.Position.X, componentMiner.ComponentCreature.ComponentBody.Position.Z), 64f, dynamicArray); float num = float.PositiveInfinity; List <ComponentBody> list = new List <ComponentBody>(); foreach (ComponentBody item in dynamicArray) { ComponentSummonBehavior componentSummonBehavior = item.Entity.FindComponent <ComponentSummonBehavior>(); if (componentSummonBehavior != null && componentSummonBehavior.IsEnabled) { float num2 = Vector3.Distance(item.Position, componentMiner.ComponentCreature.ComponentBody.Position); if (num2 > 4f && componentSummonBehavior.SummonTarget == null) { list.Add(item); num = MathUtils.Min(num, num2); } else { componentSummonBehavior.SummonTarget = componentMiner.ComponentCreature.ComponentBody; } } } foreach (ComponentBody item2 in list) { ComponentSummonBehavior componentSummonBehavior2 = item2.Entity.FindComponent <ComponentSummonBehavior>(); if (componentSummonBehavior2 != null && Vector3.Distance(item2.Position, componentMiner.ComponentCreature.ComponentBody.Position) < num + 4f) { componentSummonBehavior2.SummonTarget = componentMiner.ComponentCreature.ComponentBody; } } componentMiner.DamageActiveTool(1); return(true); }