public override void ResolveCollision(DoorCollisionResponse other) { if (isProjectile) { Entity.Destroy(entity); } var transform = entity.GetComponent <Transform>(); transform.position = transform.lastPosition; }
public override void BeginExecute() { var action = OwnerEntity.CreateAction <DamageAction>(); action.Target = AttackAction.Target; action.DamageSource = DamageSource.Attack; action.ApplyDamage(); Entity.Destroy(action); this.EndExecute(); }
void ITriggerListener.OnTriggerEnter(Collider other, Collider self) { _hitCounter++; if (_hitCounter >= HitsUntilDead) { Entity.Destroy(); return; } _sprite.Color = Color.Red; Core.Schedule(0.1f, timer => _sprite.Color = Color.White); }
public void Remove(IAutomaton automaton) { if (!_objs.ContainsKey(automaton)) { return; } var obj = _objs[automaton]; Entity.Destroy(obj); _objs.Remove(automaton); }
public override void Update(GameTime gameTime) { // set currentTime upon first call if (startTimer) { time += (float)gameTime.ElapsedGameTime.TotalMilliseconds; if (time >= Constants.ITEM_DELETION_TIME_MS) { Entity.Destroy(entity); } } }
public override async ETTask ExecuteTaskAsync() { var taskData = taskInitData as CreateTriggerTaskData; TriggerObj = GameObject.Instantiate(taskData.TriggerPrefab, taskData.Position, Quaternion.identity); TriggerObj.GetComponent <OnTriggerEnterCallback>().OnTriggerEnterCallbackAction = (other) => { OnTriggerEnterCallbackAction?.Invoke(other); }; TriggerObj.GetComponent <Collider>().enabled = true; await TimerComponent.Instance.WaitAsync(100); GameObject.Destroy(TriggerObj); Entity.Destroy(this); }
void DrawEntityContextMenuPopup(Entity entity) { if (ImGui.BeginPopup("entityContextMenu")) { if (ImGui.Selectable("Clone Entity " + entity.Name)) { var clone = entity.Clone(Core.Scene.Camera.Position); entity.Scene.AddEntity(clone); } if (ImGui.Selectable("Destroy Entity")) { entity.Destroy(); } if (ImGui.Selectable("Create Child Entity", false, ImGuiSelectableFlags.DontClosePopups)) { ImGui.OpenPopup("create-new-entity"); } if (ImGui.BeginPopup("create-new-entity")) { ImGui.Text("New Entity Name:"); ImGui.InputText("##newChildEntityName", ref _newEntityName, 25); if (ImGui.Button("Cancel")) { _newEntityName = ""; ImGui.CloseCurrentPopup(); } ImGui.SameLine(ImGui.GetContentRegionAvail().X - ImGui.GetItemRectSize().X); ImGui.PushStyleColor(ImGuiCol.Button, Microsoft.Xna.Framework.Color.Green.PackedValue); if (ImGui.Button("Create")) { _newEntityName = _newEntityName.Length > 0 ? _newEntityName : Utils.RandomString(8); var newEntity = new Entity(_newEntityName); newEntity.Transform.SetParent(entity.Transform); entity.Scene.AddEntity(newEntity); _newEntityName = ""; ImGui.CloseCurrentPopup(); } ImGui.PopStyleColor(); ImGui.EndPopup(); } ImGui.EndPopup(); } }
public static string Destroy(string[] args, GameController ctrl) { Entity e = ctrl.Cursor.HoveredCell.Actor; if (e == null) { return($"Nothing under the cursor to destroy."); } e.Destroy(null); return($"Destroyed entity {e.ToString()}"); }
void CheckHit(ColliderHitEvent hitEvent) { var otherEntity = hitEvent.HitCollider.GetComponent <Entity>(); if (otherEntity != bulletComponent.Owner) { Debug.Log("Hit " + otherEntity); Entity.Destroy(); otherEntity.Destroy(); // todo CeresECL add health example } }
protected override void Process(GameTime gameTime, Entity entity) { var expires = entity.Get <ExpiresComponent>(); expires.LifeTime -= gameTime.ElapsedGameTime; if (expires.LifeTime > TimeSpan.Zero) { return; } entity.Destroy(); expires.LifeTime = TimeSpan.Zero; }
private void Update() { var sessions = GetEntities <Session>().Select(e => e.Item1); foreach (var session in sessions) { if (Time.time > session.lastReceived + session.timeout) { var connection = session.connection; Entity.Destroy(session.gameObject); } } }
public void ComponentCreatedInvokedWhenAComponentIsCreated() { var entity = new Entity(new VariableCollection()); this.collection.Add(entity); var called = false; collection.ObjectAdded += (x) => { called = true; }; entity.AddComponent <FakeComp>(); Assert.IsTrue(called); entity.Destroy(); }
public async ETTask ApplyTurn() { PreProcess(); var jumpToAction = Creator.CreateAction <JumpToAction>(); jumpToAction.Target = Creator.GetEnemy(Creator.SeatNumber); await jumpToAction.ApplyJumpTo(); Entity.Destroy(jumpToAction); PostProcess(); }
private void OnEntityDeployedWithPlacer(Fougerite.Player player, Entity e, Fougerite.Player actualplacer) { if (e != null && !e.IsDestroyed) { if (DataStore.GetInstance().ContainsKey("AdminDuty", player.SteamID)) { e.Destroy(); player.Inventory.AddItem(e.Name); player.InventoryNotice("1 x " + e.Name + ""); player.MessageFrom("AntiAbuse", "[color #42b3f5]You [color #45f542]Can't [color #42b3f5]Build while you are in Admin-Duty!"); } } }
public void acquire() { if (!acquired) { energy = 0; var tw = spriteRenderer.TweenColorTo(Color.Black, tweenDur); tw.SetCompletionHandler(t => { Entity?.Destroy(); }); tw.Start(); spriteRenderer.Transform.TweenLocalScaleTo(0.5f, tweenDur).Start(); } acquired = true; }
public void ObjectRemovedInvokedWhenAnEntityIsDestroyed() { var entity = new Entity(new VariableCollection()); this.collection.Add(entity); var called = false; collection.ObjectRemoved += (x) => { called = true; }; entity.Destroy(); MonocleObject.LifeTimeManager.DestroyObjectsFlaggedForDestruction(); Assert.IsTrue(called); }
public void ObjectAddedInvokedWhenAnEntityIsAdded() { Entity e = null; collection.ObjectAdded += (x) => { e = (Entity)x; }; var entity = new Entity(new VariableCollection()); collection.Add(entity); Assert.AreSame(e, entity); entity.Destroy(); }
private void OnClose(Object server, Socket client) { var connection = clients.Where(c => c.socket == client).FirstOrDefault(); if (connection == null) { return; } clients.Remove(connection); ECSEvent.Create <ServerOnCloseEvent>(gameObject, connection); Entity.Destroy(connection.gameObject); }
public override void UpdateState(Entity entity, GameTime gameTime) { var tile = entity as Tile; if (tile.State.InTransition) { tile.Animator.Play(AnimationDictionary.TileDestroy); tile.State.InTransition = false; } else if (!tile.Animator.IsPlaying) { Entity.Destroy(tile); } }
float time = 0; // ms public override void Update(GameTime gameTime) { // Translate by the angle for the given amount of time float delta = (float)gameTime.ElapsedGameTime.TotalMilliseconds; entity.GetComponent <Transform>().position += new Vector2((float)Math.Cos(angle) * delta * Constants.FIREBALL_SPEED, (float)Math.Sin(angle) * delta * Constants.FIREBALL_SPEED); // Destroy if it's been around for long enough time += (float)gameTime.ElapsedGameTime.TotalMilliseconds; if (time > Constants.FIREBALL_LIFETIME_MS) { Entity.Destroy(entity); } }
private void Finish() { Percent = IsReverse ? 0 : 1; Increment(); switch (Mode) { case TweenMode.Persist: IsActive = false; break; case TweenMode.OneShot: IsActive = false; Entity?.Destroy(); break; case TweenMode.Loop: TargetValue = InitialValue; Begin(); break; case TweenMode.Yoyo: if (!IsReverse) { StartTween(); } else { IsActive = false; } IsReverse = !IsReverse; if (!IsActive) { OnFinish?.Invoke(); } return; case TweenMode.Restart: StartTween(); break; default: throw new Exception($"[Tween]: Invalid Tween Mode '{Mode}'."); } OnFinish?.Invoke(); }
private bool AddScoreAndDestroy(Entity e) { ParentComponent parent = e.GetComponent <ParentComponent>(); if (parent != null && this.EntityWorld.EntityManager.IsAlive(parent.ParentId)) { this.EntityWorld.ComponentManager.GetComponent <ScoreComponent>(parent.ParentId).Value++; this.signalManager.AddSignal(SignalType.PointScored, parent.ParentId); } e.Destroy(); this.signalManager.AddSignal(SignalType.EntityDestroyed, e.EntityId); return(true); }
public override async ETTask ExecuteTaskAsync() { var taskData = taskInitData as CreateColliderTaskData; ColliderObj = GameObject.Instantiate(taskData.ColliderPrefab, taskData.Position, Quaternion.identity); ColliderObj.SetActive(true); ColliderObj.GetComponent <Collider>().enabled = false; ColliderObj.transform.eulerAngles = new Vector3(0, taskData.Direction, 0); ColliderObj.GetComponent <OnTriggerEnterCallback>().OnTriggerEnterCallbackAction = (other) => { taskData.OnTriggerEnterCallback?.Invoke(other); }; ColliderObj.GetComponent <Collider>().enabled = true; await TimerComponent.Instance.WaitAsync(taskData.LifeTime); GameObject.Destroy(ColliderObj); Entity.Destroy(this); }
public void PerformBehaviour(Entity target, Entity instigator) { var maxRange = target.GetExplosionRange(); var maxDamage = target.GetExplosionDamage(); var nearbyEntities = _engine.GetEntitiesWithinArea(target.GetPosition(), maxRange); foreach (var other in nearbyEntities.Where(item => item.EntityId != target.EntityId)) { var distance = other.GetPosition().Distance(target.GetPosition()); var dmg = maxRange - maxDamage * Math.Log(distance, maxRange); other.TakeDamage((float)dmg, DamageTypeEnum.HighExplosion, target); } target.Destroy(); }
private bool SplitAndOrDestroy(Entity e) { TransformComponent transform = e.GetComponent <TransformComponent>(); if (transform.Scale.X > GameConfig.Asteroid.MinScale) // split { Vector2 newScale = Vector2.One * ((transform.Scale.X == 1.0) ? GameConfig.Asteroid.Medium / GameConfig.Asteroid.Large : GameConfig.Asteroid.Small / GameConfig.Asteroid.Large); this.entityFactory.AddAsteroid(this.EntityWorld.EntityManager.CreateEntity(), transform.Position, transform.Rotation + ((float)Math.PI / 6f), newScale); this.entityFactory.AddAsteroid(this.EntityWorld.EntityManager.CreateEntity(), transform.Position, transform.Rotation - ((float)Math.PI / 6f), newScale); } e.Destroy(); this.signalManager.AddSignal(SignalType.EntityDestroyed, e.EntityId); return(true); }
public override void Update(GameTime time, Entity entity) { base.Update(time, entity); var timer = (Timed_Destroy)entity.Get(Types.Timed_Destroy); if (timer.Time_Left <= 0) { entity.Destroy(); } else { timer.Time_Left -= (float)time.ElapsedGameTime.TotalSeconds; } }
public void DestroyModel() { if (modelEntity == null) { return; } #if UNITY_WSA DestroyImmediate(modelWorldAnchor); #endif modelEntity.Destroy(); modelEntity = null; DestroyImmediate(modelEntityGO); }
public virtual void Update() { if (Stats.Health > 0) { UpdateAnimations(); UpdateMovement(); UpdateColliders(); CheckAttackUnit(); } else if (Die()) { Entity.Destroy(); } }
// 删除实体 public bool Remove(Entity entity) { if (entity == null) { return(false); } uint uid = entity.UID; //销毁实体 entity.Destroy(); m_entityDic.Remove(uid); return(true); }
public void Destroy() { foreach (var transform in Root.GetComponent <Transform>().Children) { Entity entity = transform.entity; if (entity != null) { Entity.Destroy(entity); } } Root.GetComponent <Transform>().Children.Clear(); TransformSystem.CleanUp(); ColliderSystem.CleanUp(); BehaviorScriptSystem.CleanUp(); SpriteSystem.CleanUp(); }
private Entity SporeBase(int mX, int mY, float mDegrees, int mSpeed, string mTextureName, bool mEnemy) { var result = new Entity(_manager); var cBody = Body(new SSVector2I(mX, mY), 250, 250); var cMovement = Movement(cBody); var cRender = Render(cBody, mTextureName); cBody.Body.AddGroupsToCheck(Groups.Obstacle, Groups.Character); cBody.Body.AddGroupsToIgnoreResolve(Groups.Obstacle, Groups.Character); cBody.OnCollision += (mCollisionInfo) => { var entity = (Entity)mCollisionInfo.UserData; var cHealth = entity.GetComponent<CHealth>(); if (result.HasTag(Tags.SporeBlack) && entity.HasTag(Tags.DamagedByWhite)) { cHealth++; result.Destroy(); } else if (result.HasTag(Tags.SporeWhite) && entity.HasTag(Tags.DamagedByBlack)) { cHealth++; result.Destroy(); } if (entity.HasTag(Tags.DestroysBullets)) result.Destroy(); }; cMovement.Angle = mDegrees; cMovement.Speed = mSpeed; cMovement.Acceleration = -0.1f; cRender.Torque = 8; result.AddComponents(cBody, cMovement, cRender); result.AddTags(Tags.Spore); cRender.Sprite.Color = new Color(255, 255, 255, 125); return result; }
private Entity BulletBase(int mX, int mY, float mDegrees, int mSpeed, string mTextureName, bool mEnemy) { var result = new Entity(_manager); var cBody = Body(new SSVector2I(mX, mY), 250, 250); var cMovement = Movement(cBody); var cRender = Render(cBody, mTextureName); cBody.Body.AddGroupsToCheck(Groups.Obstacle, Groups.Character); cBody.Body.AddGroupsToIgnoreResolve(Groups.Obstacle, Groups.Character); cBody.OnCollision += (mCollisionInfo) => { var entity = (Entity) mCollisionInfo.UserData; var cHealth = entity.GetComponent<CHealth>(); if (entity.HasTag(Tags.DamagedByAny)) { cHealth.Health--; result.Destroy(); } else if (result.HasTag(Tags.BulletFriendly) && entity.HasTag(Tags.DamagedByFriendly)) { cHealth.Health--; result.Destroy(); } else if (result.HasTag(Tags.BulletEnemy) && entity.HasTag(Tags.DamagedByEnemy)) { cHealth.Health--; result.Destroy(); } if (entity.HasTag(Tags.DestroysBullets)) result.Destroy(); }; cMovement.Angle = mDegrees; cMovement.Speed = mSpeed; cRender.Torque = 8; result.AddComponents(cBody, cMovement, cRender); result.AddTags(Tags.Bullet); return result; }
public static void Kill(Entity mEntity) { mEntity.Destroy(); TDLSounds.Play("SoundKill1"); }