Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
TraitGeneMachine.cs
Go to the documentation of this file.
1using UnityEngine;
2
4{
5 public override bool CanBeOnlyBuiltInHome => true;
6
7 public override bool IsHomeItem => true;
8
9 public override bool CanBeHeld => !IsTargetUsingGene();
10
12 {
13 if (!owner.IsInstalled)
14 {
15 return null;
16 }
17 foreach (Chara chara in owner.pos.Charas)
18 {
19 ConSuspend condition = chara.GetCondition<ConSuspend>();
20 if (condition != null && condition.uidMachine == owner.uid)
21 {
22 return chara;
23 }
24 }
25 return null;
26 }
27
28 public bool IsTargetUsingGene()
29 {
30 return GetTarget()?.GetCondition<ConSuspend>().HasGene ?? false;
31 }
32
33 public float GetProgress()
34 {
35 ConSuspend condition = GetTarget().GetCondition<ConSuspend>();
36 if (condition == null || !condition.HasGene)
37 {
38 return 0f;
39 }
40 int remainingHours = EClass.world.date.GetRemainingHours(condition.dateFinish);
41 if (condition.duration == 0 || EClass.debug.enable)
42 {
43 return 1f;
44 }
45 return Mathf.Clamp((float)(condition.duration - remainingHours) / (float)condition.duration, 0f, 1f);
46 }
47
48 public string GetProgressText()
49 {
50 ConSuspend condition = GetTarget().GetCondition<ConSuspend>();
51 int remainingHours = EClass.world.date.GetRemainingHours(condition.dateFinish);
52 if (remainingHours > 0)
53 {
54 return remainingHours + " h";
55 }
56 return "progress_finish".lang();
57 }
58
59 public override bool CanUse(Chara c)
60 {
62 {
64 {
65 return GetProgress() >= 1f;
66 }
67 return true;
68 }
69 return false;
70 }
71
72 public override bool OnUse(Chara c)
73 {
75 {
77 return false;
78 }
79 Chara target = GetTarget();
80 if (target == null)
81 {
82 LayerPeople.CreateSelect("", "", delegate(UIList l)
83 {
84 foreach (Chara member in EClass.Branch.members)
85 {
86 if (member.GetCondition<ConSuspend>() == null && member.host == null && !member.IsPC && member.IsAliveInCurrentZone && member.memberType == FactionMemberType.Default)
87 {
88 l.Add(member);
89 }
90 }
91 }, delegate(Chara c)
92 {
93 if (c.IsPCParty)
94 {
96 }
97 if (!c.pos.Equals(owner.pos))
98 {
100 c.Teleport(owner.pos, silent: false, force: true);
101 c.isRestrained = false;
102 }
103 if (EClass.debug.enable)
104 {
105 if (c.c_genes == null)
106 {
107 c.c_genes = new CharaGenes();
108 }
109 c.c_genes.inferior += 20;
110 c.feat += 500;
111 }
112 c.RemoveCondition<ConSleep>();
113 c.PlaySound("ride");
114 (c.AddCondition<ConSuspend>(100, force: true) as ConSuspend).uidMachine = owner.uid;
115 }, (Chara a) => "gene_note".lang(a.CurrentGeneSlot.ToString() ?? "", a.MaxGeneSlot.ToString() ?? "", a.feat.ToString() ?? "", a.GetTotalFeat() + " "));
116 }
117 else if (GetProgress() >= 1f)
118 {
119 ConSuspend condition = target.GetCondition<ConSuspend>();
120 if (condition.gene.GetRootCard() != target)
121 {
123 }
124 else
125 {
126 target.Say("gene_finish", target, condition.gene);
127 condition.gene.c_DNA.Apply(target);
128 condition.gene.Destroy();
129 condition.gene = null;
130 }
131 target.RemoveCondition<ConSuspend>();
132 target.MoveNeighborDefinitely();
133 target.PlaySound("ding_potential");
134 target.pos.PlayEffect("mutation");
135 }
136 else
137 {
139 }
140 return true;
141 }
142}
virtual void PlayEffect()
void Teleport(Point point, bool silent=false, bool force=false)
Definition: Card.cs:5153
SoundSource PlaySound(string id, float v=1f, bool spatial=true)
Definition: Card.cs:5404
Point pos
Definition: Card.cs:55
int uid
Definition: Card.cs:118
CharaGenes c_genes
Definition: Card.cs:1745
void Destroy()
Definition: Card.cs:4538
bool IsInstalled
Definition: Card.cs:2241
Card GetRootCard()
Definition: Card.cs:3173
bool isOn
Definition: Card.cs:514
DNA c_DNA
Definition: Card.cs:1781
Definition: Chara.cs:10
Condition AddCondition(string id, int p=100, bool force=false)
Definition: Chara.cs:8415
override bool IsPCParty
Definition: Chara.cs:600
Party party
Definition: Chara.cs:43
void Kick(Point p, bool ignoreSelf=false)
Definition: Chara.cs:5174
Thing gene
Definition: ConSuspend.cs:15
int duration
Definition: ConSuspend.cs:9
bool HasGene
Definition: ConSuspend.cs:20
int uidMachine
Definition: ConSuspend.cs:6
int dateFinish
Definition: ConSuspend.cs:12
bool enable
Definition: CoreDebug.cs:285
void Apply(Chara c)
Definition: DNA.cs:165
int GetRemainingHours(int rawDeadLine)
Definition: Date.cs:337
Definition: EClass.cs:5
static Zone _zone
Definition: EClass.cs:20
static World world
Definition: EClass.cs:40
static FactionBranch Branch
Definition: EClass.cs:22
static Chara pc
Definition: EClass.cs:14
static CoreDebug debug
Definition: EClass.cs:48
List< Chara > members
static LayerDragGrid Create(InvOwnerDraglet owner, bool refuelFromLayerDragGrid=false)
static LayerPeople CreateSelect(string langHeader, string langHint, Action< UIList > onList, Action< Chara > onClick, Func< Chara, string > _onShowSubText=null)
Definition: LayerPeople.cs:176
Definition: Msg.cs:5
static string SayNothingHappen()
Definition: Msg.cs:96
void RemoveMember(Chara c)
Definition: Party.cs:84
List< Chara > Charas
Definition: Point.cs:316
bool Equals(int _x, int _z)
Definition: Point.cs:924
string GetProgressText()
override bool CanBeOnlyBuiltInHome
override bool CanBeHeld
override bool IsHomeItem
override bool CanUse(Chara c)
override bool OnUse(Chara c)
Card owner
Definition: Trait.cs:26
Definition: UIList.cs:9
GameDate date
Definition: World.cs:6
virtual bool IsUserZone
Definition: Zone.cs:264