Changes

Jump to navigation Jump to search

Documentation/Engine/Units

2,010 bytes added, 01:40, 19 December 2018
What is unit?
=What is unit?=
Units are objects in Prism3d that have ability to inside SCS game engine. One of their core abilities is so they can be serialized or deserializedmaking it a perfect tool to give content creators a way to define various parts of the games.
Unit has:
* Name - units can be nameless or have some specified name . Unit names are divided into components which are 12-char tokens separated by dot - for example correct unit name will be <code>vehicle.dummy.truck</code> incorrect will be <code>vehicledummytruck</code> however in most cases you should not use them as in case engine detects two units with the same name it will fail so , in case some mod is using name <code>vehicle.dummy.truck</code> and you will also use this your mod will fail to load. To create nameless unit simply use dot as the prefix for your unit name for example <code>.my_mod.nameless.units</code>* Attributes - attributes is a are set of the data that unit can store, it can be number, text, other unit connection, set of them etc. Some units are failing in case they contain serialized some attribute that is no longer supported however some of them have special flag in the engine to allow loading not allowed attributes.
== SII files ==
Units are stored in SII files. There are two versions of this file supported by the game engine textual : plain-text and binary however . However, only textual form the plain-text format is used for definitions.
=== Struture Structure ===
The magic mark - &ndash; used to check if the file is a real SII file or not.
<pre>SiiNUnitSiiNunit</pre>
The opening bracket used to explicitly show the global file scope start
attribute_number: 40
attribute_string: &quot;TEST STRING&quot;
attribute_tokenattribute_unit: TESTtest.unit attribute_vector3attribute_float3: (1.0, 1.0, 1.0)
attribute_float_number_ieee754: &amp;40490f5a
}</pre>
The closing bracked bracket for the SiiNUnitSiiNunit
<pre>}</pre>
 It's always good to add one blank line at the end of the file.
=== Unit definition entry ===
=== Includes ===
You can also include the contents of other files into another. To do this you need to use using the SII preprocessor directives directive - <code>@include</code>. The contents of the included file will be read as if they were in the file itself. '''Example:'''<br />''some_file_using_include.sii''<pre>SiiNunit{example: doing.includes{ foo: &quot;bar&quot; over: 9000@include &quot;some_file_to_include.sui&quot;}}</pre>''some_file_to_include.sui:''<pre> ninjas: true</pre>''How the game &ldquo;sees&rdquo; some_file_using_include.sii:''<pre>SiiNunit{example: doing.includes{ foo: &quot;bar&quot; over: 9000 ninjas: true}}</pre>You may notice usage of the new extension - '''.sui'''. It's used for unit serialized files without magic mark <code>SiiNunit</code> that are included somewhere in different files. We recommend you also use this extension.
{{Note|The <code>@include</code> directive must appear at the beginning of a new line with no whitespace (space, tab, etc) before it. The following examples will '''Example:not'''work:<pre>SiiNunit{bad_examples: just.the.worst { foo: &quot;bar&quot; @include &quot;dont_get_too_attached_to_indents.sui&quot;
<pre> foo: @include &quot;some_file_to_includeyou_definitely_cannot_use_it_inline.sui&quot;}}</pre>You may notice usage of the new extension - '''.sui'''. It's used for unit serialized files without magic mark <code>SiiNUnit</code> that are included somewhere in different files. We recommend you also using this extension.}}
== Attribute types ==
 
<pre>TODO: arrays</pre>
{| class="wikitable" width="100%"
!width="19%"| Type!width="25%"| Value!width="55%"| Example! Notes
|-
| string
| &quot;x&quot;
| attribute: &quot;String value&quot;
|
|-
| float
| x
| attribute: 1.0 // Using normal float-notation<br>attribute: &amp;3f800000 // using ieee754 hexa notation
|
|-
| float2
| (x, y)
| attribute: (1.0, 2.0)
|
|-
| float3
| (x, y, z)
| attribute: (1.0, 5.0, 3.0)
|
|-
| float4
| (x, y, z, w)
| attribute: (1.0, 5.0, 3.0, 9.0)
|
|-
| float4x4placement| ?(x, y, z) (w; x, y, z)| attribute: (0, 0, 0) (1; 0, 0, 0)| ?
|-
| fixed
| x
| ?attribute: 10|
|-
| fixed2
| (x, y)
| ?attribute: (10, 22)|
|-
| fixed3
| (x, y, z)
| ?attribute: (10, 22, 33)|
|-
| fixed4
| (x, y, z, w)
| ?attribute: (10, 22, 33, 44)|
|-
| int2
| (x, y)
| attribute: (20, 69)
|
|-
| quaternion
| (w, x, y, z)
| attribute: (1.0, 0.0, 0.0, 0.0)
|-| placement| ?| ?|-| placement_scale| ?| ?|-| placement_nonuniform| ?| ?|-| plane| ?| ?|-| aabox| ?| ?|-| token| x| attribute: value
|-
| s16
| x
| attribute: -15
|
|-
| s32
| x
| attribute: -15
|
|-
| s64
| x
| attribute: -15
|
|-
| u16
| x
| attribute: 15
|
|-
| u32
| x
| attribute: 15
|
|-
| u64
| x
| attribute: 15
|
|-
| bool (boolean)
| x
| attribute: true
 
attribute: false
|
|-
| <span id="attribute_type_token">token</span>
| x
| attribute: value
| Token is a string of maximum length of 12 characters, only lowercase alphanumeric characters and underscore can be used [<code>a-z0-9_</code>]
|-
| boolowner pointer (owner_ptr)
| x
| attribute: true.some.nameless.unit| '''owner_ptr''' refers to unit defined within the same SiiNunit (eg. <brcode>attribute: false.trailer.tchassis</code>)
|-
| unitlink pointer (link_ptr)
| x
| attribute: mysome.named.unit| '''link_ptr''' refers to a named unit that is defined elsewhere (eg. <code>cabin_a.brand.model.cabin</code>)|-| resource_tie| "x"| attribute: "path/to/some/resource.pma"| '''resource_tie''' is typically used to bind animations to animated models. The syntax is the same as for 'string' type attributes.
|}
 
===Arrays===
 
You can also use arrays of the values. The array syntax is:
 
<pre>
attribute_name[]: value
attribute_name[]: value2
attribute_name[]: value3
</pre>
 
In some cases you may notice fixed-arrays written in this format:
 
<pre>
attribute_name: 3 <-- Size of the array.
attribute_name[0]: 1 <-- 1st element
attribute_name[1]: 5 <-- 2nd element
attribute_name[2]: 9 <-- 3rd element
</pre>
 
=Documented Unit Types=
{{Special:PrefixIndex/Documentation/Engine/Units/|hideredirects=1|stripprefix=1}}
developer
1,626
edits

Navigation menu