Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
TaskChopWood.cs
Go to the documentation of this file.
1using System.Collections.Generic;
2using UnityEngine;
3
5{
7
8 public override int destDist => 1;
9
10 public override bool Loop => GetLog() != null;
11
12 public override bool CanManualCancel()
13 {
14 return true;
15 }
16
17 public Thing GetLog()
18 {
19 return pos.FindThing((Thing t) => t.id == "log");
20 }
21
22 public override HitResult GetHitResult()
23 {
24 if (GetLog() != null)
25 {
26 return HitResult.Valid;
27 }
28 return HitResult.Invalid;
29 }
30
31 public override bool CanProgress()
32 {
33 if (base.CanProgress() && GetLog() != null && owner.Tool != null && owner.Tool.trait is TraitTool)
34 {
35 return owner.Tool.HasElement(225);
36 }
37 return false;
38 }
39
40 public override void OnCreateProgress(Progress_Custom p)
41 {
42 p.textHint = Name;
43 p.maxProgress = Mathf.Max((15 + EClass.rnd(20)) * 100 / (100 + owner.Tool.material.hardness * 3), 2);
44 p.onProgressBegin = delegate
45 {
46 if (owner.Tool != null)
47 {
48 owner.Say("chopwood_start", owner, GetLog().GetName(NameStyle.Full, 1));
49 }
50 };
51 p.onProgress = delegate
52 {
53 Thing log2 = GetLog();
54 SourceMaterial.Row material2 = log2.material;
55 log2.PlaySoundImpact();
56 material2.AddBlood(pos);
57 log2.PlayAnime(AnimeID.HitObj);
58 material2.PlayHitEffect(pos);
60 };
61 p.onProgressComplete = delegate
62 {
63 Thing log = GetLog();
65 log.PlaySoundDead();
66 material.AddBlood(pos, 3 + EClass.rnd(2));
67 log.material.PlayHitEffect(pos, 10);
68 Thing thing = ThingGen.Create("plank", material.id).SetNum(1 + EClass.rnd(2));
69 CraftUtil.MixIngredients(thing, new List<Thing> { log }, CraftUtil.MixType.General, 999);
70 log.ModNum(-1);
71 owner.elements.ModExp(225, 30);
72 owner.stamina.Mod(-1);
74 };
75 }
76}
AnimeID
Definition: AnimeID.cs:2
HitResult
Definition: HitResult.cs:2
NameStyle
Definition: NameStyle.cs:2
new Chara owner
Definition: AIAct.cs:14
virtual new string Name
Definition: AIAct.cs:68
virtual void NextFrame()
ElementContainerCard elements
Definition: Card.cs:37
string id
Definition: Card.cs:31
bool HasElement(int ele, int req=1)
Definition: Card.cs:5214
SourceMaterial.Row material
Definition: Card.cs:1927
Thing Tool
Definition: Card.cs:2270
void PlaySoundImpact(bool spatial=true)
Definition: Card.cs:5394
Thing SetNum(int a)
Definition: Card.cs:3242
Trait trait
Definition: Card.cs:49
void PlaySoundDead(bool spatial=true)
Definition: Card.cs:5399
void PlayAnime(AnimeID id, bool force=false)
Definition: Card.cs:5423
void ModNum(int a, bool notify=true)
Definition: Card.cs:3262
CardRenderer renderer
Definition: Card.cs:57
void Say(string lang, string ref1=null, string ref2=null)
Definition: Card.cs:6046
Stats stamina
Definition: Chara.cs:955
static Thing MixIngredients(string idProduct, List< Thing > ings, MixType type, int idMat=0, Chara crafter=null)
Definition: CraftUtil.cs:132
static CursorInfo Cut
Definition: CursorSystem.cs:62
Definition: EClass.cs:5
static int rnd(int a)
Definition: EClass.cs:50
static Map _map
Definition: EClass.cs:18
static Chara pc
Definition: EClass.cs:14
void ModExp(int ele, int a, bool chain=false)
static string GetName(string alias)
Definition: ELEMENT.cs:386
void TrySmoothPick(Cell cell, Thing t, Chara c)
Definition: Map.cs:1791
Thing FindThing(Func< Thing, bool > func)
Definition: Point.cs:1104
void AddBlood(Point p, int a=1)
void PlayHitEffect(Point p, int emit=2)
virtual void Mod(int a)
Definition: Stats.cs:135
override int destDist
Definition: TaskChopWood.cs:8
override void OnCreateProgress(Progress_Custom p)
Definition: TaskChopWood.cs:40
override bool CanProgress()
Definition: TaskChopWood.cs:31
override bool CanManualCancel()
Definition: TaskChopWood.cs:12
Thing GetLog()
Definition: TaskChopWood.cs:17
override HitResult GetHitResult()
Definition: TaskChopWood.cs:22
override CursorInfo CursorIcon
Definition: TaskChopWood.cs:6
override bool Loop
Definition: TaskChopWood.cs:10
Point pos
Definition: TaskPoint.cs:11
static Thing Create(string id, int idMat=-1, int lv=-1)
Definition: ThingGen.cs:53
Definition: Thing.cs:8