Modding:Block Entity/ru: Difference between revisions

From Vintage Story Wiki
Created page with "<syntaxhighlight lang="c#"> public class TickingBlockEntity : BlockEntity { } </syntaxhighlight>"
(Created page with "== Сущность блока ==")
(Created page with "<syntaxhighlight lang="c#"> public class TickingBlockEntity : BlockEntity { } </syntaxhighlight>")
Line 17: Line 17:
== Сущность блока ==
== Сущность блока ==


<div lang="en" dir="ltr" class="mw-content-ltr">
Теперь нам нужно зарегистрировать наш класс blockentity и поэтому нам нужно создать новый файл *.cs в нашем проекте. Назовем его <code>Ticking.cs</code>.
Now we need to register our blockentity class and therefore we need to create a new *.cs file in our project. Let's name it <code>Ticking.cs</code>.
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
Прежде всего вам нужно создать сам класс blockentity. Поэтому вам нужно расширить <code>BlockEntity</code>:
First of all you need to create the blockentity class itself. Therefore you need to extend <code>BlockEntity</code>:
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
<syntaxhighlight lang="c#">
<syntaxhighlight lang="c#">
     public class TickingBlockEntity : BlockEntity
     public class TickingBlockEntity : BlockEntity
Line 32: Line 27:
     }
     }
</syntaxhighlight>
</syntaxhighlight>
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
----
----
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
Этот класс должен иметь таймер, когда таймер достигает 3 секунд, он должен заменить текущий блок другим состоянием.
This class needs to have a timer, once the timer reaches 3 seconds it should replace the current block with the different state.
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
Чтобы создать таймер, нам нужно зарегистрировать прослушиватель тиков. Поэтому нам нужно переопределить <code>Initialize(ICoreAPI)</code>:
In order to create a timer we need to register a tick listener. Therefore we need to override <code>Initialize(ICoreAPI)</code>:
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
Confirmedusers
13,514

edits