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); }
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); }
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); }
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; }
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); }
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); }
public void InitProxy(HitProxyManager mgr) { Actor = GActor.NewMeshActorDirect(null); Checked = false; BindObject = null; Actor.ActorProxy = this; mgr.MapActor(Actor); }
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]); }
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]); } }
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); }
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); }
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]); } } }
//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]); } } }
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); }
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); }
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); }
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); }
public float GetActorDistance(GActor target) { return(Vector3.Distance(ref Placement.mPlacementData.mLocation, ref target.Placement.mPlacementData.mLocation)); }
public void AddHelpMeshComponentHelp(CRenderContext rc, EngineNS.GamePlay.Actor.GActor actor, EngineNS.Bricks.Particle.CGfxParticleSystem sys) { AddHelpMeshComponent(rc, actor, sys); }
public virtual void OnUnsetMacross(GActor actor) { }
public virtual async System.Threading.Tasks.Task OnInit(GActor actor) { await Thread.AsyncDummyClass.DummyFunc(); //actor.CreateCenterData(); }
public virtual void OnCleanup(GActor actor) { }
public virtual void OnTick(GActor actor) { }
public virtual async System.Threading.Tasks.Task OnLoadedAll(GActor actor) { await Thread.AsyncDummyClass.DummyFunc(); }