|  |  |  | using System; | 
					
						
							|  |  |  | using System.Collections.Generic; | 
					
						
							|  |  |  | using UnityEngine; | 
					
						
							|  |  |  | using Entitas; | 
					
						
							|  |  |  | using Game; | 
					
						
							|  |  |  | using Articy.Touhou; | 
					
						
							|  |  |  | using CleverCrow.Fluid.BTs.Trees; | 
					
						
							|  |  |  | using FluidDynamics; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | namespace Game | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     public abstract partial class Util | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         public static Dictionary<Type, int> CompKeymap; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         public static int GetCompnentIndex<T>() | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             if (CompKeymap == null) | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 CompKeymap = new Dictionary<Type, int>(); | 
					
						
							|  |  |  |                 var compTypes = GameComponentsLookup.componentTypes; | 
					
						
							|  |  |  |                 for (int i = 0; i < compTypes.Length; i++) | 
					
						
							|  |  |  |                 { | 
					
						
							|  |  |  |                     CompKeymap[compTypes[i]] = i; | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             return CompKeymap[typeof(T)]; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | public partial class GameEntity | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     static GameEntity() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public void AddComponent<T>() where T : IComponent | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         var index = Util.GetCompnentIndex<T>(); | 
					
						
							|  |  |  |         var component = (T)CreateComponent(index, typeof(T)); | 
					
						
							|  |  |  |         AddComponent(index, component); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public void AddID(string cfgId, EntityCreateHandler callback) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         var newId = UtilID.GetID(EIdType.Entity); | 
					
						
							|  |  |  |         AddID(newId, new CommonData()); | 
					
						
							|  |  |  |         iD.Data.IsCreate = true; | 
					
						
							|  |  |  |         iD.Data.IsDestroy = false; | 
					
						
							|  |  |  |         iD.Data.CfgId = cfgId; | 
					
						
							|  |  |  |         iD.Data.CreateCallback = callback; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public void AddMonsterView(string[] prefabNames) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         var cfg = Util.GetMonsterConfigData(CfgId()); | 
					
						
							|  |  |  |         var monsterCfg = cfg.GetFeatureEntityParamMonster(); | 
					
						
							|  |  |  |         AddView(prefabNames[(int)monsterCfg.MonsterSize]); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public void AddView(string prefabPath) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         AddComponent<ViewComponent>(); | 
					
						
							|  |  |  |         var entityPoolItem = EntityPoolManager.Instance.CreateEntity(prefabPath); | 
					
						
							|  |  |  |         var go = entityPoolItem.GameObject; | 
					
						
							|  |  |  |         view.EntityPoolItem = entityPoolItem; | 
					
						
							|  |  |  |         view.GameObject = go; | 
					
						
							|  |  |  |         view.GameObjectLogic = go.transform.Find("logic").gameObject; | 
					
						
							|  |  |  |         view.TransformLogic = view.GameObjectLogic.transform; | 
					
						
							|  |  |  |         view.TransformView = go.transform.Find("view"); | 
					
						
							|  |  |  |         view.TransformViewRot = go.transform.Find("view/viewRot"); | 
					
						
							|  |  |  |         view.TransformViewOffset = go.transform.Find("view/viewRot/viewOffset"); | 
					
						
							|  |  |  |         view.TransformViewMain = go.transform.Find("view/viewRot/viewOffset/animator"); | 
					
						
							|  |  |  |         view.TransformViewOther = go.transform.Find("view/other"); | 
					
						
							|  |  |  |         var goInfo = go.GetComponent<EntityInfo>(); | 
					
						
							|  |  |  |         if (goInfo == null) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             goInfo = go.AddComponent<EntityInfo>(); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         goInfo.entityId = ID(); | 
					
						
							|  |  |  |         view.SpriteRenderer = view.TransformViewMain.GetComponent<SpriteRenderer>(); | 
					
						
							|  |  |  |         view.SpriteRenderer.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.On; | 
					
						
							|  |  |  |         view.SpriteRenderer.receiveShadows = true; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         view.Material = view.SpriteRenderer.material; | 
					
						
							|  |  |  |         view.Collider = go.GetComponent<Collider>(); | 
					
						
							|  |  |  |         view.LocalPositionOrder = Vector3.forward * GameRandom.Random(0, 0.01f); | 
					
						
							|  |  |  |         view.TransformViewRot.localRotation = GameConst.CommonRot; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public void AddMove() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         AddComponent<MoveComponent>(); | 
					
						
							|  |  |  |         var go = view.GameObject; | 
					
						
							|  |  |  |         move.Transform = go.transform; | 
					
						
							|  |  |  |         move.TransformViewMain = view.TransformViewMain; | 
					
						
							|  |  |  |         move.Rigidbody = go.GetComponent<Rigidbody>(); | 
					
						
							|  |  |  |         move.MoveParam = new MoveParam(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public void AddAnimation() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         AddComponent<AnimationComponent>(); | 
					
						
							|  |  |  |         var go = view.GameObject; | 
					
						
							|  |  |  |         animation.Animator = go.GetComponentInChildren<Animator>(); | 
					
						
							|  |  |  |         animation.AnimatorOverrideController = | 
					
						
							|  |  |  |             new AnimatorOverrideController(animation.Animator.runtimeAnimatorController); | 
					
						
							|  |  |  |         animation.Animator.runtimeAnimatorController = animation.AnimatorOverrideController; | 
					
						
							|  |  |  |         animation.ResetMsg = true; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public void AddTimeline() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         AddComponent<TimelineComponent>(); | 
					
						
							|  |  |  |         timeline.Timeline = new TimelineObject(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public void AddSkill() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         AddComponent<SkillComponent>(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public void AddCombo() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         AddComponent<ComboComponent>(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         //test 必须先加武器再加技能 | 
					
						
							|  |  |  |         Util.SetWeaponListAll(this); | 
					
						
							|  |  |  |         Util.AddSkillAll(this); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public void AddHp() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         AddComponent<HpComponent>(); | 
					
						
							|  |  |  |         hp.IsDamaged.Value = false; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public void AddPause() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         AddComponent<PauseComponent>(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public void AddInteract(EInteractType interactType) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         AddComponent<InteractComponent>(); | 
					
						
							|  |  |  |         interact.InteractType = interactType; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public void AddBullet() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         AddComponent<BulletComponent>(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public void AddAI() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         AddComponent<AIComponent>(); | 
					
						
							|  |  |  |         aI.ThinkCdMax = 1; //保底思考频率1秒 | 
					
						
							|  |  |  |         aI.HungryMax.Value = 1; //保底最大饥饿值1 | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public void AddBuff() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         AddComponent<BuffComponent>(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public void AddMasterSoul() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         AddComponent<MasterSoulComponent>(); | 
					
						
							|  |  |  |         masterSoul.Emitter = view.TransformViewMain.GetComponentInChildren<Fluid_Dynamics_Game_Emitter>(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public void AddPoint() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         AddComponent<PointComponent>(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public void AddBag() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         AddComponent<BagComponent>(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public void AddProperty() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         AddComponent<PropertyComponent>(); | 
					
						
							|  |  |  |         Util.ClearProperty(this); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } |