public override void Update(float deltaTime, Camera cam) { UpdateProjSpecific(deltaTime); if (CurrentFixer == null) { if (!ShouldDeteriorate()) { return; } if (item.Condition > 0.0f) { if (deteriorationTimer > 0.0f) { if (GameMain.NetworkMember == null || !GameMain.NetworkMember.IsClient) { deteriorationTimer -= deltaTime; #if SERVER if (deteriorationTimer <= 0.0f) { item.CreateServerEvent(this); } #endif } return; } if (item.Condition > MinDeteriorationCondition) { item.Condition -= DeteriorationSpeed * deltaTime; } } return; } if (Item.IsFullCondition || CurrentFixer.SelectedConstruction != item || !currentFixer.CanInteractWith(item)) { currentFixer.AnimController.Anim = AnimController.Animation.None; currentFixer = null; return; } UpdateFixAnimation(CurrentFixer); if (GameMain.NetworkMember != null && GameMain.NetworkMember.IsClient) { return; } float successFactor = requiredSkills.Count == 0 ? 1.0f : 0.0f; foreach (Skill skill in requiredSkills) { float characterSkillLevel = CurrentFixer.GetSkillLevel(skill.Identifier); if (characterSkillLevel >= skill.Level) { successFactor += 1.0f / requiredSkills.Count; } CurrentFixer.Info.IncreaseSkillLevel(skill.Identifier, SkillIncreaseMultiplier * deltaTime / Math.Max(characterSkillLevel, 1.0f), CurrentFixer.WorldPosition + Vector2.UnitY * 100.0f); } bool wasBroken = !item.IsFullCondition; float fixDuration = MathHelper.Lerp(FixDurationLowSkill, FixDurationHighSkill, successFactor); if (fixDuration <= 0.0f) { item.Condition = item.MaxCondition; } else { item.Condition += deltaTime / (fixDuration / item.MaxCondition); } if (wasBroken && item.IsFullCondition) { SteamAchievementManager.OnItemRepaired(item, currentFixer); deteriorationTimer = Rand.Range(MinDeteriorationDelay, MaxDeteriorationDelay); #if SERVER item.CreateServerEvent(this); #endif } }
public override void Update(float deltaTime, Camera cam) { UpdateProjSpecific(deltaTime); if (CurrentFixer == null) { if (!ShouldDeteriorate()) { return; } if (item.Condition > 0.0f) { if (deteriorationTimer > 0.0f) { if (GameMain.NetworkMember == null || !GameMain.NetworkMember.IsClient) { deteriorationTimer -= deltaTime; #if SERVER if (deteriorationTimer <= 0.0f) { item.CreateServerEvent(this); } #endif } return; } if (item.Condition > MinDeteriorationCondition) { item.Condition -= DeteriorationSpeed * deltaTime; } } return; } if (Item.IsFullCondition || CurrentFixer.SelectedConstruction != item || !currentFixer.CanInteractWith(item)) { currentFixer.AnimController.Anim = AnimController.Animation.None; currentFixer = null; return; } UpdateFixAnimation(CurrentFixer); if (GameMain.NetworkMember != null && GameMain.NetworkMember.IsClient) { return; } float successFactor = requiredSkills.Count == 0 ? 1.0f : 0.0f; //item must have been below the repair threshold for the player to get an achievement or XP for repairing it if (item.Condition < ShowRepairUIThreshold) { wasBroken = true; } float fixDuration = MathHelper.Lerp(FixDurationLowSkill, FixDurationHighSkill, successFactor); if (fixDuration <= 0.0f) { item.Condition = item.MaxCondition; } else { float conditionIncrease = deltaTime / (fixDuration / item.MaxCondition); item.Condition += conditionIncrease; #if SERVER GameMain.Server.KarmaManager.OnItemRepaired(CurrentFixer, this, conditionIncrease); #endif } if (wasBroken && item.IsFullCondition) { foreach (Skill skill in requiredSkills) { float characterSkillLevel = CurrentFixer.GetSkillLevel(skill.Identifier); CurrentFixer.Info.IncreaseSkillLevel(skill.Identifier, SkillIncreasePerRepair / Math.Max(characterSkillLevel, 1.0f), CurrentFixer.WorldPosition + Vector2.UnitY * 100.0f); } SteamAchievementManager.OnItemRepaired(item, currentFixer); deteriorationTimer = Rand.Range(MinDeteriorationDelay, MaxDeteriorationDelay); wasBroken = false; #if SERVER item.CreateServerEvent(this); #endif } }