1 /*-- Loom --*/
2
3 #include Library_Structure
4 #include Library_Ownable
5 #include Library_Producer
6 #include Library_LampPost
7
8 local animWork;
9 local meshAttach;
10
LampPosition(id def)11 public func LampPosition(id def) { return [GetCalcDir()*11,2]; }
12
Initialize()13 func Initialize()
14 {
15 animWork = PlayAnimation("Working", 1, Anim_Const(0));
16 return _inherited(...);
17 }
18
Construction(object creator)19 func Construction(object creator)
20 {
21 SetAction("Wait");
22 return _inherited(creator, ...);
23 }
24
IsHammerBuildable()25 public func IsHammerBuildable() { return true; }
26
27 /*-- Production --*/
28
IsProduct(id product_id)29 public func IsProduct(id product_id)
30 {
31 return product_id->~IsLoomProduct();
32 }
33
ProductionTime(id product)34 private func ProductionTime(id product) { return _inherited(product, ...) ?? 140; }
PowerNeed()35 public func PowerNeed() { return 40; }
36
FxIntWorkAnimTimer(object target,proplist effect,int timer)37 private func FxIntWorkAnimTimer(object target, proplist effect, int timer)
38 {
39 if(effect.paused == true) return 1;
40
41 var tickAmount = 50;
42 var animSpot = GetAnimationPosition(animWork);
43 //-50 is to dodge around an engine crash. If it reaches (near) the end of the
44 //animation, it dies for some reason. :(
45 var animLength = GetAnimationLength("Working") - 50;
46
47 //loop anim
48 if(animSpot + tickAmount > animLength){
49 SetAnimationPosition(animWork, Anim_Const(animSpot + tickAmount - animLength));
50 }
51 //otherwise, advance animation
52 else SetAnimationPosition(animWork, Anim_Const(animSpot + tickAmount));
53 }
54
55 local workEffect;
56
OnProductionStart(id product)57 public func OnProductionStart(id product)
58 {
59 workEffect = AddEffect("IntWorkAnim", this, 1,1,this);
60 return _inherited(product, ...);
61 }
62
OnProductionHold(id product)63 public func OnProductionHold(id product)
64 {
65 workEffect.paused = true;
66 return _inherited(product, ...);
67 }
68
OnProductionContinued(id product)69 public func OnProductionContinued(id product)
70 {
71 workEffect.paused = false;
72 return _inherited(product, ...);
73 }
74
OnProductionFinish(id product)75 public func OnProductionFinish(id product)
76 {
77 RemoveEffect(nil, this, workEffect);
78 return _inherited(product, ...);
79 }
80
Definition(def)81 func Definition(def){
82 SetProperty("MeshTransformation", Trans_Rotate(25, 0,1,0), def);
83 SetProperty("PictureTransformation", Trans_Rotate(65,0,1,0), def);
84 return _inherited(def, ...);
85 }
86
87 local ActMap = {
88 Wait = {
89 Prototype = Action,
90 Name = "Wait",
91 Procedure = DFA_NONE,
92 Directions = 2,
93 FlipDir = 1,
94 Length = 1,
95 Delay = 0,
96 FacetBase=1,
97 NextAction = "Wait",
98 },
99 };
100
101 local Name = "$Name$";
102 local Description ="$Description$";
103 local ContainBlast = true;
104 local BlastIncinerate = 100;
105 local FireproofContainer = true;
106 local HitPoints = 70;
107 local Components = {Wood = 3, Metal = 1, Rock = 1};