Elin Decompiled Documentation EA 23.240 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 Thing log = GetLog();
26 {
27 return HitResult.Invalid;
28 }
29 if (GetLog() != null)
30 {
31 return HitResult.Valid;
32 }
33 return HitResult.Invalid;
34 }
35
36 public override bool CanProgress()
37 {
38 if (base.CanProgress() && GetLog() != null && owner.Tool != null && owner.Tool.trait is TraitTool)
39 {
40 return owner.Tool.HasElement(225);
41 }
42 return false;
43 }
44
45 public override void OnCreateProgress(Progress_Custom p)
46 {
47 p.textHint = Name;
48 p.maxProgress = Mathf.Max((15 + EClass.rnd(20)) * 100 / (100 + owner.Tool.material.hardness * 3), 2);
49 p.onProgressBegin = delegate
50 {
51 if (owner.Tool != null)
52 {
53 owner.Say("chopwood_start", owner, GetLog().GetName(NameStyle.Full, 1));
54 }
55 };
56 p.onProgress = delegate
57 {
58 Thing log2 = GetLog();
59 SourceMaterial.Row material2 = log2.material;
60 log2.PlaySoundImpact();
61 material2.AddBlood(pos);
62 log2.PlayAnime(AnimeID.HitObj);
63 material2.PlayHitEffect(pos);
65 };
66 p.onProgressComplete = delegate
67 {
68 Thing log = GetLog();
70 log.PlaySoundDead();
71 material.AddBlood(pos, 3 + EClass.rnd(2));
72 log.material.PlayHitEffect(pos, 10);
73 Thing thing = ThingGen.Create("plank", material.id).SetNum(1 + EClass.rnd(2));
74 CraftUtil.MixIngredients(thing, new List<Thing> { log }, CraftUtil.MixType.General, 999);
75 log.ModNum(-1);
76 owner.elements.ModExp(225, 30f);
77 owner.stamina.Mod(-1);
79 };
80 }
81}
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:41
string id
Definition: Card.cs:35
bool isNPCProperty
Definition: Card.cs:554
bool HasElement(int ele, int req=1)
Definition: Card.cs:5897
SourceMaterial.Row material
Definition: Card.cs:2051
Thing Tool
Definition: Card.cs:2410
void PlaySoundImpact(bool spatial=true)
Definition: Card.cs:6119
Thing SetNum(int a)
Definition: Card.cs:3492
Trait trait
Definition: Card.cs:53
void PlaySoundDead(bool spatial=true)
Definition: Card.cs:6124
void PlayAnime(AnimeID id, bool force=false)
Definition: Card.cs:6148
void ModNum(int a, bool notify=true)
Definition: Card.cs:3512
CardRenderer renderer
Definition: Card.cs:61
void Say(string lang, string ref1=null, string ref2=null)
Definition: Card.cs:6781
Stats stamina
Definition: Chara.cs:1146
static Thing MixIngredients(string idProduct, List< Thing > ings, MixType type, int idMat=0, Chara crafter=null)
Definition: CraftUtil.cs:350
static CursorInfo Cut
Definition: CursorSystem.cs:62
Definition: EClass.cs:6
static Game game
Definition: EClass.cs:9
static Zone _zone
Definition: EClass.cs:21
static Map _map
Definition: EClass.cs:19
static int rnd(long a)
Definition: EClass.cs:59
static Chara pc
Definition: EClass.cs:15
void ModExp(int ele, float a, bool chain=false)
static string GetName(string alias)
Definition: ELEMENT.cs:396
bool disableUsermapBenefit
GamePrincipal principal
Definition: Game.cs:224
void TrySmoothPick(Cell cell, Thing t, Chara c)
Definition: Map.cs:1804
Thing FindThing(Func< Thing, bool > func)
Definition: Point.cs:1140
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:45
override bool CanProgress()
Definition: TaskChopWood.cs:36
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
virtual bool IsUserZone
Definition: Zone.cs:268