Skip to content

Beam System

SmArtKar edited this page Jan 8, 2023 · 6 revisions

This article is for C# users who wish to use beams in their mods.

Beams are spawned via static methods of corresponding type - Beam.CreateActiveBeam and Beam.CreateStaticBeam respectively

public static Beam CreateActiveBeam(Thing beamStart, Thing beamEnd, ThingDef beamDef, Vector3 startOffset = new Vector3(), Vector3 endOffset = new Vector3()) { }

public static Beam CreateStaticBeam(Thing beamStart, Thing beamEnd, ThingDef beamDef, Vector3 startOffset = new Vector3(), Vector3 endOffset = new Vector3()) { }

public static Beam CreateStaticBeam(Vector3 beamStart, Vector3 beamEnd, ThingDef beamDef, Map map) { }

All of them return created beam objects

    public abstract class Beam : ThingWithComps
    {
        public Vector3 firstPoint;
        public Vector3 secondPoint;
        public Matrix4x4 matrix;

        public List<List<Material>> materials;
        public Material curMat;

        public int frameAmount = 0;
        public int frameDelayAmount = 0;

        public int currentFrame = 0;
        public int currentFrameTick = 0;

        public int sizeIndex = 0;
        public int sizeAmount = 0;
        public float maxRange = 0;

        public int ticksLeft = -1;
        public int fadeoutTicks = -1;
    }

Clone this wiki locally