protected override void OnUpdate() { for (var i = 0; i < playersShooting.Length; i++) { var commandSender = playersShooting.ModifyHealthCommandSenders[i]; var commandSent = false; var gunId = playersShooting.Gun[i].GunId; var gunSettings = GunDictionary.Get(gunId); var damage = gunSettings.ShotDamage; foreach (var shot in playersShooting.Shots[i].Events) { var shotInfo = shot; if (!ValidateShot(shotInfo)) { continue; } // Send command to entity being shot. var modifyHealthRequest = HealthComponent.ModifyHealth.CreateRequest( new EntityId(shotInfo.EntityId), new HealthModifier() { Amount = -damage, Origin = shotInfo.HitOrigin, AppliedLocation = shotInfo.HitLocation }); commandSender.RequestsToSend.Add(modifyHealthRequest); commandSent = true; } if (commandSent) { playersShooting.ModifyHealthCommandSenders[i] = commandSender; } } }
private void OnGunChanged(int gunId) { CurrentGunSettings = GunDictionary.Get(gunId); SetGunSettings(); }