public void Update(float dt) { if (componentPlayer == null) { return; } if (msginfobtn.IsClicked || componentPlayer.ViewWidget.Input.IsKeyDownOnce(Key.Tab)) //消息点击 { if (messageInfo.IsVisible) { messageInfo.alwaysShow = false; messageInfo.IsVisible = messageInfo.alwaysShow; } else { messageInfo.alwaysShow = true; messageInfo.IsVisible = messageInfo.alwaysShow; } } if (componentPlayer.ViewWidget.Input.IsKeyDownOnce(Key.B)) { if (jeiBehavior.xjJEIWidget == null) { jeiBehavior.player = componentPlayer; jeiBehavior.xjJEIWidget = new XjJEIWidget(jeiBehavior); } if (componentPlayer.ComponentGui.ModalPanelWidget == null) { componentPlayer.ComponentGui.ModalPanelWidget = jeiBehavior.xjJEIWidget; } else { componentPlayer.ComponentGui.ModalPanelWidget = null; } } if (componentPlayer.ComponentHealth.DeathTime.HasValue) { foreach (SubsystemXjJeiBehavior.MarkFLag mark in SubsystemXjJeiBehavior.markFLags) { if (mark.point == componentPlayer.ComponentBody.Position) { markaddflag = true; break; } } if (!markaddflag) { SubsystemXjJeiBehavior.MarkFLag markFLag = new SubsystemXjJeiBehavior.MarkFLag(); markFLag.point = componentPlayer.ComponentBody.Position; markFLag.name = "死亡地点"; markFLag.color = Color.Red; SubsystemXjJeiBehavior.markFLags.Add(markFLag); markaddflag = true; } } if (touch.IsPressed) { componentPlayer.ComponentLocomotion.JumpOrder = 1f; jump.Texture = TextureAtlasManager.GetSubtexture("JEITextures/JEI_Jump_P").Texture; } else { jump.Texture = TextureAtlasManager.GetSubtexture("JEITextures/JEI_Jump").Texture; } if (messageInfo.IsVisible) { if (messageInfo.inputpos > 0) { if (componentPlayer.ViewWidget.Input.IsKeyDownOnce(Key.UpArrow)) { if (messageInfo.inputpos - 1 < 0) { messageInfo.inputpos = messageInfo.inputcache.Count - 1; } else { messageInfo.inputpos -= 1; } messageInfo.inputtext.Text = messageInfo.inputcache[messageInfo.inputpos]; } else if (componentPlayer.ViewWidget.Input.IsKeyDownOnce(Key.DownArrow)) { if (messageInfo.inputpos + 1 > messageInfo.inputcache.Count - 1) { messageInfo.inputpos = 0; } else { messageInfo.inputpos += 1; } messageInfo.inputtext.Text = messageInfo.inputcache[messageInfo.inputpos]; } } } block = BlocksManager.Blocks[Terrain.ExtractContents(componentPlayer.ComponentMiner.ActiveBlockValue)]; if (block.Durability > 0) { disname = block.GetDisplayName(null, componentPlayer.ComponentMiner.ActiveBlockValue); if (XjJeiManager.is_NewSC && ModsManager.customer_Strings.ContainsKey(disname)) { disname = ModsManager.customer_Strings[disname]; } int durty = 0; int damage = block.GetDamage(componentPlayer.ComponentMiner.ActiveBlockValue); durty = (block.Durability - damage); moreInfo.setInfo(disname, durty, block.GetMeleePower(componentPlayer.ComponentMiner.ActiveBlockValue)); moreInfo.bitmapWidget.Texture = moreInfo.texture; } else { moreInfo.naijiu.Text = ""; moreInfo.bitmapWidget.Texture = null; moreInfo.labelWidget.Text = ""; } moreInfo.setPosi(componentPlayer.ComponentBody.Position); moreInfo.setShow(SubsystemXjJeiBehavior.posi, SubsystemXjJeiBehavior.dura); if (!SubsystemXjJeiBehavior.run) { return; } if (componentPlayer.ComponentGui.ModalPanelWidget != null) { infoDialog.IsVisible = false; return; } //检测是否有方块 Ray3 ray = new Ray3(componentPlayer.GameWidget.ActiveCamera.ViewPosition, componentPlayer.GameWidget.ActiveCamera.ViewDirection); terrainray = componentPlayer.ComponentMiner.Raycast <TerrainRaycastResult>(ray, RaycastMode.Interaction, true, true, false); foreach (KeyValuePair <ComponentCreature, bool> creature in creatureSpawn.m_creatures) { if (creature.Key == null) { hasCreature = false; continue; } Vector3 creaturePosition = creature.Key.ComponentCreatureModel.EyePosition; Vector3 start = ray.Position; Vector3 direction = Vector3.Normalize(ray.Direction); Vector3 end = ray.Position + direction * 15f; //检测是否有生物 if (creature.Key.ComponentBody.Position == componentPlayer.ComponentBody.Position) { hasCreature = false; continue; } Raymm = ray.Intersection(creature.Key.ComponentBody.BoundingBox); if (Raymm.HasValue) { if (Raymm.Value <= 10f) { infoDialog.setCreatureinfo(creature.Key); hasCreature = true; break; } } else { hasCreature = false; } } if (terrainray.HasValue && !hasCreature) { point = terrainray.Value.CellFace.Point; float disb = terrainray.Value.Distance; if (Raymm.HasValue && Raymm.Value <= disb) { infoDialog.IsVisible = true; } else { cellValue = terrainray.Value.Value; if (Terrain.ExtractContents(componentPlayer.ComponentMiner.ActiveBlockValue) != 0) { //装备的工具等级 block = BlocksManager.Blocks[Terrain.ExtractContents(componentPlayer.ComponentMiner.ActiveBlockValue)]; toollevel = block.ToolLevel; //hack为劈砍 //shovel为铲子 //quarry为镐子 //none为手 } else { toollevel = 0; } block = BlocksManager.Blocks[Terrain.ExtractContents(cellValue)]; disname = block.GetDisplayName(null, cellValue); if (XjJeiManager.is_NewSC && ModsManager.customer_Strings.ContainsKey(disname)) { disname = ModsManager.customer_Strings[disname]; } ; if (subsystemPlantBlock.HandledBlocks.Contains(Terrain.ExtractContents(cellValue))) { grow = Terrain.ExtractData(cellValue) & 7; if (Terrain.ExtractContents(cellValue) == 174) { grow = (int)((((float)grow) / 7f) * 100); //黑麦 } else { grow = (int)(((7f - (float)grow) / 7f) * 100); //南瓜 } infoDialog.setPlantInfo(disname, cellValue, grow); } else {//不是作物 grow = 0; dig = block.RequiredToolLevel; infoDialog.setBlockInfo($"{disname}", cellValue, dig, block.DigMethod, toollevel); } infoDialog.IsVisible = true; } } else { if (!hasCreature) { infoDialog.IsVisible = false; } else { infoDialog.IsVisible = true; } } infoDialog.setBottomWidget(moreInfo); infoDialog.setUpmode(SubsystemXjJeiBehavior.upmode); }
public void Hit(ComponentBody componentBody, Vector3 hitPoint, Vector3 hitDirection) { if (Hit1 != null) { Hit1(componentBody, hitPoint, hitDirection); return; } if (!(m_subsystemTime.GameTime - m_lastHitTime > 0.6600000262260437)) { return; } m_lastHitTime = m_subsystemTime.GameTime; Block block = BlocksManager.Blocks[Terrain.ExtractContents(ActiveBlockValue)]; if (!CanUseTool(ActiveBlockValue)) { ComponentPlayer?.ComponentGui.DisplaySmallMessage(string.Format(LanguageControl.Get(fName, 1), block.PlayerLevelRequired, block.GetDisplayName(m_subsystemTerrain, ActiveBlockValue)), Color.White, blinking: true, playNotificationSound: true); Poke(forceRestart: false); return; } float num = 0f; float num2 = 1f; if (ActiveBlockValue != 0) { num = block.GetMeleePower(ActiveBlockValue) * AttackPower * m_random.Float(0.8f, 1.2f); num2 = block.GetMeleeHitProbability(ActiveBlockValue); } else { num = AttackPower * m_random.Float(0.8f, 1.2f); num2 = 0.66f; } bool flag; if (ComponentPlayer != null) { m_subsystemAudio.PlaySound("Audio/Swoosh", 1f, m_random.Float(-0.2f, 0.2f), componentBody.Position, 3f, autoDelay: false); flag = m_random.Bool(num2); num *= ComponentPlayer.ComponentLevel.StrengthFactor; } else { flag = true; } if (flag) { AttackBody(componentBody, ComponentCreature, hitPoint, hitDirection, num, isMeleeAttack: true); DamageActiveTool(1); } else if (ComponentCreature is ComponentPlayer) { HitValueParticleSystem particleSystem = new HitValueParticleSystem(hitPoint + 0.75f * hitDirection, 1f * hitDirection + ComponentCreature.ComponentBody.Velocity, Color.White, LanguageControl.Get(fName, 2)); base.Project.FindSubsystem <SubsystemParticles>(throwOnError: true).AddParticleSystem(particleSystem); } if (ComponentCreature.PlayerStats != null) { ComponentCreature.PlayerStats.MeleeAttacks++; if (flag) { ComponentCreature.PlayerStats.MeleeHits++; } } Poke(forceRestart: false); }
public Dictionary <string, string> GetBlockProperties(int value) { Dictionary <string, string> dictionary = new Dictionary <string, string>(); int num = Terrain.ExtractContents(value); Block block = BlocksManager.Blocks[num]; if (block.DefaultEmittedLightAmount > 0) { dictionary.Add(LanguageControl.Get(fName, 1), block.DefaultEmittedLightAmount.ToString()); } if (block.FuelFireDuration > 0f) { dictionary.Add(LanguageControl.Get(fName, 2), block.FuelFireDuration.ToString()); } dictionary.Add(LanguageControl.Get(fName, 3), (block.MaxStacking > 1) ? string.Format(LanguageControl.Get(fName, 4), block.MaxStacking.ToString()) : LanguageControl.Get("Usual", "no")); dictionary.Add(LanguageControl.Get(fName, 5), (block.FireDuration > 0f) ? LanguageControl.Get("Usual", "yes") : LanguageControl.Get("Usual", "no")); if (block.GetNutritionalValue(value) > 0f) { dictionary.Add(LanguageControl.Get(fName, 6), block.GetNutritionalValue(value).ToString()); } if (block.GetRotPeriod(value) > 0) { dictionary.Add(LanguageControl.Get(fName, 7), string.Format(LanguageControl.Get(fName, 25), $"{(2 * block.GetRotPeriod(value) * 60f / 1200f):0.0}")); } if (block.DigMethod != 0) { dictionary.Add(LanguageControl.Get(fName, 8), LanguageControl.Get("DigMethod", block.DigMethod.ToString())); dictionary.Add(LanguageControl.Get(fName, 9), block.DigResilience.ToString()); } if (block.ExplosionResilience > 0f) { dictionary.Add(LanguageControl.Get(fName, 10), block.ExplosionResilience.ToString()); } if (block.GetExplosionPressure(value) > 0f) { dictionary.Add(LanguageControl.Get(fName, 11), block.GetExplosionPressure(value).ToString()); } bool flag = false; if (block.GetMeleePower(value) > 1f) { dictionary.Add(LanguageControl.Get(fName, 12), block.GetMeleePower(value).ToString()); flag = true; } if (block.GetMeleePower(value) > 1f) { dictionary.Add(LanguageControl.Get(fName, 13), $"{100f * block.GetMeleeHitProbability(value):0}%"); flag = true; } if (block.GetProjectilePower(value) > 1f) { dictionary.Add(LanguageControl.Get(fName, 14), block.GetProjectilePower(value).ToString()); flag = true; } if (block.ShovelPower > 1f) { dictionary.Add(LanguageControl.Get(fName, 15), block.ShovelPower.ToString()); flag = true; } if (block.HackPower > 1f) { dictionary.Add(LanguageControl.Get(fName, 16), block.HackPower.ToString()); flag = true; } if (block.QuarryPower > 1f) { dictionary.Add(LanguageControl.Get(fName, 17), block.QuarryPower.ToString()); flag = true; } if (flag && block.Durability > 0) { dictionary.Add(LanguageControl.Get(fName, 18), block.Durability.ToString()); } if (block.DefaultExperienceCount > 0f) { dictionary.Add(LanguageControl.Get(fName, 19), block.DefaultExperienceCount.ToString()); } if (block is ClothingBlock) { ClothingData clothingData = ClothingBlock.GetClothingData(Terrain.ExtractData(value)); dictionary.Add(LanguageControl.Get(fName, 20), clothingData.CanBeDyed ? LanguageControl.Get("Usual", "yes") : LanguageControl.Get("Usual", "no")); dictionary.Add(LanguageControl.Get(fName, 21), $"{(int)(clothingData.ArmorProtection * 100f)}%"); dictionary.Add(LanguageControl.Get(fName, 22), clothingData.Sturdiness.ToString()); dictionary.Add(LanguageControl.Get(fName, 23), $"{clothingData.Insulation:0.0} clo"); dictionary.Add(LanguageControl.Get(fName, 24), $"{clothingData.MovementSpeedFactor * 100f:0}%"); } return(dictionary); }