Elin Decompiled Documentation EA 23.303 Nightly
Loading...
Searching...
No Matches
CharaActorPCC.cs
Go to the documentation of this file.
1using UnityEngine;
2
4{
5 private static Vector3 org;
6
7 public PCC pcc;
8
9 public SpriteProvider provider = new SpriteProvider();
10
11 private float lastNextFrame;
12
13 public static Vector3 V2 = new Vector3(2f, 2f, 1f);
14
15 public override bool isPCC => true;
16
17 public override int currentDir => provider.currentDir;
18
19 public override void OnSetOwner()
20 {
22 sr.flipX = false;
23 pcc = PCC.Get((owner.renderer as CharaRenderer).pccData);
24 provider.onSetSprite = delegate(Sprite a)
25 {
26 sr.sprite = a;
27 mpb.SetTexture("_MainTex", sr.sprite.texture);
28 };
29 provider.angle = owner.angle;
30 provider.SetPCC(pcc);
31 mpb.SetTexture("_MainTex", sr.sprite.texture);
32 IdleFrame();
33 }
34
35 public override void NextFrame()
36 {
37 if (lastNextFrame != Time.timeSinceLevelLoad)
38 {
39 provider.NextFrame();
40 lastNextFrame = Time.timeSinceLevelLoad;
41 }
42 }
43
44 public override void IdleFrame()
45 {
46 if (!owner.isDead)
47 {
48 provider.SetSpriteIdle();
49 }
50 }
51
52 public override int GetFrame()
53 {
54 return provider.currentFrame % 2;
55 }
56
57 public override void NextDir()
58 {
59 provider.NextDir();
60 owner.angle = provider.angle;
61 provider.SetDir();
62 provider.SetSpriteMain();
64 }
65
66 public override void Kill()
67 {
68 base.Kill();
69 pcc = null;
70 provider.pcc = null;
71 }
72
73 public override void OnRender(RenderParam p)
74 {
75 base.OnRender(p);
76 if (pcc.data.isUnique)
77 {
78 return;
79 }
80 org.x = p.x;
81 org.y = p.y;
82 org.z = p.z + owner.renderer.data.offset.z;
83 bool flag = owner.combatCount <= 0 && EMono.core.config.game.hideWeapons;
84 Cell cell = owner.Cell;
85 if ((owner.held == null || (owner.held.trait.ShowAsTool && !HotItemHeld.disableTool)) && !owner.IsDeadOrSleeping && pcc.data.state != PCCState.Naked && (owner.Cell.isFloating || !cell.sourceSurface.tileType.IsDeepWater || cell.IsIceTile))
86 {
87 int num = currentDir;
88 int tempLeft = pcc.data.tempLeft;
89 int tempRight = pcc.data.tempRight;
90 switch (tempRight)
91 {
92 default:
93 {
95 bool flag3 = num == 0 || num == 1;
96 Vector3[] mainHandPos2 = EMono.setting.render.mainHandPos;
97 Vector3[] mainHand2 = EMono.setting.render.animeWalk[provider.currentFrame].mainHand;
98 p.tile = tempRight * (flag3 ? 1 : (-1));
99 p.matColor = 104025f;
100 p.x = org.x + mainHandPos2[num].x + mainHand2[num].x;
101 p.y = org.y + mainHandPos2[num].y + mainHand2[num].y;
102 p.z = org.z - renderTempEQ.offset.z + mainHandPos2[num].z + mainHand2[num].z;
103 renderTempEQ.Draw(p);
104 break;
105 }
106 case 0:
107 {
108 Thing thing = ((owner.IsPC && EMono.player.currentHotItem.RenderThing != null) ? EMono.player.currentHotItem.RenderThing : ((!flag && owner.body.slotMainHand?.thing != null) ? owner.body.slotMainHand.thing : null));
109 if (thing == null)
110 {
111 break;
112 }
113 bool flag2 = num == 0 || num == 1;
114 if (thing.trait.InvertHeldSprite)
115 {
116 flag2 = !flag2;
117 }
118 Vector3[] mainHandPos = EMono.setting.render.mainHandPos;
119 Vector3[] mainHand = EMono.setting.render.animeWalk[provider.currentFrame].mainHand;
120 SourcePref pref = thing.Pref;
121 thing.dir = ((!flag2) ? 1 : 0);
122 thing.SetRenderParam(p);
123 p.x = org.x + mainHandPos[num].x + mainHand[num].x + (flag2 ? 0.01f : (-0.01f)) * (float)pref.equipX;
124 p.y = org.y + mainHandPos[num].y + mainHand[num].y + 0.01f * (float)pref.equipY;
125 p.z = org.z - thing.renderer.data.offset.z + mainHandPos[num].z + mainHand[num].z;
126 if (thing.renderer.hasActor)
127 {
128 thing.renderer.RefreshSprite();
129 if (!flag2)
130 {
131 p.x -= thing.renderer.data._offset.x * 2f;
132 }
133 }
134 p.v.x = p.x;
135 p.v.y = p.y;
136 p.v.z = p.z;
137 thing.renderer.Draw(p, ref p.v, drawShadow: false);
138 break;
139 }
140 case -1:
141 break;
142 }
143 switch (tempLeft)
144 {
145 default:
146 {
148 bool flag5 = num == 1 || num == 3;
149 Vector3[] offHandPos2 = EMono.setting.render.offHandPos;
150 Vector3[] offHand2 = EMono.setting.render.animeWalk[provider.currentFrame].offHand;
151 p.tile = tempLeft * (flag5 ? 1 : (-1));
152 p.matColor = 104025f;
153 p.x = org.x + offHandPos2[num].x + offHand2[num].x;
154 p.y = org.y + offHandPos2[num].y + offHand2[num].y;
155 p.z = org.z - renderTempEQ2.offset.z + offHandPos2[num].z + offHand2[num].z;
156 renderTempEQ2.Draw(p);
157 break;
158 }
159 case 0:
160 {
161 if (flag || owner.body.slotOffHand == null || !EMono.core.config.game.showOffhand)
162 {
163 break;
164 }
166 if (thing2 == null)
167 {
168 break;
169 }
170 bool flag4 = num == 1 || num == 3;
171 Vector3[] offHandPos = EMono.setting.render.offHandPos;
172 Vector3[] offHand = EMono.setting.render.animeWalk[provider.currentFrame].offHand;
173 SourcePref pref2 = thing2.Pref;
174 thing2.dir = ((!flag4) ? 1 : 0);
175 thing2.SetRenderParam(p);
176 p.x = org.x + offHandPos[num].x + offHand[num].x + (flag4 ? 0.01f : (-0.01f)) * (float)pref2.equipX;
177 p.y = org.y + offHandPos[num].y + offHand[num].y + 0.01f * (float)pref2.equipY;
178 p.z = org.z - thing2.renderer.data.offset.z + offHandPos[num].z + offHand[num].z;
179 if (thing2.renderer.hasActor)
180 {
181 thing2.renderer.RefreshSprite();
182 if (!flag4)
183 {
184 p.x -= thing2.renderer.data._offset.x * 2f;
185 }
186 }
187 p.v.x = p.x;
188 p.v.y = p.y;
189 p.v.z = p.z;
190 thing2.renderer.Draw(p, ref p.v, drawShadow: false);
191 break;
192 }
193 case -1:
194 break;
195 }
196 }
197 p.x = org.x;
198 p.y = org.y;
199 p.z = org.z - owner.renderer.data.offset.z;
200 }
201
202 public override void RefreshSprite()
203 {
204 provider.angle = owner.angle;
205 provider.SetDir();
206 provider.SetSpriteMain();
207 base.RefreshSprite();
208 }
209}
Vector3[] mainHand
Vector3[] offHand
Thing thing
Definition: BodySlot.cs:8
SpriteRenderer sr
Definition: CardActor.cs:15
MaterialPropertyBlock mpb
Definition: CardActor.cs:21
override void Draw(RenderParam p)
Definition: CardRenderer.cs:49
void RefreshSprite()
float angle
Definition: Card.cs:74
Trait trait
Definition: Card.cs:54
Cell Cell
Definition: Card.cs:2095
CardRenderer renderer
Definition: Card.cs:64
Definition: Cell.cs:7
bool IsIceTile
Definition: Cell.cs:806
bool isFloating
Definition: Cell.cs:474
SourceFloor.Row sourceSurface
Definition: Cell.cs:1059
override void OnSetOwner()
override void OnRender(RenderParam p)
override void RefreshSprite()
static Vector3 V2
override int currentDir
override int GetFrame()
override void NextDir()
override bool isPCC
override void NextFrame()
override void IdleFrame()
float lastNextFrame
override void Kill()
static Vector3 org
Definition: CharaActorPCC.cs:5
SpriteProvider provider
Definition: CharaActorPCC.cs:9
void SetOwnerAsChara()
Definition: CharaActor.cs:7
new Chara owner
Definition: CharaActor.cs:5
BodySlot slotOffHand
Definition: CharaBody.cs:12
BodySlot slotMainHand
Definition: CharaBody.cs:10
CharaBody body
Definition: Chara.cs:94
Card held
Definition: Chara.cs:70
override bool IsDeadOrSleeping
Definition: Chara.cs:575
bool isDead
Definition: Chara.cs:391
new GameConfig game
Definition: CoreConfig.cs:613
CoreConfig config
Definition: Core.cs:70
Definition: EMono.cs:4
static GameSetting setting
Definition: EMono.cs:31
static Core core
Definition: EMono.cs:5
static Player player
Definition: EMono.cs:11
static Scene scene
Definition: EMono.cs:27
RenderData renderTempEQ
Definition: GameScreen.cs:7
AnimationFrame[] animeWalk
Definition: GameSetting.cs:216
RenderSetting render
Definition: GameSetting.cs:301
static bool disableTool
Definition: HotItemHeld.cs:11
virtual Thing RenderThing
Definition: HotItem.cs:19
HotItem currentHotItem
Definition: Player.cs:1167
void Draw(RenderParam p, int tile)
Definition: RenderData.cs:129
Vector3 offset
Definition: RenderData.cs:19
RenderData data
Definition: RenderObject.cs:34
Vector3 v
Definition: RenderParam.cs:19
GameScreen screenElin
Definition: Scene.cs:93
Definition: Thing.cs:8
override void SetRenderParam(RenderParam p)
Definition: Thing.cs:1508
override SourcePref Pref
Definition: Thing.cs:50
virtual bool ShowAsTool
Definition: Trait.cs:347
virtual bool InvertHeldSprite
Definition: Trait.cs:72