001package com.fs.starfarer.api.impl.campaign; 002 003import com.fs.starfarer.api.campaign.TextPanelAPI; 004import com.fs.starfarer.api.ui.TooltipMakerAPI; 005import com.fs.starfarer.api.util.Misc; 006 007public class BaseCampaignObjectivePlugin extends BaseCustomEntityPlugin implements CampaignObjective { 008 009 public static final String HACKED = "$cob_hacked"; 010 public static final String RESET = "$cob_reset"; 011 012 public static final float HACK_DURATION_DAYS = 90f; 013 public static final float RESET_DURATION_DAYS = 30f; 014 015 public void printEffect(TooltipMakerAPI text, float pad) { 016 017 } 018 019 public void addHackStatusToTooltip(TooltipMakerAPI text, float pad) { 020 if (isHacked()) { 021 text.addPara("Hacked", Misc.getTextColor(), pad); 022 } 023 if (isReset()) { 024 text.addPara("Disrupted by factory reset", Misc.getTextColor(), pad); 025 } 026 } 027 028 public void printNonFunctionalAndHackDescription(TextPanelAPI text) { 029 030 } 031 032 033 public Boolean isHacked() { 034 return entity != null && entity.getMemoryWithoutUpdate().getBoolean(HACKED); 035 } 036 037 public void setHacked(boolean hacked) { 038 setHacked(hacked, HACK_DURATION_DAYS + (float) Math.random() * 0.5f * HACK_DURATION_DAYS); 039 } 040 041 public void setHacked(boolean hacked, float days) { 042 if (hacked) { 043 entity.getMemoryWithoutUpdate().set(HACKED, hacked, days); 044 } else { 045 entity.getMemoryWithoutUpdate().unset(HACKED); 046 } 047 } 048 049 public Boolean isReset() { 050 return entity != null && entity.getMemoryWithoutUpdate().getBoolean(RESET); 051 } 052 053 public void setReset(boolean reset) { 054 setReset(reset, RESET_DURATION_DAYS + (float) Math.random() * 0.5f * RESET_DURATION_DAYS); 055 } 056 057 public void setReset(boolean reset, float days) { 058 if (reset) { 059 entity.getMemoryWithoutUpdate().set(RESET, reset, days); 060 } else { 061 entity.getMemoryWithoutUpdate().unset(RESET); 062 } 063 } 064 065 066 067} 068 069 070 071