예제 #1
0
        public override async Task <GamePlay.Actor.GActor> CreateActor(Editor.PlantableItemCreateActorParam param)
        {
            var rc = EngineNS.CEngine.Instance.RenderContext;

            var actor = new EngineNS.GamePlay.Actor.GActor();

            actor.ActorId = Guid.NewGuid();
            var placement = new EngineNS.GamePlay.Component.GPlacementComponent();

            actor.Placement    = placement;
            placement.Location = param.Location;

            var init = new OctreeVolumeComponentInitializer();

            init.SpecialName = "VolumeData";
            await SetInitializer(rc, actor, actor, init);

            if (mActorOctree == null)
            {
                mActorOctree = new Octree();
                mActorOctree.LinkedActorId = actor.ActorId;
            }

            mLineMeshComponent.Host = actor;
            var mat = actor.Placement.WorldMatrix;

            mLineMeshComponent.OnUpdateDrawMatrix(ref mat);
            //var aabb = new BoundingBox(-0.5f, -0.5f, -0.5f, 0.5f, 0.5f, 0.5f);
            //BoundingBox.Merge(ref actor.LocalBoundingBox, ref aabb, out actor.LocalBoundingBox);

            actor.AddComponent(this);
            return(actor);
        }
예제 #2
0
        public async System.Threading.Tasks.Task <GamePlay.Actor.GActor> CreateTitanActor(
            [Editor.Editor_RNameType(Editor.Editor_RNameTypeAttribute.Mesh)]
            RName mesh,
            Vector3 lookOffset, float radius, float height,
            [Editor.Editor_RNameType(Editor.Editor_RNameTypeAttribute.PhyMaterial)]
            RName phyMtl)
        {
            var titanActor = await EngineNS.GamePlay.Actor.GActor.NewMeshActorAsync(mesh);

            titanActor.SpecialName = "TitanActor";
            this.World.AddActor(titanActor);
            this.World.DefaultScene.AddActor(titanActor);

            var tpcComp = new EngineNS.GamePlay.Camera.ThirdPersonCameraComponent();

            titanActor.AddComponent(tpcComp);
            tpcComp.SetCamera(this.GameCamera, 4.0f, lookOffset);
            var physxCtr   = new EngineNS.Bricks.PhysicsCore.GPhyControllerComponent();
            var phyCtrInit = new EngineNS.Bricks.PhysicsCore.GPhyControllerComponent.GPhyControllerComponentInitializer();

            phyCtrInit.IsBox         = false;
            phyCtrInit.CapsuleRadius = radius;
            phyCtrInit.CapsuleHeight = height;
            phyCtrInit.MaterialName  = phyMtl;
            await physxCtr.SetInitializer(CEngine.Instance.RenderContext, titanActor, titanActor, phyCtrInit);

            titanActor.AddComponent(physxCtr);

            ControlActor = titanActor;
            return(titanActor);
        }
예제 #3
0
        public async Task <GActor> CreateActor(Editor.PlantableItemCreateActorParam param)
        {
            await EngineNS.Thread.AsyncDummyClass.DummyFunc();

            var rc = EngineNS.CEngine.Instance.RenderContext;

            var actor = new EngineNS.GamePlay.Actor.GActor();

            actor.ActorId = Guid.NewGuid();
            var placement = new EngineNS.GamePlay.Component.GPlacementComponent();

            actor.Placement    = placement;
            placement.Location = param.Location;
            placement.Rotation = EngineNS.Quaternion.GetQuaternion(Vector3.UnitZ, -Vector3.UnitY);
            actor.SpecialName  = "SunActor";

            var initializer = new GDirLightComponentInitializer();

            initializer.SpecialName = "LightData";
            await SetInitializer(rc, actor, actor, initializer);

            this.View = param.View;

            var meshComp     = new EngineNS.GamePlay.Component.GMeshComponent();
            var meshCompInit = new EngineNS.GamePlay.Component.GMeshComponent.GMeshComponentInitializer();

            meshCompInit.SpecialName = "VisualMesh";
            meshCompInit.MeshName    = EngineNS.RName.GetRName("editor/sun.gms", EngineNS.RName.enRNameType.Game);
            var test = meshComp.SetInitializer(rc, actor, actor, meshCompInit);

            actor.AddComponent(meshComp);

            actor.AddComponent(this);
            return(actor);
        }
예제 #4
0
        public async Task InitParticleSubSystemComponent(EngineNS.GamePlay.Actor.GActor actor, GParticleComponent particlecomponent, CGfxParticleSystem sys)
        {
            var rc = EngineNS.CEngine.Instance.RenderContext;

            ParticleModifier = new CGfxParticleModifier();
            ParticleModifier.SetParticleSystem(sys);

            GMeshComponentInitializer initializer = new GMeshComponentInitializer();

            await SetInitializer(rc, actor, particlecomponent, initializer);

            SpecialName       = string.IsNullOrEmpty(sys.Name) ? Guid.NewGuid().ToString() : sys.Name;
            EditorVisibleName = sys.EditorVisibleName;
            particlecomponent.AddComponent(this);

            Host = actor;

            var mPlacementData = Placement.mPlacementData;

            Placement = new GParticlePlacementComponent();
            await Placement.SetInitializer(rc, actor, this, mPlacementData as GComponentInitializer);

            Placement.SetMatrix(ref sys.Matrix);

            ((GParticlePlacementComponent)Placement).IsIgnore = !sys.IsBind;

            sys.HostActorMesh = this;
        }
예제 #5
0
        public async Task <GActor> CreateActor(Editor.PlantableItemCreateActorParam param, RName MacrossName)
        {
            var rc = EngineNS.CEngine.Instance.RenderContext;

            await EngineNS.Thread.AsyncDummyClass.DummyFunc();

            var actor = new EngineNS.GamePlay.Actor.GActor();

            actor.ActorId = Guid.NewGuid();
            var placement = new EngineNS.GamePlay.Component.GPlacementComponent();

            actor.Placement    = placement;
            placement.Location = param.Location;

            var init = new GParticleComponentInitializer();

            init.SpecialName = "ParticleData";
            init.MacrossName = MacrossName;
            await SetInitializer(rc, actor, actor, init);

            actor.AddComponent(this);

            var meshComp     = new EngineNS.GamePlay.Component.GMeshComponent();
            var meshCompInit = new EngineNS.GamePlay.Component.GMeshComponent.GMeshComponentInitializer();

            meshCompInit.SpecialName = "EditorShow";
            meshCompInit.MeshName    = EngineNS.RName.GetRName("meshes/icon_particle.gms", EngineNS.RName.enRNameType.Editor);
            await meshComp.SetInitializer(rc, actor, actor, meshCompInit);

            meshComp.HideInGame = true;
            actor.AddComponent(meshComp);

            return(actor);
        }
예제 #6
0
        public Actor.GActor FindNearestActor(Vector3 pos, float radius, List <Actor.GActor> ignoreList = null)
        {
            Actor.GActor result  = null;
            float        curDist = float.MaxValue;

            using (var it = Actors.Values.GetEnumerator())
            {
                while (it.MoveNext())
                {
                    if (it.Current.Placement == null)
                    {
                        continue;
                    }
                    if (ignoreList != null)
                    {
                        if (ignoreList.Contains(it.Current))
                        {
                            continue;
                        }
                    }

                    var dist = Vector3.Distance(ref it.Current.Placement.mPlacementData.mLocation, ref pos);
                    if (dist > radius)
                    {
                        continue;
                    }
                    if (dist < curDist)
                    {
                        curDist = dist;
                        result  = it.Current;
                    }
                }
            }
            return(result);
        }
예제 #7
0
 public void InitProxy(HitProxyManager mgr)
 {
     Actor            = GActor.NewMeshActorDirect(null);
     Checked          = false;
     BindObject       = null;
     Actor.ActorProxy = this;
     mgr.MapActor(Actor);
 }
예제 #8
0
        public async System.Threading.Tasks.Task <GActor> GetPrefabFistChild(CRenderContext rc, RName name, bool clone = false)
        {
            GPrefab result;
            bool    found = false;

            lock (Prefabs)
            {
                if (Prefabs.TryGetValue(name, out result) == false)
                {
                    result = new GPrefab();
                    Prefabs.Add(name, result);
                }
                else
                {
                    found = true;
                }
            }

            if (found)
            {
                await result.AwaitLoad();

                if (clone)
                {
                    GActor cloneprefab = await result.Children[0].Clone(EngineNS.CEngine.Instance.RenderContext);
                    //cloneprefab.Placement.Transform = cloneprefab.Placement.Transform * result.Placement.Transform;
                    return(cloneprefab);
                }
                return(result.Children[0]);
            }

            var xnd = await IO.XndHolder.LoadXND(name.Address);

            if (xnd == null)
            {
                Profiler.Log.WriteLine(Profiler.ELogTag.Error, "IO", "Prefab RName error!");
                return(null);
            }
            if (false == await result.LoadXnd(rc, xnd.Node))
            {
                xnd.Node.TryReleaseHolder();
                return(null);
            }
            xnd.Node.TryReleaseHolder();
            result.Name = name;

            if (clone)
            {
                GActor cloneprefab = await result.Children[0].Clone(EngineNS.CEngine.Instance.RenderContext);
                //cloneprefab.Placement.Transform = cloneprefab.Placement.Transform * result.Placement.Transform;
                return(cloneprefab);
            }
            return(result.Children[0]);
        }
예제 #9
0
 public void AddEditorActor(Actor.GActor actor)
 {
     if (EditorActors.ContainsKey(actor.ActorId))
     {
         return;
     }
     EditorActors[actor.ActorId] = actor;
     actor.OnAddToWorld(this);
     for (int i = 0; i < actor.Children.Count; ++i)
     {
         AddEditorActor(actor.Children[i]);
     }
 }
예제 #10
0
        GActor NewMeshActor(CGfxMesh mesh)
        {
            var rc    = CEngine.Instance.RenderContext;
            var actor = new EngineNS.GamePlay.Actor.GActor();

            actor.ActorId = Guid.NewGuid();
            var placement = new EngineNS.GamePlay.Component.GPlacementComponent();

            actor.Placement = placement;
            var meshComp = new EngineNS.GamePlay.Component.GMeshComponent();

            meshComp.SetSceneMesh(rc.ImmCommandList, mesh);
            actor.AddComponent(meshComp);
            return(actor);
        }
예제 #11
0
        public void AddActor(Actor.GActor actor)
        {
            if (Actors.ContainsKey(actor.ActorId))
            {
                return;
            }
            mActorsDictionaryDirty = true;
            Actors[actor.ActorId]  = actor;
            actor.OnAddToWorld(this);

            for (int i = 0; i < actor.Children.Count; ++i)
            {
                AddActor(actor.Children[i]);
            }
            OnAddActor?.Invoke(actor);
        }
예제 #12
0
 public void UnmapActor(GActor actor)
 {
     lock (ProxyedActors)
     {
         if (actor.HitProxyId == 0)
         {
             return;
         }
         ProxyedActors.Remove(actor.HitProxyId);
         actor.HitProxyId = 0;
         for (int i = 0; i < actor.Children.Count; ++i)
         {
             UnmapActor(actor.Children[i]);
         }
     }
 }
예제 #13
0
        //public bool NeedToUpdateHitProxy = false;
        //public bool HitProxyIsNewest = false;

        public void MapActor(GActor actor)
        {
            lock (ProxyedActors)
            {
                if (actor.HitProxyId != 0)
                {
                    return;
                }

                actor.HitProxyId = ++HitProxyAllocatorId;
                //if(actor.HitProxyId == 0)
                //    actor.HitProxyId = ++HitProxyAllocatorId;
                ProxyedActors[actor.HitProxyId] = new WeakReference <GActor>(actor);
                for (int i = 0; i < actor.Children.Count; ++i)
                {
                    MapActor(actor.Children[i]);
                }
            }
        }
예제 #14
0
        public override async Task <GamePlay.Actor.GActor> CreateActor(Editor.PlantableItemCreateActorParam param)
        {
            await EngineNS.Thread.AsyncDummyClass.DummyFunc();

            var rc = EngineNS.CEngine.Instance.RenderContext;

            var actor = new EngineNS.GamePlay.Actor.GActor();

            actor.ActorId = Guid.NewGuid();
            var placement = new EngineNS.GamePlay.Component.GPlacementComponent();

            actor.Placement    = placement;
            placement.Location = param.Location;
            placement.Rotation = EngineNS.Quaternion.GetQuaternion(Vector3.UnitZ, -Vector3.UnitY);

            var meshComp     = new EngineNS.GamePlay.Component.GMeshComponent();
            var meshCompInit = new EngineNS.GamePlay.Component.GMeshComponent.GMeshComponentInitializer();

            meshCompInit.SpecialName = "EditorShow";
            meshCompInit.MeshName    = EngineNS.RName.GetRName("meshes/go_on.gms", EngineNS.RName.enRNameType.Editor);
            await meshComp.SetInitializer(rc, actor, actor, meshCompInit);

            meshComp.HideInGame                = true;
            meshComp.Placement.InheritScale    = false;
            meshComp.Placement.InheritRotation = false;
            actor.AddComponent(meshComp);

            var init = new BoxComponentInitializer();

            init.SpecialName = "NavMeshBoundVolume";
            await SetInitializer(rc, actor, actor, init);

            mLineMeshComponent.Host = actor;
            var mat = actor.Placement.WorldMatrix;

            mLineMeshComponent.OnUpdateDrawMatrix(ref mat);

            actor.AddComponent(this);

            return(actor);
        }
예제 #15
0
        async System.Threading.Tasks.Task <GActor> NewMeshActor(CGfxMeshPrimitives meshPri)
        {
            var rc    = CEngine.Instance.RenderContext;
            var actor = new EngineNS.GamePlay.Actor.GActor();

            actor.ActorId = Guid.NewGuid();
            var placement = new EngineNS.GamePlay.Component.GPlacementComponent();

            actor.Placement = placement;
            var meshComp = new EngineNS.GamePlay.Component.GMeshComponent();
            var mesh     = CEngine.Instance.MeshManager.CreateMesh(rc, meshPri);
            var mtl      = await EngineNS.CEngine.Instance.MaterialInstanceManager.GetMaterialInstanceAsync(rc, RName.GetRName("Material/defaultmaterial.instmtl"));

            for (int i = 0; i < mesh.MtlMeshArray.Length; ++i)
            {
                await mesh.SetMaterialInstanceAsync(rc, (uint)i, mtl, null);
            }
            meshComp.SetSceneMesh(rc.ImmCommandList, mesh);
            actor.AddComponent(meshComp);

            return(actor);
        }
예제 #16
0
        public async System.Threading.Tasks.Task <GActor> ConvertToActor(CRenderContext rc)
        {
            var result = new GActor();
            var init   = Initializer.CloneObject() as GActorInitializer;

            init.ActorId = Guid.NewGuid();
            result.SetInitializer(init);
            for (int i = 0; i < Components.Count; ++i)
            {
                var comp = await Components[i]?.CloneComponent(rc, result, result);
                result.AddComponent(comp);
            }

            foreach (var i in Children)
            {
                var actor = await i.Clone(rc);

                actor.SetParent(result);
                actor.OnActorLoaded();
            }
            result.OnActorLoaded();
            return(result);
        }
예제 #17
0
        public async Task <GActor> CreateActor(Editor.PlantableItemCreateActorParam param)
        {
            var rc = EngineNS.CEngine.Instance.RenderContext;

            await EngineNS.Thread.AsyncDummyClass.DummyFunc();

            var actor = new EngineNS.GamePlay.Actor.GActor();

            actor.ActorId = Guid.NewGuid();
            var placement = new EngineNS.GamePlay.Component.GPlacementComponent();

            actor.Placement    = placement;
            placement.Location = param.Location;

            var init = new GParticleComponentInitializer();

            init.SpecialName = "ParticleData";
            await SetInitializer(rc, actor, actor, init);

            actor.AddComponent(this);

            return(actor);
        }
예제 #18
0
 public float GetActorDistance(GActor target)
 {
     return(Vector3.Distance(ref Placement.mPlacementData.mLocation, ref target.Placement.mPlacementData.mLocation));
 }
예제 #19
0
 public void AddHelpMeshComponentHelp(CRenderContext rc, EngineNS.GamePlay.Actor.GActor actor, EngineNS.Bricks.Particle.CGfxParticleSystem sys)
 {
     AddHelpMeshComponent(rc, actor, sys);
 }
예제 #20
0
 public virtual void OnUnsetMacross(GActor actor)
 {
 }
예제 #21
0
        public virtual async System.Threading.Tasks.Task OnInit(GActor actor)
        {
            await Thread.AsyncDummyClass.DummyFunc();

            //actor.CreateCenterData();
        }
예제 #22
0
 public virtual void OnCleanup(GActor actor)
 {
 }
예제 #23
0
 public virtual void OnTick(GActor actor)
 {
 }
예제 #24
0
 public virtual async System.Threading.Tasks.Task OnLoadedAll(GActor actor)
 {
     await Thread.AsyncDummyClass.DummyFunc();
 }