示例#1
0
        public void SetVisual(string visualName)
        {
            if (string.Equals(visual, visualName, StringComparison.OrdinalIgnoreCase))
            {
                return;
            }

            this.render = true;
            this.visual = visualName;
            if (zenTree != null)
            {
                zenTree.ReleaseVobSubTree();
                zenTree = null;
            }

            if (!string.IsNullOrWhiteSpace(visualName))
            {
                if (visualName.EndsWith(".ZEN", StringComparison.OrdinalIgnoreCase))
                {
                    renderVob.SetVisual(new zCVisual(0));

                    Gothic.zCOption.ChangeDir(0xE); // world directory
                    zenTree = rndrWorld.MergeVobSubTree(visualName);
                    if (zenTree.Address != 0)
                    {
                        zenTree.AddRefVobSubtree();
                        rndrWorld.RemoveVobSubTree(zenTree);
                        return;
                    }
                    else
                    {
                        Logger.LogWarning("Could not load " + visualName);
                        zenTree = null;
                    }
                }
                else
                {
                    renderVob.SetVisual(zCVisual.LoadVisual(visualName));
                    return;
                }
            }
            renderVob.SetVisual(new zCVisual(0));
            render = false;
        }
示例#2
0
        public override zCVob CreateVob(zCVob vob = null)
        {
            zCVob ret = vob == null?zCVob.Create() : vob;

            var visualName = this.ModelInstance.Visual;

            if (visualName.EndsWith(".ZEN"))
            {
                ret.SetVisual(new zCVisual(0));
                ret.SetCollDetDyn(false);
                ret.SetCollDetStat(false);
                Gothic.zCOption.ChangeDir(0xE); // world directory
                var world = GothicGlobals.Game.GetWorld();
                world.AddVob(ret);
                ret.SetPositionWorld(0, 0, 0);

                zCVob zenVob = world.MergeVobSubTree(visualName);
                if (zenVob.Address != 0)
                {
                    zenVob.SetCollDetDyn(false);
                    zenVob.SetCollDetStat(false);
                    zenVob.SetPositionWorld(0, 0, 0);
                    ret.TrafoObjToWorld.Set(zenVob.TrafoObjToWorld);
                    zenVob.AddRefVobSubtree();
                    world.RemoveVobSubTree(zenVob);
                    world.AddVobAsChild(zenVob, ret);
                    world.RemoveVobSubTree(ret);
                }
                else
                {
                    Log.Logger.LogWarning("Could not load " + visualName);
                }
            }
            else
            {
                zCVisual vis = zCVisual.LoadVisual(this.ModelInstance.Visual);
                ret.SetVisual(vis);
            }

            ret.SetCollDetDyn(CDDyn);
            ret.SetCollDetStat(CDStatic);

            return(ret);
        }