Beispiel #1
0
    public void PreProcess(IPrefabProcessor preProcess, GameObject rootObj, string name, bool serverside, bool clientside, bool bundling)
    {
        List <HitboxDefinition> obj = Pool.GetList <HitboxDefinition>();

        GetComponentsInChildren(obj);
        if (serverside)
        {
            foreach (HitboxDefinition item2 in obj)
            {
                preProcess?.RemoveComponent(item2);
            }
            preProcess?.RemoveComponent(this);
        }
        if (clientside)
        {
            hitboxes.Clear();
            foreach (HitboxDefinition item3 in obj.OrderBy((HitboxDefinition x) => x.priority))
            {
                HitboxShape item = new HitboxShape
                {
                    bone             = item3.transform,
                    localTransform   = item3.LocalMatrix,
                    colliderMaterial = item3.physicMaterial,
                    type             = item3.type
                };
                hitboxes.Add(item);
                preProcess?.RemoveComponent(item3);
            }
        }
        Pool.FreeList(ref obj);
    }
Beispiel #2
0
    public Hitbox(Rect boundaries, HitboxType hitboxType)
    {
        Type       = hitboxType;
        Position   = Vector3.zero;
        Boundaries = boundaries;

        //Always assume default as rectangle
        Shape = HitboxShape.Rectangle;
    }
Beispiel #3
0
    public Hitbox(Rect boundaries, HitboxType hitboxType)
    {
        Type = hitboxType;
        Position = Vector3.zero;
        Boundaries = boundaries;

        //Always assume default as rectangle
        Shape = HitboxShape.Rectangle;
    }
Beispiel #4
0
        public Hitbox MakeHitbox(Vector2 position, HitboxShape shape, Vector3 dimensions)
        {
            Transform hitboxTransform = new Transform(transform, null, position);

            if (shape == HitboxShape.Rectangle)
            {
                return(hitbox = new RectangleHitbox(hitboxTransform, dimensions, this));
            }
            else
            {
                return(null);
            }
        }
Beispiel #5
0
        public GameObject(Vector2 position, Vector2 hitboxPosition, HitboxShape shape, Vector3 dimensions, Texture2D texture, GameObject parent = null)
        {
            DefaultConstructor();
            if (parent != null)
            {
                SetParent(parent);
                transform = new Transform(parent.transform, texture, position);
            }
            else
            {
                transform = new Transform(texture, position);
            }

            MakeHitbox(hitboxPosition, shape, dimensions);
        }