public TouchResponseData Touch(TouchData touchData) { if (_dead || !Game.CheckTeamVsTeam(touchData.teamId, teamId)) { return(TouchResponseData.empty); } Console.WriteLine($"Health {teamId} hurt by team {touchData.teamId}"); int previous = health; health -= touchData.damage; TouchResponseData result; result.damageTaken = touchData.damage; GFXQuick gfx = Main.i.factory.SpawnGFX(GameFactory.Path_GFXBloodImpact); gfx.Spawn(touchData.hitPos, touchData.hitNormal); if (health <= 0) { _dead = true; result.responseType = TouchResponseType.Killed; _onDeath?.Invoke(); } else { int change = health - previous; result.responseType = TouchResponseType.Damaged; _onHealthChange?.Invoke(health, change, touchData); } return(result); }
public TouchResponseData Touch(TouchData touchData) { if (_dead) { return(TouchResponseData.empty); } int previous = _health; _health -= touchData.damage; TouchResponseData result; result.damageTaken = touchData.damage; GFXQuick gfx = Main.i.factory.SpawnGFX(GameFactory.Path_GFXBloodImpact); gfx.Spawn(touchData.hitPos, touchData.hitNormal); if (_health <= 0) { _dead = true; result.responseType = TouchResponseType.Killed; _onDeath?.Invoke(); } else { int change = _health - previous; result.responseType = TouchResponseType.Damaged; _onHealthChange?.Invoke(_health, change, touchData); } return(result); }
public TouchResponseData ActorTouch(TouchData touchData) { //Console.WriteLine($"Mob hit for {touchData.damage}"); if (_dead) { return(TouchResponseData.empty); } _health -= touchData.damage; TouchResponseData result; result.damageTaken = touchData.damage; GFXQuick gfx = Main.i.factory.SpawnGFX(GameFactory.Path_GFXBloodImpact); gfx.Spawn(touchData.hitPos, touchData.hitNormal); if (_health <= 0) { result.responseType = TouchResponseType.Killed; _dead = true; RemoveActor(); } else { if (touchData.damageType == DamageType.Launch) { Console.WriteLine($"Mob - Launched!"); Main.i.mobThink.ApplyStun(this); } stunAccumulator += result.damageTaken; result.responseType = TouchResponseType.Damaged; pushAccumulator.x += -touchData.hitNormal.x * (15 * mobDef.pushMultiplier); pushAccumulator.z += -touchData.hitNormal.z * (15 * mobDef.pushMultiplier); //Console.WriteLine($"Push: {pushAccumulator}"); } return(result); return(TouchResponseData.empty); }