This forum is locked and will eventually go offline. If you have feedback to share you can find us in our Discord channel "MythoLogic Interactive" https://discord.gg/nECKnbT7gk

Forum rules

Add category bit constants

Give us your input on how we may improve the ScriptAPI in the game in future versions.
Forum rules
By using the forum you agree to the following rules.
Locked
NearHuscarl
Superfighter
Superfighter
Posts: 97
Joined: Thu Feb 07, 2019 4:36 am

Add category bit constants

Post by NearHuscarl » Sun Mar 22, 2020 7:17 pm

I'd be nice to have a way to specify category bit by name instead of number which is less readable. Here is a helper class copied straight from my script. Maybe add more documentation to help scripters know what each one of these are about

Code: Select all

    public static class CategoryBits
    {
        internal const ushort None = 0x0000;

        /// <summary>
        /// Static impassable objects (wall, ground, plate...)
        /// </summary>
        internal const ushort StaticGround = 0x0001;
        internal const ushort DynamicPlatform = 0x0002;
        internal const ushort Player = 0x0004;
        /// <summary>
        /// Dynamic objects that can collide with player without setting IObject.TrackAsMissle(true)
        /// Example: table, chair, couch, crate...
        /// </summary>
        internal const ushort DynamicG1 = 0x0008;
        /// <summary>
        /// Dynamic objects that cannot collide with player but can collide with other dynamic objects
        /// Set IObject.TrackAsMissle(true) to make them collide with players
        /// Example: glass, cup, bottle, weapons on map...
        /// </summary>
        internal const ushort DynamicG2 = 0x0010;
        internal const ushort Dynamic = DynamicG1 + DynamicG2;

        internal const ushort Items = 0x0020;
        internal const ushort Debris = 0x0010;
        internal const ushort DynamicsThrown = 0x8000;
    }
Usage

Code: Select all

var rayCastInput = new RayCastInput()
{
   MaskBits = CategoryBits.StaticGround + CategoryBits.DynamicPlatform,
   FilterOnMaskBits = true,
};
1 x
Image

User avatar
Gurt
Lead Programmer
Lead Programmer
Posts: 1887
Joined: Sun Feb 28, 2016 3:22 pm
Title: Lead programmer
Started SFD: Made it!
Location: Sweden
Gender:
Age: 36

Post by Gurt » Sun Mar 22, 2020 8:28 pm

You can see the main collision bits used in SFD by looking in the collisionGroups.sfdx file in the installation folder. Just open it in notepad.
0 x
Gurt

NearHuscarl
Superfighter
Superfighter
Posts: 97
Joined: Thu Feb 07, 2019 4:36 am

Post by NearHuscarl » Mon Mar 23, 2020 6:25 am

Whenever I need to fill the MaskBits parameter, I need to open that file which is a bit inconvenient. That's why I made this suggestion, make your code self-document would be nicer. This suggestion is not important to me, I already had this class but it may help other scripters since those maskbit values are hard to read
0 x
Image

Locked