static int GetComponentsInChildren(IntPtr L) { int count = LuaDLL.lua_gettop(L); if (count == 2) { Entity obj = LuaScriptMgr.GetNetObject <Entity>(L, 1); Type arg0 = LuaScriptMgr.GetTypeObject(L, 2); Component[] o = obj.GetComponentsInChildren(arg0); LuaScriptMgr.PushArray(L, o); return(1); } else if (count == 3) { Entity obj = LuaScriptMgr.GetNetObject <Entity>(L, 1); Type arg0 = LuaScriptMgr.GetTypeObject(L, 2); bool arg1 = LuaScriptMgr.GetBoolean(L, 3); Component[] o = obj.GetComponentsInChildren(arg0, arg1); LuaScriptMgr.PushArray(L, o); return(1); } else { LuaDLL.luaL_error(L, "invalid arguments to method: Entity.GetComponentsInChildren"); } return(0); }
void FindVisibleTargets() { VisibleTargets.Clear(); Collider[] targetsInViewRadius = Physics.OverlapSphere(transform.position, viewRadius, visionMask); for (int i = 0; i < targetsInViewRadius.Length; i++) { Entity target = targetsInViewRadius[i].GetComponentInParent <Entity>(); if (target != null && target.teamId != selfEntity.teamId) { Collider targetVisionCollider = target.GetComponentsInChildren <Collider>() .Where(x => visionMask == (visionMask | (1 << x.gameObject.layer))).FirstOrDefault(); Vector3 targetPosition = targetVisionCollider != null ? targetVisionCollider.bounds.center : target.transform.position; Vector3 myPosition = myVisionCollider != null ? myVisionCollider.bounds.center : transform.position; Vector3 dirToTarget = (targetPosition - myPosition).normalized; if (Vector3.Angle(transform.forward, dirToTarget) <= viewAngle / 2) { float dstToTarget = Vector3.Distance(myPosition, targetPosition); if (!Physics.Raycast(myPosition, dirToTarget, dstToTarget, obstacleMask)) { VisibleTargets.Add(target); } } } } if (isClient && VisibleTargets.Count > 0) { visibilityManager.AddVisibleTargets(VisibleTargets); } }
private void ApplyChams(Entity entity, Color color) { foreach (Renderer renderer in entity.GetComponentsInChildren <Renderer>()) { renderer.material = chamsMaterial; renderer.material.SetColor(_Color, color); } }
public void Load(Entity owner) { Slots = owner.GetComponentsInChildren <EquipmentSlot>(); foreach (var slot in Slots) { slot.Owner = owner; } }
public override void OnInspectorGUI() { var found = entity.GetComponentsInChildren <Trait>(); var problems = new List <Problem>(); using (new EditorGUILayout.VerticalScope()) { using (new EditorGUILayout.HorizontalScope()) { EditorGUILayout.LabelField($"Traits ({found.Length})", EditorStyles.boldLabel); button.OnInspectorGUI(); } EditorGUILayout.Space(); if (EditorApplication.isPlaying) { GUILayout.Label( new GUIContent { image = Icons.console_infoicon, text = "Please exit play mode to inspect entity" }, Styles.CenteredLabel ); return; } DrawTraitTree(found, problems); } if (problems.IsEmpty()) { return; } using (new EditorGUILayout.VerticalScope(EditorStyles.helpBox)) { EditorGUILayout.LabelField("Problems: ", EditorStyles.boldLabel); foreach (var problem in problems) { using (new EditorGUILayout.HorizontalScope(EditorStyles.helpBox)) { GUILayout.Label(new GUIContent(problem.Description, Icons.console_erroricon), ProblemStyle.Value); var solution = problem.Solution; if (solution == null) { continue; } if (GUILayout.Button( solution.Description, GUILayout.ExpandHeight(true) )) { solution.Action(); } } } } }
private void SetColor() { var renderers = Entity.GetComponentsInChildren <Renderer>() .Where(i => i.name != "Projection"); var color = IsCPU ? "Units_red" : "Units_blue"; var path = $"{colorsTextures}/{color}"; var mat = Resources.Load(path, typeof(Material)) as Material; renderers.ForEach(r => r.material = mat); }
/*------------------------------------------------------------------*\ |* PRIVATE METHODES \*------------------------------------------------------------------*/ private void SetColor() { var exclude = new List <string> { "Projection", "Minimap", "NamePlate" }; var renderers = entity.GetComponentsInChildren <Renderer>() .Where(i => !exclude.Contains(i.name)); var path = CreatePath(); var mat = Resources.Load(path, typeof(Material)) as Material; renderers.ForEach(r => r.material = mat); }
void Start() { if (Multiplayer) { scopone = new ScoponeManager(); scopone.INIT(this); } else { scopa = new ScopaManager(); scopa.Init(this); allPlayers = FindObjectsOfType <Entity>(); } tablecards_images = GetComponentsInChildren <Image>(); //deactive used card images foreach (var p in allPlayers) { //p.UsedCard.enabled = false; if (p.isPlayer) { player = p; } else { pc = p; } } playerButtons = player.GetComponentsInChildren <Button>(); //deactive yellow borders foreach (var b in tablecardBorders) { b.enabled = false; } //initialize deck and pass this reference deck = GetComponentInChildren <DeckController>(); if (!Multiplayer) { deck.Init(this); currentPlayer = player; } else { deck.MultiplayerInit(this, allPlayers); scopone.goToNextTurn(); } Scopatxt = GameObject.Find("Scopa"); Scopatxt.SetActive(false); }
public void StartFindEnergySourceQuest() { if (MainChar == null) { return; } //create a deranged bot ChunkCoords emptyChunk = EntityGenerator.GetNearbyEmptyChunk(); SpawnableEntity se = EntityGenerator.GetSpawnableEntity("deranged bot"); Entity newEntity = EntityGenerator.SpawnOneEntityInChunk(se, null, emptyChunk); //set waypoint to new bot //attach dialogue prompt when player approaches bot VicinityTrigger entityPrompt = newEntity.GetComponentsInChildren <VicinityTrigger>() .Where(t => t.gameObject.layer == LayerMask.NameToLayer("VicinityTrigger")).FirstOrDefault(); Action <IActor> triggerEnterAction = null; triggerEnterAction = (IActor actor) => { if (!(actor is Shuttle)) { return; } StartDialogue(foundDerangedBotConversation, false); entityPrompt.OnEnteredTrigger -= triggerEnterAction; }; entityPrompt.OnEnteredTrigger += triggerEnterAction; List <QuestReward> qRewards = new List <QuestReward>(); List <QuestRequirement> qReqs = new List <QuestRequirement>(); Waypoint wp = Waypoint.CreateWaypoint(MainChar, entityPrompt, entityPrompt.PivotPosition); qReqs.Add(new GatheringQReq(Item.Type.CorruptedCorvorite, MainChar, "Find the nearby energy source.", wp)); Quest q = new Quest( "Acquire an Energy Source", "The ship appears intact, however it is in a powered-down state. We need to find an energy source.", MainQuester, qRewards, qReqs); q.OnQuestComplete += CompletedFindEnergySourceQuest; GiveQuest(MainQuester, q); }
public virtual void OnAttachEntity(Entity target) { WeaponBase[] weapons = target.GetComponentsInChildren<WeaponBase>(); GameObject effectTmp; if (this.weaponEffect == null) return; foreach (WeaponBase weapon in weapons) { effectTmp = GameObject.Instantiate(this.weaponEffect) as GameObject; if (weapon.mesh != null) { effectTmp.transform.parent = weapon.mesh.transform; effectTmp.transform.localPosition = Vector3.zero; effectTmp.transform.localRotation = Quaternion.identity; effectTmp.transform.localScale = Vector3.one; this._weaponEffectActif.Add(effectTmp); } } }
public override void ApplyEntityEffect(Entity target) { ElementalDoT[] dotElem = target.GetComponentsInChildren<ElementalDoT>(); if (dotElem != null && dotElem.Length != 0) { for (int i = 0, size = dotElem.Length; i < size; ++i) { if (dotElem[i].element == this.dotPrefab.element) { dotElem[i].ResetTimer(); return; } } } GameObject dot = GameObject.Instantiate(this.dotPrefab.gameObject) as GameObject; dot.transform.parent = target.transform; dot.transform.localPosition = Vector3.zero; dot.transform.localRotation = Quaternion.identity; dot.transform.localScale = Vector3.one; dot.GetComponent<ElementalDoT>().entity = target; }
public override void OnInspectorGUI() { var found = entity.GetComponentsInChildren <Trait>(); var problems = new List <Problem>(); using (new EditorGUILayout.VerticalScope(EditorStyles.helpBox)) { using (new EditorGUILayout.HorizontalScope()) { EditorGUILayout.LabelField($"Traits ({found.Length})", EditorStyles.boldLabel); button.OnInspectorGUI(); } EditorGUILayout.Space(); if (EditorApplication.isPlaying) { GUILayout.Label( new GUIContent { image = Icons.console_infoicon, text = "Please exit play mode to inspect entity" }, Styles.CenteredLabel ); return; } foreach (var trait in found) { trait.TryClaim(entity, found, out var dependencies, false); if (dependencies == null) { continue; } using (new EditorGUILayout.HorizontalScope(Styles.box)) { var content = new GUIContent(trait.GetType().Name); if (!dependencies.Problems.IsEmpty()) { TsukiGUILayout.Icon(Icons.console_erroricon, 16); } EditorGUILayout.PrefixLabel(content); EditorGUILayout.Space(0, true); var obj = Selection.activeObject; var editable = true; if (obj == trait) { editable = false; } else if (obj is GameObject go && go == trait.gameObject) { editable = false; } using (new GUIEnabledScope(editable)) { if (GUILayout.Button("Select", GUILayout.Height(22), GUILayout.Width(32F * 4))) { Selection.activeObject = trait; } } if (GUILayout.Button(Icons.treeeditor_trash, GUILayout.Height(22), GUILayout.Width(22))) { Delete(trait); } } problems.AddRange(dependencies.Problems); } } if (problems.IsEmpty()) { return; } using (new EditorGUILayout.VerticalScope(EditorStyles.helpBox)) { EditorGUILayout.LabelField("Problems: ", EditorStyles.boldLabel); foreach (var problem in problems) { using (new EditorGUILayout.HorizontalScope(EditorStyles.helpBox)) { GUILayout.Label(new GUIContent(problem.Description, Icons.console_erroricon), ProblemStyle.Value); var solution = problem.Solution; if (solution == null) { continue; } if (GUILayout.Button( solution.Description, GUILayout.ExpandHeight(true) )) { solution.Action(); } } } } }
public void Load(Entity owner) { Sprites = owner.GetComponentsInChildren <OrientationControlledSprite>(); }