public override void DrawBlock(PrimitivesRenderer3D primitivesRenderer, int value, Color color, float size, ref Matrix matrix, DrawBlockEnvironmentData environmentData) { int data = Terrain.ExtractData(value); int draw = GetDraw(data); ArrowBlock.ArrowType?arrowType = GetArrowType(data); BlocksManager.DrawMeshBlock(primitivesRenderer, m_standaloneBlockMeshes[draw], color, 2f * size, ref matrix, environmentData); if (arrowType.HasValue) { Matrix matrix2 = Matrix.CreateRotationX(-(float)Math.PI / 2f) * Matrix.CreateTranslation(0f, 0.2f * size, -0.09f * size) * matrix; int value2 = Terrain.MakeBlockValue(192, 0, ArrowBlock.SetArrowType(0, arrowType.Value)); BlocksManager.Blocks[192].DrawBlock(primitivesRenderer, value2, color, size, ref matrix2, environmentData); } }
static SubsystemTreasureGeneratorBlockBehavior() { TreasureData[] array = new TreasureData[61]; TreasureData treasureData = new TreasureData { Value = 79, Probability = 4f, MaxCount = 4 }; array[0] = treasureData; treasureData = new TreasureData { Value = 111, Probability = 1f, MaxCount = 1 }; array[1] = treasureData; treasureData = new TreasureData { Value = 43, Probability = 4f, MaxCount = 4 }; array[2] = treasureData; treasureData = new TreasureData { Value = 40, Probability = 2f, MaxCount = 3 }; array[3] = treasureData; treasureData = new TreasureData { Value = 42, Probability = 4f, MaxCount = 3 }; array[4] = treasureData; treasureData = new TreasureData { Value = 22, Probability = 4f, MaxCount = 4 }; array[5] = treasureData; treasureData = new TreasureData { Value = 103, Probability = 2f, MaxCount = 4 }; array[6] = treasureData; treasureData = new TreasureData { Value = 150, Probability = 1f, MaxCount = 1 }; array[7] = treasureData; treasureData = new TreasureData { Value = 21, Probability = 2f, MaxCount = 16 }; array[8] = treasureData; treasureData = new TreasureData { Value = 159, Probability = 2f, MaxCount = 4 }; array[9] = treasureData; treasureData = new TreasureData { Value = 207, Probability = 2f, MaxCount = 4 }; array[10] = treasureData; treasureData = new TreasureData { Value = 17, Probability = 2f, MaxCount = 2 }; array[11] = treasureData; treasureData = new TreasureData { Value = 31, Probability = 4f, MaxCount = 4 }; array[12] = treasureData; treasureData = new TreasureData { Value = 108, Probability = 4f, MaxCount = 8 }; array[13] = treasureData; treasureData = new TreasureData { Value = 109, Probability = 2f, MaxCount = 4 }; array[14] = treasureData; treasureData = new TreasureData { Value = 105, Probability = 1f, MaxCount = 4 }; array[15] = treasureData; treasureData = new TreasureData { Value = 106, Probability = 1f, MaxCount = 2 }; array[16] = treasureData; treasureData = new TreasureData { Value = 107, Probability = 1f, MaxCount = 1 }; array[17] = treasureData; treasureData = new TreasureData { Value = 234, Probability = 1f, MaxCount = 4 }; array[18] = treasureData; treasureData = new TreasureData { Value = 235, Probability = 1f, MaxCount = 2 }; array[19] = treasureData; treasureData = new TreasureData { Value = 236, Probability = 1f, MaxCount = 1 }; array[20] = treasureData; treasureData = new TreasureData { Value = 132, Probability = 2f, MaxCount = 2 }; array[21] = treasureData; treasureData = new TreasureData { Value = Terrain.MakeBlockValue(173, 0, 6), Probability = 2f, MaxCount = 8 }; array[22] = treasureData; treasureData = new TreasureData { Value = Terrain.MakeBlockValue(173, 0, 7), Probability = 8f, MaxCount = 8 }; array[23] = treasureData; treasureData = new TreasureData { Value = Terrain.MakeBlockValue(173, 0, 5), Probability = 8f, MaxCount = 8 }; array[24] = treasureData; treasureData = new TreasureData { Value = Terrain.MakeBlockValue(173, 0, 6), Probability = 2f, MaxCount = 8 }; array[25] = treasureData; treasureData = new TreasureData { Value = Terrain.MakeBlockValue(119, 0, 0), Probability = 2f, MaxCount = 8 }; array[26] = treasureData; treasureData = new TreasureData { Value = Terrain.MakeBlockValue(119, 0, 1), Probability = 2f, MaxCount = 8 }; array[27] = treasureData; treasureData = new TreasureData { Value = Terrain.MakeBlockValue(119, 0, 2), Probability = 2f, MaxCount = 8 }; array[28] = treasureData; treasureData = new TreasureData { Value = Terrain.MakeBlockValue(119, 0, 3), Probability = 2f, MaxCount = 8 }; array[29] = treasureData; treasureData = new TreasureData { Value = Terrain.MakeBlockValue(119, 0, 4), Probability = 2f, MaxCount = 8 }; array[30] = treasureData; treasureData = new TreasureData { Value = 191, Probability = 4f, MaxCount = 1 }; array[31] = treasureData; treasureData = new TreasureData { Value = Terrain.MakeBlockValue(192, 0, ArrowBlock.SetArrowType(0, ArrowBlock.ArrowType.CopperArrow)), Probability = 2f, MaxCount = 2 }; array[32] = treasureData; treasureData = new TreasureData { Value = Terrain.MakeBlockValue(192, 0, ArrowBlock.SetArrowType(0, ArrowBlock.ArrowType.IronArrow)), Probability = 2f, MaxCount = 2 }; array[33] = treasureData; treasureData = new TreasureData { Value = Terrain.MakeBlockValue(192, 0, ArrowBlock.SetArrowType(0, ArrowBlock.ArrowType.DiamondArrow)), Probability = 1f, MaxCount = 2 }; array[34] = treasureData; treasureData = new TreasureData { Value = Terrain.MakeBlockValue(192, 0, ArrowBlock.SetArrowType(0, ArrowBlock.ArrowType.FireArrow)), Probability = 2f, MaxCount = 2 }; array[35] = treasureData; treasureData = new TreasureData { Value = 200, Probability = 1f, MaxCount = 1 }; array[36] = treasureData; treasureData = new TreasureData { Value = Terrain.MakeBlockValue(192, 0, ArrowBlock.SetArrowType(0, ArrowBlock.ArrowType.IronBolt)), Probability = 2f, MaxCount = 2 }; array[37] = treasureData; treasureData = new TreasureData { Value = Terrain.MakeBlockValue(192, 0, ArrowBlock.SetArrowType(0, ArrowBlock.ArrowType.DiamondBolt)), Probability = 1f, MaxCount = 2 }; array[38] = treasureData; treasureData = new TreasureData { Value = Terrain.MakeBlockValue(192, 0, ArrowBlock.SetArrowType(0, ArrowBlock.ArrowType.ExplosiveBolt)), Probability = 1f, MaxCount = 2 }; array[39] = treasureData; treasureData = new TreasureData { Value = 212, Probability = 1f, MaxCount = 1 }; array[40] = treasureData; treasureData = new TreasureData { Value = 124, Probability = 1f, MaxCount = 1 }; array[41] = treasureData; treasureData = new TreasureData { Value = 125, Probability = 1f, MaxCount = 1 }; array[42] = treasureData; treasureData = new TreasureData { Value = 82, Probability = 1f, MaxCount = 1 }; array[43] = treasureData; treasureData = new TreasureData { Value = 116, Probability = 1f, MaxCount = 1 }; array[44] = treasureData; treasureData = new TreasureData { Value = 36, Probability = 1f, MaxCount = 1 }; array[45] = treasureData; treasureData = new TreasureData { Value = 113, Probability = 1f, MaxCount = 1 }; array[46] = treasureData; treasureData = new TreasureData { Value = 38, Probability = 1f, MaxCount = 1 }; array[47] = treasureData; treasureData = new TreasureData { Value = 115, Probability = 1f, MaxCount = 1 }; array[48] = treasureData; treasureData = new TreasureData { Value = 37, Probability = 1f, MaxCount = 1 }; array[49] = treasureData; treasureData = new TreasureData { Value = 114, Probability = 1f, MaxCount = 1 }; array[50] = treasureData; treasureData = new TreasureData { Value = 171, Probability = 1f, MaxCount = 1 }; array[51] = treasureData; treasureData = new TreasureData { Value = 172, Probability = 1f, MaxCount = 1 }; array[52] = treasureData; treasureData = new TreasureData { Value = 90, Probability = 1f, MaxCount = 1 }; array[53] = treasureData; treasureData = new TreasureData { Value = 160, Probability = 1f, MaxCount = 1 }; array[54] = treasureData; treasureData = new TreasureData { Value = 158, Probability = 2f, MaxCount = 1 }; array[55] = treasureData; treasureData = new TreasureData { Value = 133, Probability = 1f, MaxCount = 10 }; array[56] = treasureData; treasureData = new TreasureData { Value = 179, Probability = 1f, MaxCount = 2 }; array[57] = treasureData; treasureData = new TreasureData { Value = 142, Probability = 1f, MaxCount = 2 }; array[58] = treasureData; treasureData = new TreasureData { Value = 141, Probability = 1f, MaxCount = 2 }; array[59] = treasureData; treasureData = new TreasureData { Value = 237, Probability = 1f, MaxCount = 2 }; array[60] = treasureData; m_treasureData = array; }
public override bool OnAim(Ray3 aim, ComponentMiner componentMiner, AimState state) { IInventory inventory = componentMiner.Inventory; if (inventory != null) { int activeSlotIndex = inventory.ActiveSlotIndex; if (activeSlotIndex >= 0) { int slotValue = inventory.GetSlotValue(activeSlotIndex); int slotCount = inventory.GetSlotCount(activeSlotIndex); int num = Terrain.ExtractContents(slotValue); int data = Terrain.ExtractData(slotValue); if (num == 191 && slotCount > 0) { if (!m_aimStartTimes.TryGetValue(componentMiner, out double value)) { value = m_subsystemTime.GameTime; m_aimStartTimes[componentMiner] = value; } float num2 = (float)(m_subsystemTime.GameTime - value); float num3 = (float)MathUtils.Remainder(m_subsystemTime.GameTime, 1000.0); Vector3 v = ((componentMiner.ComponentCreature.ComponentBody.IsSneaking ? 0.02f : 0.04f) + 0.25f * MathUtils.Saturate((num2 - 2.1f) / 5f)) * new Vector3 { X = SimplexNoise.OctavedNoise(num3, 2f, 3, 2f, 0.5f), Y = SimplexNoise.OctavedNoise(num3 + 100f, 2f, 3, 2f, 0.5f), Z = SimplexNoise.OctavedNoise(num3 + 200f, 2f, 3, 2f, 0.5f) }; aim.Direction = Vector3.Normalize(aim.Direction + v); switch (state) { case AimState.InProgress: { if (num2 >= 9f) { componentMiner.ComponentCreature.ComponentCreatureSounds.PlayMoanSound(); return(true); } ComponentFirstPersonModel componentFirstPersonModel = componentMiner.Entity.FindComponent <ComponentFirstPersonModel>(); if (componentFirstPersonModel != null) { componentMiner.ComponentPlayer?.ComponentAimingSights.ShowAimingSights(aim.Position, aim.Direction); componentFirstPersonModel.ItemOffsetOrder = new Vector3(-0.1f, 0.15f, 0f); componentFirstPersonModel.ItemRotationOrder = new Vector3(0f, -0.7f, 0f); } componentMiner.ComponentCreature.ComponentCreatureModel.AimHandAngleOrder = 1.2f; componentMiner.ComponentCreature.ComponentCreatureModel.InHandItemOffsetOrder = new Vector3(0f, 0f, 0f); componentMiner.ComponentCreature.ComponentCreatureModel.InHandItemRotationOrder = new Vector3(0f, -0.2f, 0f); if (m_subsystemTime.PeriodicGameTimeEvent(0.10000000149011612, 0.0)) { int draw2 = MathUtils.Min(BowBlock.GetDraw(data) + 1, 15); inventory.RemoveSlotItems(activeSlotIndex, 1); inventory.AddSlotItems(activeSlotIndex, Terrain.MakeBlockValue(num, 0, BowBlock.SetDraw(data, draw2)), 1); } break; } case AimState.Cancelled: inventory.RemoveSlotItems(activeSlotIndex, 1); inventory.AddSlotItems(activeSlotIndex, Terrain.MakeBlockValue(num, 0, BowBlock.SetDraw(data, 0)), 1); m_aimStartTimes.Remove(componentMiner); break; case AimState.Completed: { int draw = BowBlock.GetDraw(data); ArrowBlock.ArrowType?arrowType = BowBlock.GetArrowType(data); if (arrowType.HasValue) { Vector3 vector = componentMiner.ComponentCreature.ComponentCreatureModel.EyePosition + componentMiner.ComponentCreature.ComponentBody.Matrix.Right * 0.3f - componentMiner.ComponentCreature.ComponentBody.Matrix.Up * 0.2f; Vector3 vector2 = Vector3.Normalize(vector + aim.Direction * 10f - vector); float num4 = MathUtils.Lerp(0f, 28f, MathUtils.Pow((float)draw / 15f, 0.75f)); if (componentMiner.ComponentPlayer != null) { num4 *= 0.5f * (componentMiner.ComponentPlayer.ComponentLevel.StrengthFactor - 1f) + 1f; } Vector3 vector3 = Vector3.Zero; if (arrowType == ArrowBlock.ArrowType.WoodenArrow) { vector3 = new Vector3(0.025f, 0.025f, 0.025f); } if (arrowType == ArrowBlock.ArrowType.StoneArrow) { vector3 = new Vector3(0.01f, 0.01f, 0.01f); } int value2 = Terrain.MakeBlockValue(192, 0, ArrowBlock.SetArrowType(0, arrowType.Value)); Vector3 vector4 = Vector3.Normalize(Vector3.Cross(vector2, Vector3.UnitY)); Vector3 v2 = Vector3.Normalize(Vector3.Cross(vector2, vector4)); Vector3 v3 = m_random.Float(0f - vector3.X, vector3.X) * vector4 + m_random.Float(0f - vector3.Y, vector3.Y) * v2 + m_random.Float(0f - vector3.Z, vector3.Z) * vector2; if (m_subsystemProjectiles.FireProjectile(value2, vector, (vector2 + v3) * num4, Vector3.Zero, componentMiner.ComponentCreature) != null) { data = BowBlock.SetArrowType(data, null); m_subsystemAudio.PlaySound("Audio/Bow", 1f, m_random.Float(-0.1f, 0.1f), vector, 3f, autoDelay: true); } } else { componentMiner.ComponentPlayer?.ComponentGui.DisplaySmallMessage("Load an arrow first", Color.White, blinking: true, playNotificationSound: false); } inventory.RemoveSlotItems(activeSlotIndex, 1); int value3 = Terrain.MakeBlockValue(num, 0, BowBlock.SetDraw(data, 0)); inventory.AddSlotItems(activeSlotIndex, value3, 1); int damageCount = 0; if (draw >= 15) { damageCount = 2; } else if (draw >= 4) { damageCount = 1; } componentMiner.DamageActiveTool(damageCount); m_aimStartTimes.Remove(componentMiner); break; } } } } } return(false); }
public override bool OnAim(Ray3 aim, ComponentMiner componentMiner, AimState state) { IInventory inventory = componentMiner.Inventory; if (inventory != null) { int activeSlotIndex = inventory.ActiveSlotIndex; if (activeSlotIndex >= 0) { int slotValue = inventory.GetSlotValue(activeSlotIndex); int slotCount = inventory.GetSlotCount(activeSlotIndex); int num = Terrain.ExtractContents(slotValue); int data = Terrain.ExtractData(slotValue); if (num == 200 && slotCount > 0) { int draw = CrossbowBlock.GetDraw(data); if (!m_aimStartTimes.TryGetValue(componentMiner, out double value)) { value = m_subsystemTime.GameTime; m_aimStartTimes[componentMiner] = value; } float num2 = (float)(m_subsystemTime.GameTime - value); float num3 = (float)MathUtils.Remainder(m_subsystemTime.GameTime, 1000.0); Vector3 v = ((componentMiner.ComponentCreature.ComponentBody.IsSneaking ? 0.01f : 0.03f) + 0.15f * MathUtils.Saturate((num2 - 2.5f) / 6f)) * new Vector3 { X = SimplexNoise.OctavedNoise(num3, 2f, 3, 2f, 0.5f), Y = SimplexNoise.OctavedNoise(num3 + 100f, 2f, 3, 2f, 0.5f), Z = SimplexNoise.OctavedNoise(num3 + 200f, 2f, 3, 2f, 0.5f) }; aim.Direction = Vector3.Normalize(aim.Direction + v); switch (state) { case AimState.InProgress: { if (num2 >= 10f) { componentMiner.ComponentCreature.ComponentCreatureSounds.PlayMoanSound(); return(true); } ComponentFirstPersonModel componentFirstPersonModel = componentMiner.Entity.FindComponent <ComponentFirstPersonModel>(); if (componentFirstPersonModel != null) { componentMiner.ComponentPlayer?.ComponentAimingSights.ShowAimingSights(aim.Position, aim.Direction); componentFirstPersonModel.ItemOffsetOrder = new Vector3(-0.22f, 0.15f, 0.1f); componentFirstPersonModel.ItemRotationOrder = new Vector3(-0.7f, 0f, 0f); } componentMiner.ComponentCreature.ComponentCreatureModel.AimHandAngleOrder = 1.3f; componentMiner.ComponentCreature.ComponentCreatureModel.InHandItemOffsetOrder = new Vector3(-0.08f, -0.1f, 0.07f); componentMiner.ComponentCreature.ComponentCreatureModel.InHandItemRotationOrder = new Vector3(-1.55f, 0f, 0f); break; } case AimState.Cancelled: m_aimStartTimes.Remove(componentMiner); break; case AimState.Completed: { ArrowBlock.ArrowType?arrowType = CrossbowBlock.GetArrowType(data); if (draw != 15) { componentMiner.ComponentPlayer?.ComponentGui.DisplaySmallMessage("Draw the crossbow first", Color.White, blinking: true, playNotificationSound: false); } else if (!arrowType.HasValue) { componentMiner.ComponentPlayer?.ComponentGui.DisplaySmallMessage("Load a bolt first", Color.White, blinking: true, playNotificationSound: false); } else { Vector3 vector = componentMiner.ComponentCreature.ComponentCreatureModel.EyePosition + componentMiner.ComponentCreature.ComponentBody.Matrix.Right * 0.3f - componentMiner.ComponentCreature.ComponentBody.Matrix.Up * 0.2f; Vector3 v2 = Vector3.Normalize(vector + aim.Direction * 10f - vector); int value2 = Terrain.MakeBlockValue(192, 0, ArrowBlock.SetArrowType(0, arrowType.Value)); float s = 38f; if (m_subsystemProjectiles.FireProjectile(value2, vector, s * v2, Vector3.Zero, componentMiner.ComponentCreature) != null) { data = CrossbowBlock.SetArrowType(data, null); m_subsystemAudio.PlaySound("Audio/Bow", 1f, m_random.Float(-0.1f, 0.1f), componentMiner.ComponentCreature.ComponentCreatureModel.EyePosition, 3f, 0.05f); } } inventory.RemoveSlotItems(activeSlotIndex, 1); int value3 = Terrain.MakeBlockValue(num, 0, CrossbowBlock.SetDraw(data, 0)); inventory.AddSlotItems(activeSlotIndex, value3, 1); if (draw > 0) { componentMiner.DamageActiveTool(1); m_subsystemAudio.PlaySound("Audio/CrossbowBoing", 1f, m_random.Float(-0.1f, 0.1f), componentMiner.ComponentCreature.ComponentCreatureModel.EyePosition, 3f, 0f); } m_aimStartTimes.Remove(componentMiner); break; } } } } } return(false); }