예제 #1
0
        public static StaticGeometryComponent CreateStaticRigidBody(Entity parent, TransformComponent transform, H2vMap map, TagRef <HaloModelTag> hlmtRef, int damageLevel = 0)
        {
            if (map.TryGetTag(hlmtRef, out var hlmt) == false)
            {
                return(null);
            }

            return(new StaticGeometryComponent(parent, transform)
            {
                Collider = ColliderFactory.GetTriangleColliderForHlmt(map, hlmt, damageLevel)
            });
        }
예제 #2
0
        public static RigidBodyComponent CreateKinematicRigidBody(Entity parent, TransformComponent transform, H2vMap map, TagRef <HaloModelTag> hlmtRef, int damageLevel = 0)
        {
            if (map.TryGetTag(hlmtRef, out var hlmt) == false)
            {
                throw new Exception($"Couldn't find HLMT[{hlmtRef.Id}]");
            }

            RigidBodyComponent body;

            if (!map.TryGetTag(hlmt.PhysicsModel, out var phmo) || phmo.BodyParameters.Length == 0)
            {
                return(null);
            }

            var param = phmo.BodyParameters[0];

            body = new RigidBodyComponent(parent, transform, param.InertiaTensor, param.Mass, param.CenterOfMass)
            {
                IsDynamic = false,
                Collider  = ColliderFactory.GetTriangleColliderForHlmt(map, hlmt, damageLevel)
            };

            return(body);
        }
예제 #3
0
        public static RigidBodyComponent CreateDynamicRigidBody(Entity parent, TransformComponent transform, H2vMap map, TagRef <HaloModelTag> hlmtRef, int damageLevel = 0)
        {
            if (map.TryGetTag(hlmtRef, out var hlmt) == false)
            {
                throw new Exception($"Couldn't find HLMT[{hlmtRef.Id}]");
            }

            RigidBodyComponent body;


            if (map.TryGetTag(hlmt.PhysicsModel, out var phmo) && phmo.BodyParameters.Length > 0)
            {
                var param = phmo.BodyParameters[0];

                body          = new RigidBodyComponent(parent, transform, param.InertiaTensor, param.Mass, param.CenterOfMass);
                body.Collider = ColliderFactory.GetAggregateColliderForPhmo(map, phmo, damageLevel);
            }
            else
            {
                body = new RigidBodyComponent(parent, transform);
            }

            return(body);
        }