Elin Decompiled Documentation EA 23.102 Nightly
All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Events Pages
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 bool flag2 = num == 0 || num == 1;
112 if (thing.trait.InvertHeldSprite)
113 {
114 flag2 = !flag2;
115 }
116 Vector3[] mainHandPos = EMono.setting.render.mainHandPos;
117 Vector3[] mainHand = EMono.setting.render.animeWalk[provider.currentFrame].mainHand;
118 SourcePref pref = thing.sourceCard.pref;
119 thing.dir = ((!flag2) ? 1 : 0);
120 thing.SetRenderParam(p);
121 p.x = org.x + mainHandPos[num].x + mainHand[num].x + (flag2 ? 0.01f : (-0.01f)) * (float)pref.equipX;
122 p.y = org.y + mainHandPos[num].y + mainHand[num].y + 0.01f * (float)pref.equipY;
123 p.z = org.z - thing.renderer.data.offset.z + mainHandPos[num].z + mainHand[num].z;
124 p.v.x = p.x;
125 p.v.y = p.y;
126 p.v.z = p.z;
127 if (thing.renderer.hasActor)
128 {
129 thing.renderer.RefreshSprite();
130 }
131 thing.renderer.Draw(p, ref p.v, drawShadow: false);
132 }
133 break;
134 }
135 case -1:
136 break;
137 }
138 switch (tempLeft)
139 {
140 default:
141 {
143 bool flag5 = num == 1 || num == 3;
144 Vector3[] offHandPos2 = EMono.setting.render.offHandPos;
145 Vector3[] offHand2 = EMono.setting.render.animeWalk[provider.currentFrame].offHand;
146 p.tile = tempLeft * (flag5 ? 1 : (-1));
147 p.matColor = 104025f;
148 p.x = org.x + offHandPos2[num].x + offHand2[num].x;
149 p.y = org.y + offHandPos2[num].y + offHand2[num].y;
150 p.z = org.z - renderTempEQ2.offset.z + offHandPos2[num].z + offHand2[num].z;
151 renderTempEQ2.Draw(p);
152 break;
153 }
154 case 0:
155 {
156 if (flag || owner.body.slotOffHand == null || !EMono.core.config.game.showOffhand)
157 {
158 break;
159 }
161 if (thing2 != null)
162 {
163 bool flag4 = num == 1 || num == 3;
164 Vector3[] offHandPos = EMono.setting.render.offHandPos;
165 Vector3[] offHand = EMono.setting.render.animeWalk[provider.currentFrame].offHand;
166 SourcePref pref2 = thing2.source.pref;
167 thing2.dir = ((!flag4) ? 1 : 0);
168 thing2.SetRenderParam(p);
169 p.x = org.x + offHandPos[num].x + offHand[num].x + (flag4 ? 0.01f : (-0.01f)) * (float)pref2.equipX;
170 p.y = org.y + offHandPos[num].y + offHand[num].y + 0.01f * (float)pref2.equipY;
171 p.z = org.z - thing2.renderer.data.offset.z + offHandPos[num].z + offHand[num].z;
172 if (thing2.renderer.hasActor)
173 {
174 thing2.renderer.RefreshSprite();
175 }
176 thing2.renderer.Draw(p);
177 }
178 break;
179 }
180 case -1:
181 break;
182 }
183 }
184 p.x = org.x;
185 p.y = org.y;
186 p.z = org.z - owner.renderer.data.offset.z;
187 }
188
189 public override void RefreshSprite()
190 {
191 provider.angle = owner.angle;
192 provider.SetDir();
193 provider.SetSpriteMain();
194 base.RefreshSprite();
195 }
196}
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:67
Trait trait
Definition: Card.cs:49
Cell Cell
Definition: Card.cs:1931
CardRenderer renderer
Definition: Card.cs:57
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:91
Card held
Definition: Chara.cs:67
override bool IsDeadOrSleeping
Definition: Chara.cs:558
bool isDead
Definition: Chara.cs:374
new GameConfig game
Definition: CoreConfig.cs:596
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:901
void Draw(RenderParam p, int tile)
Definition: RenderData.cs:128
Vector3 offset
Definition: RenderData.cs:18
RenderData data
Definition: RenderObject.cs:34
Vector3 v
Definition: RenderParam.cs:19
SourcePref pref
Definition: RenderRow.cs:68
GameScreen screenElin
Definition: Scene.cs:89
Definition: Thing.cs:8
SourceThing.Row source
Definition: Thing.cs:11
override void SetRenderParam(RenderParam p)
Definition: Thing.cs:1401
override CardRow sourceCard
Definition: Thing.cs:47
virtual bool ShowAsTool
Definition: Trait.cs:323
virtual bool InvertHeldSprite
Definition: Trait.cs:66