public AnimatedModelAdapter(AasSystem aasSystem, AasHandle handle, AnimatedModel model, bool borrowed = false)
 {
     aasSystem_ = aasSystem;
     handle_    = handle;
     model_     = model;
     borrowed_  = borrowed;
 }
Esempio n. 2
0
    public static void DestroyRendering(this GameObject obj)
    {
        GameSystems.Light.RemoveAttachedTo(obj);

        var renderPalette = obj.GetInt32(obj_f.render_palette);

        if (renderPalette != 0)
        {
            // I think most of this is 2D rendering which is unused
            throw new NotImplementedException();
            // TODO sub_101EBD40(v1);
            obj.SetInt32(obj_f.render_palette, 0);
        }

        var renderColors = obj.GetUInt32(obj_f.render_colors);

        if (renderColors != 0)
        {
            throw new NotImplementedException();

            // TODO I think most of this is 2D rendering which is unused
            // TODO v3 = *(_DWORD *)(renderColors - 4);
            // TODO *(_DWORD *)(v3 + 4) = dword_107880A0;
            // TODO dword_107880A0 = (void *)v3;

            obj.SetInt32(obj_f.render_colors, 0);
        }

        var renderFlags = obj.GetUInt32(obj_f.render_flags);

        // Clear flags 76000000
        obj.SetUInt32(obj_f.render_flags, renderFlags & 0x89FFFFFF);

        var animHandle = new AasHandle(obj.GetUInt32(obj_f.animation_handle));

        if (animHandle)
        {
            GameSystems.AAS.ModelFactory.FreeHandle(animHandle.Handle);
            obj.SetUInt32(obj_f.animation_handle, 0);
        }

        GameSystems.ParticleSys.InvalidateObject(obj);
    }
Esempio n. 3
0
    public static IAnimatedModel GetOrCreateAnimHandle(this GameObject obj)
    {
        // I think this belongs to the map_obj subsystem
        if (obj == null)
        {
            return(null);
        }

        // An animation handle was already created
        var animHandle = new AasHandle(obj.GetUInt32(obj_f.animation_handle));

        if (animHandle)
        {
            return(GameSystems.AAS.ModelFactory.BorrowByHandle(animHandle.Handle));
        }

        // Which object to retrieve the model properties from (this indirection
        // is used for polymorph)
        var modelSrcObj = obj;

        // If the obj is polymorphed, use the polymorph proto instead
        int polyProto = GameSystems.D20.D20QueryInt(obj, D20DispatcherKey.QUE_Polymorphed);

        if (polyProto != 0)
        {
            modelSrcObj = GameSystems.Proto.GetProtoById((ushort)polyProto);
        }

        var meshId     = modelSrcObj.GetInt32(obj_f.base_mesh);
        var skeletonId = modelSrcObj.GetInt32(obj_f.base_anim);
        var idleAnimId = obj.GetIdleAnimId();
        var animParams = obj.GetAnimParams();

        // Create the model from the meshes.mes IDs and store the result in the obj
        var model = GameSystems.AAS.ModelFactory.FromIds(
            meshId,
            skeletonId,
            idleAnimId,
            animParams,
            true // Borrowed since we store the handle in the obj
            );

        model.OnAnimEvent += evt => HandleAnimEvent(obj, evt);
        obj.SetUInt32(obj_f.animation_handle, model.GetHandle());

        if (obj.IsCritter())
        {
            GameSystems.Critter.UpdateModelEquipment(obj);
        }

        if (obj.type == ObjectType.npc)
        {
            GameSystems.Critter.AddNpcAddMeshes(obj);
        }

        var flags = obj.GetFlags();

        if (!flags.HasFlag(ObjectFlag.HEIGHT_SET))
        {
            UpdateRenderHeight(obj, model);
        }

        if (!flags.HasFlag(ObjectFlag.RADIUS_SET))
        {
            UpdateRadius(obj, model);
        }

        return(model);
    }