public override void OnPoll(int value, int x, int y, int z, int pollPass)
 {
     if (m_isRotEnabled)
     {
         int   num       = Terrain.ExtractContents(value);
         Block block     = BlocksManager.Blocks[num];
         int   rotPeriod = block.GetRotPeriod(value);
         if (rotPeriod > 0 && pollPass % rotPeriod == 0)
         {
             int num2 = block.GetDamage(value) + 1;
             value = ((num2 > 1) ? block.GetDamageDestructionValue(value) : block.SetDamage(value, num2));
             base.SubsystemTerrain.ChangeCell(x, y, z, value);
         }
     }
 }
예제 #2
0
        public static int DamageItem(int value, int damageCount)
        {
            int   num   = Terrain.ExtractContents(value);
            Block block = Blocks[num];

            if (block.Durability >= 0)
            {
                int num2 = block.GetDamage(value) + damageCount;
                if (num2 <= block.Durability)
                {
                    return(block.SetDamage(value, num2));
                }
                return(block.GetDamageDestructionValue(value));
            }
            return(value);
        }
        public void ItemsScanned(ReadOnlyList <ScannedItemData> items)
        {
            int num = (int)((m_subsystemGameInfo.TotalElapsedGameTime - m_lastRotTime) / 60.0);

            if (num > 0)
            {
                if (m_isRotEnabled)
                {
                    foreach (ScannedItemData item in items)
                    {
                        int   num2      = Terrain.ExtractContents(item.Value);
                        Block block     = BlocksManager.Blocks[num2];
                        int   rotPeriod = block.GetRotPeriod(item.Value);
                        if (rotPeriod > 0)
                        {
                            int num3 = block.GetDamage(item.Value);
                            for (int i = 0; i < num; i++)
                            {
                                if (num3 > 1)
                                {
                                    break;
                                }
                                if ((i + m_rotStep) % rotPeriod == 0)
                                {
                                    num3++;
                                }
                            }
                            if (num3 <= 1)
                            {
                                m_subsystemItemsScanner.TryModifyItem(item, block.SetDamage(item.Value, num3));
                            }
                            else
                            {
                                m_subsystemItemsScanner.TryModifyItem(item, block.GetDamageDestructionValue(item.Value));
                            }
                        }
                    }
                }
                m_rotStep     += num;
                m_lastRotTime += (float)num * 60f;
            }
        }
예제 #4
0
 public override void MeasureOverride(Vector2 parentAvailableSize)
 {
     if (m_inventory != null)
     {
         bool flag = m_inventory is ComponentCreativeInventory || m_inventory is ComponentFurnitureInventory;
         int  num  = m_inventory.GetSlotCount(m_slotIndex);
         if (!flag && m_dragMode.HasValue)
         {
             num = ((m_dragMode.Value != 0) ? MathUtils.Max(num - 1, 0) : 0);
         }
         m_rectangleWidget.IsVisible = true;
         if (num > 0)
         {
             int   slotValue = m_inventory.GetSlotValue(m_slotIndex);
             int   num2      = Terrain.ExtractContents(slotValue);
             Block block     = BlocksManager.Blocks[num2];
             bool  flag2     = block.GetRotPeriod(slotValue) > 0 && block.GetDamage(slotValue) > 0;
             m_blockIconWidget.Value     = Terrain.ReplaceLight(slotValue, 15);
             m_blockIconWidget.IsVisible = !HideBlockIcon;
             if (num != m_lastCount)
             {
                 m_countWidget.Text = num.ToString();
                 m_lastCount        = num;
             }
             m_countWidget.IsVisible              = (num > 1 && !flag);
             m_editOverlayWidget.IsVisible        = (!HideEditOverlay && block.IsEditable);
             m_interactiveOverlayWidget.IsVisible = (!HideInteractiveOverlay && ((m_subsystemTerrain != null) ? block.IsInteractive(m_subsystemTerrain, slotValue) : block.DefaultIsInteractive));
             m_foodOverlayWidget.IsVisible        = (!HideFoodOverlay && block.GetRotPeriod(slotValue) > 0);
             m_foodOverlayWidget.FillColor        = (flag2 ? new Color(128, 64, 0) : new Color(160, 160, 160));
             if (!flag && !HideHealthBar && block.Durability >= 0)
             {
                 int damage = block.GetDamage(slotValue);
                 m_healthBarWidget.IsVisible = true;
                 m_healthBarWidget.Value     = (float)(block.Durability - damage) / (float)block.Durability;
             }
             else
             {
                 m_healthBarWidget.IsVisible = false;
             }
         }
         else
         {
             m_blockIconWidget.IsVisible          = false;
             m_countWidget.IsVisible              = false;
             m_healthBarWidget.IsVisible          = false;
             m_editOverlayWidget.IsVisible        = false;
             m_interactiveOverlayWidget.IsVisible = false;
             m_foodOverlayWidget.IsVisible        = false;
         }
         m_highlightWidget.IsVisible    = !HideHighlightRectangle;
         m_highlightWidget.OutlineColor = Color.Transparent;
         m_highlightWidget.FillColor    = Color.Transparent;
         m_splitLabelWidget.IsVisible   = false;
         if (m_slotIndex == m_inventory.ActiveSlotIndex)
         {
             m_highlightWidget.OutlineColor = new Color(0, 0, 0);
             m_highlightWidget.FillColor    = new Color(0, 0, 0, 80);
         }
         if (IsSplitMode())
         {
             m_highlightWidget.OutlineColor = new Color(255, 64, 0);
             m_splitLabelWidget.IsVisible   = true;
         }
     }
     else
     {
         m_rectangleWidget.IsVisible          = false;
         m_highlightWidget.IsVisible          = false;
         m_blockIconWidget.IsVisible          = false;
         m_countWidget.IsVisible              = false;
         m_healthBarWidget.IsVisible          = false;
         m_editOverlayWidget.IsVisible        = false;
         m_interactiveOverlayWidget.IsVisible = false;
         m_foodOverlayWidget.IsVisible        = false;
         m_splitLabelWidget.IsVisible         = false;
     }
     base.IsDrawRequired = (m_inventoryDragData != null);
     base.MeasureOverride(parentAvailableSize);
 }
예제 #5
0
        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);
        }