Besiege mod "ModernAirCombat"

mod name: ModernAirCombat

Setup of mod

1
$createmod "ModernAirCombat"

modify ./Mod.xml

  • Author
  • Description
1
$createblock "ModernAirCombat" "SRAAM"
1
mkdir ./Resources/SRAAM

add assets of SRAAM block r73.obj, r73.png

modify ./Mod.xml

  • Add resources
    1
    2
    <Mesh name="SRAAM Mesh" path="SRAAM\r73.obj"/>
    <Texture name="SRAAM Texture" path="SRAAM\r73.png"/>
    SRAAM-apppearance

modify ./SRAAM.xml

  • Mass
  • Mesh name
  • Texture name
  • Icon
  • Colliders
  • Points

create assembly for scripts

1
createassembly "ModernAirCombat" compiled MacAssembly ModernAirCombat forceUnityTools

open project with VStudio

edit ModernAirCombat.cs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
using System;
using Modding;
using UnityEngine;

namespace ModernAirCombat
{
public enum BlockList
{
SRAAM = 1,
MRAAM = 2,
LRAAM = 3
}
public class ModernAirCombat : ModEntryPoint
{
public static GameObject Mod;
public override void OnLoad()
{
Mod = new GameObject("Morden Firearm Kit Mod");
UnityEngine.Object.DontDestroyOnLoad(Mod); \\avoid destroy mod instance when changing levels
Debug.Log("Hello, this is Modern Air Combat!");
// Called when the mod is loaded.
}
}
}

Write Block Scripts

add a block class SRAAM.cs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
using System.Collections;

using Modding.Modules;
using Modding;
using Modding.Blocks;
using UnityEngine;

namespace ModernAirCombat
{
class SRAAMBlock : BlockScript
{
public MToggle IFF;
public MSlider detectAngleSlider;
private Transform myTransform; //实例化Transform对象
private Rigidbody myRigidbody;

public override void SafeAwake()
{
IFF = AddToggle("开启友伤", "IFF", true);
detectAngleSlider = AddSlider("探测角度", "detection angle", 45.0f, 0.0f, 150.0f);
}
private void Start()
{
myTransform = gameObject.GetComponent<Transform>(); //获取相应对象的引用
myRigidbody = gameObject.GetComponent<Rigidbody>();
myRigidbody.drag = 2;
myRigidbody.angularDrag = 4;
}

public override void OnSimulateStart()
{
base.OnSimulateStart();
}

public override void OnSimulateStop()
{
base.OnSimulateStop();
}

private void Update() {
myRigidbody.AddRelativeForce(new Vector3(0, 1, 0), ForceMode.Impulse);
}
}
}

modify SRAAM.xml

1
<Script>ModernAirCombat.SRAAMBlock</Script>