콘텐츠로 건너뛰기
라이엇 비트

라이엇 비트

  • 집
  • 소식
  • 가이드
  • 비디오 가이드
  • 패치 노트
  • 남용 신고
  • 검색 양식 전환
우주 엔지니어

우주 엔지니어 – How to Mod UseObjects (Custom Block Interactions)

에 게시됨 07/29/2021 에 의해 Gwindalmir 코멘트 없음 ~에 우주 엔지니어 – How to Mod UseObjects (Custom Block Interactions)
  • 제목: 우주 엔지니어
  • 출시일: 2월 28, 2019
  • 개발자: 예리한 소프트웨어 하우스
  • 발행자: 예리한 소프트웨어 하우스

This guide explains how to use the custom UseObjects added to the modding API in SE 1.199.

소개

Since SE version 1.199, Keen added to the Modding API the ability to create custom UseObjects. A UseObject is an interactive point on a block, such as terminal access or a button on a button panel.

If you’ve ever made a block mod before, you’ve probably made an interaction point. These are empties (dummies) named something like detector_terminal_1.

This guide will show you how to create your own interaction dummies, which you can use to trigger any behavior you want that is possible with the ModAPI.

Model Preparation

The model setup is similar to any other interaction dummy you would make for regular blocks.
The only difference is the name of the empty/dummy.

  • 만들다 (or modify) a model
  • Add a new empty, following the same procedure for making any dummies
  • Name the empty according to the syntax described below.

The name of an interaction dummy is broken down into 3 or more parts: Marker, 유형, subtype, sequence number (seq no); in this format: marker_type_subtype_sequencenumber.
Two parts are required to be named specifically: the marker and the sequence number.
For the purposes of this guide, the marker is the detector, and seq no is an integer starting from 1.

UseObject Code Implementation

Once the model is set up, the actual interaction implementation is done via a C# script.

// Initialize the UseObject, using the type of "DHD"
// This must match the second element of the empty/dummy name, but is not case sensitive.
[MyUseObject("DHD")]
public class DHDUseObject : MyUseObjectBase
{
    IMyGps m_selectedButton;
    IMyTerminalBlock m_dhd;

    public DHDUseObject(IMyEntity owner, string dummyName, IMyModelDummy dummyData, uint key)
    : 베이스(소유자, dummyData)
    {
        // Save a reference to the parent block, so we can execute the action on the correct one later.
        m_dhd = owner as IMyTerminalBlock;
    }

    // This is the primary action, such as pushing a button.
    public override UseActionEnum PrimaryAction => UseActionEnum.Manipulate;

    // This is the secondary action, such as pressing K to open the action assignment menu of a button. This is optional.
    public override UseActionEnum SecondaryAction => UseActionEnum.OpenTerminal;

    // This tells the game which actions you want to support. 이 경우, only the primary is used.
    // You can use specify multiple actions by combining them using a bitwise OR operator
    // 예를 들어, PrimaryAction | SecondaryAction
    public override UseActionEnum SupportedActions => PrimaryAction;

    // This is called when the player is aiming at the interaction dummy.
    public override MyActionDescription GetActionInfo(UseActionEnum actionEnum)
    {
        // This example doesn't care about the subtype ("단추" in the model empty name),
        // However you can use that field, if set, to share one script with multiple dummy actions.
        // 예를 들어, detector_mypower_on_1 could be used to turn a block on, 그리고
        // detector_mypower_off_1 could be used to turn a block off. You could even have a 
        // a third one, detector_mypower_toggle_1 which toggles the block state.
        // You can grab the subtype field by splitting the dummy name on '_' and grabbing the third element (index 2).
        스위치 (actionEnum)
        {
            case UseActionEnum.Manipulate:
                만약에 (m_selectedButton == null)
                {
                    // Get the seq no of the dummy (spaces added to avoid Steam flagging as URL)
                    var button = int.Parse( this.Dummy .Name.Substring( this.Dummy .Name.LastIndexOf('_') + 1 ) ) - 1;
                    var button_text = "Button " + button.ToString();

                    // This creates a HUD marker for the interaction dummy, like button panels. This is optional.
                    m_selectedButton = MyAPIGateway.Session.GPS.Create(button_text, "DHD Symbol", ActivationMatrix.Translation, 진실);
                    MyAPIGateway.Session.GPS.AddLocalGps(m_selectedButton);
                }
                또 다른
                {
                    m_selectedButton.Coords = ActivationMatrix.Translation;
                }

                // This section provides the HUD help text when the player aims at the interaction with Control Hints enabled.
                // 메모, the game control key label is wrapped around [], which causes it to turn yellow in the notification.
                var hint = "누르다 {0} to activate symbol on {1}";
                return new MyActionDescription()
                {
                    Text = MyStringId.GetOrCompute(힌트),
                    FormatParams = new[] { "[" + MyAPIGateway.Input.GetGameControl(MyControlsSpace.USE) + "]", m_dhd?.DisplayNameText },
                    IsTextControlHint = true,
                };
            case UseActionEnum.OpenTerminal:
                return new MyActionDescription()
                {
                    Text = MySpaceTexts.NotificationHintPressToOpenControlPanel,
                    FormatParams = new [] { "[" + MyAPIGateway.Input.GetGameControl(MyControlsSpace.TERMINAL) + "]", m_dhd?.DefinitionDisplayNameText },
                    IsTextControlHint = true,
                };
            기본:
                return default(MyActionDescription);
        }
    }

    // This is called when the player is no longer aiming at the interaction dummy.
    public override void OnSelectionLost()
    {
        // Remove the HUD marker
        if(m_selectedButton != null)
            MyAPIGateway.Session.GPS.RemoveLocalGps(m_selectedButton);
        m_selectedButton = null;
    }

    // This is called when the player interacts with the object (presses the assigned keybind).
    public override void Use(UseActionEnum actionEnum, IMyEntity user)
    {
        스위치 (actionEnum)
        {
            case UseActionEnum.Manipulate:
                노력하다
                {
                    var button = int.Parse( this.Dummy .Name.Substring( this.Dummy .Name.LastIndexOf('_') + 1 ) ) - 1;

                    // Place whatever code you want here to perform the action you wish to do.
                    // This example toggles the block On/Off action; note this example requires a MyFunctionalBlock,
                    // but you can use a regular MyTerminalBlock, depending on what you want to do.
                    m_dhd.Enabled = !m_dhd.Enabled
                }
                catch(Exception)
                { /* avoid crashing the game, however you should write a message to the log */ }
                부서지다;
            case UseActionEnum.OpenTerminal:
                // There's no way to open the terminal just yet.
                부서지다;
        }
    }
}

Testing

Once you have the model, and code set up, you can load it up in the game, like you would any mod. The steps for creating a mod, 일반적으로, is outside the scope of this guide.

After you load it, you can view the dummy by enabling debug draw in the ModAPI debug menu (Shift-F11). 목표, and you should see your help text if you have Control Hints enabled in the game options. Push your assigned keybind on it, and watch it perform the action you want!

이것이 오늘 우리가 공유하는 모든 것입니다. 우주 엔지니어 가이드. 이 가이드는 원래 작성자가 작성하고 작성했습니다. Gwindalmir. 이 가이드를 업데이트하지 못한 경우, 다음을 수행하여 최신 업데이트를 찾을 수 있습니다. 링크.

이 사이트의 콘텐츠가 귀하의 권리를 침해한다고 생각하는 경우, 귀하의 지적 재산권을 포함하여, 문의 양식을 사용하여 즉시 문의하십시오..
가이드 태그:우주 엔지니어

탐색 후

이전 게시물: Critter Crunch Achievement Guide
다음 게시물: Omno Achievement Guide

답장을 남겨주세요 답장 취소

귀하의 이메일 주소는 공개되지 않습니다. 필수 입력란이 표시되어 있습니다 *

  • 제목: 우주 엔지니어
  • 출시일: 2월 28, 2019
  • 개발자: 예리한 소프트웨어 하우스
  • 발행자: 예리한 소프트웨어 하우스

부인 성명

인용된 모든 콘텐츠는 해당 소스에서 파생됩니다.. 귀하의 콘텐츠를 허가 없이 사용했다고 생각되는 경우, 우리에게 연락하면 진지하게 받아 들일 것입니다..
  • 회사 소개
  • 문의하기
  • 개인 정보 정책
  • 서비스 약관

저작권 © 2025 라이엇 비트.

에 의해 구동 프레스북 뉴스 WordPress 테마