磁石modは、Besiegeに便利な磁石を追加するものである。 磁石の記述はinterfaceとして実装したうえでモジュール化する。
Magnet mod adds useful magnets to Besiege. The script of magnetic blocks is implemented as a combination of custom module and interface.
磁性ブロックは以下のように示されるクーロンの法則に従う。
ここで、
Magnetic blocks follows Coulomb's law described as bellow, where
We define
計算量の増大を防ぐため、クーロンの法則が適用されるブロックの距離の最大値
To avoid an increase in the number of calculations, we define the maximum distance
public interface IMonopole
{
// 極の位置を取得する Get the position of the pole
public Vector3 GetPolePosition();
// 磁気量を取得する Get the magnetic charge
public float GetCharge();
// 磁力を計算する Calcurate the magnetic force and get it
public float GetForce(Monopole other);
}
public class Monopole : CustomModule, IMonopole
{
protected Transform m_pole;
public Vector3 GetPolePosition() => m_pole.position;
protected float m_charge;
public float GetCharge() => m_charge;
public float GetForce(Monopole other)
{
// 仕様通りに実装する
// This will be implemented as Specifications
}
// 毎フレーム呼ばれる関数にAddForceを追加しておくこと
// Write AddForce() in the function called in every frames.
public void Update()
{
}
}単極子(monopole)を想定する。
We assume monopole.
- テスト用磁石 Magnet for test
- 天然磁石 Magnet 常に磁性を持つ
- 電磁石 Electromagnet キー入力時に磁性を持つ
実装未定。/ TBD.