Skip to content

Commit 3e94b06

Browse files
committed
Add project files.
1 parent a72f004 commit 3e94b06

File tree

16 files changed

+1099
-0
lines changed

16 files changed

+1099
-0
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "Everest"]
2+
path = Everest
3+
url = https://github.com/EverestAPI/Everest.git

Everest

Submodule Everest added at f9ed76c

GhostMod.sln

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 14
4+
VisualStudioVersion = 14.0.25420.1
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GhostMod", "GhostMod\GhostMod.csproj", "{4ABF8C07-C533-407E-9EC9-534C2916C907}"
7+
EndProject
8+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Celeste.Mod.mm", "Everest\Celeste.Mod.mm\Celeste.Mod.mm.csproj", "{D5D0239D-FF95-4897-9484-1898AB7E82F5}"
9+
EndProject
10+
Global
11+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
12+
Debug|Any CPU = Debug|Any CPU
13+
Release|Any CPU = Release|Any CPU
14+
EndGlobalSection
15+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
16+
{4ABF8C07-C533-407E-9EC9-534C2916C907}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17+
{4ABF8C07-C533-407E-9EC9-534C2916C907}.Debug|Any CPU.Build.0 = Debug|Any CPU
18+
{4ABF8C07-C533-407E-9EC9-534C2916C907}.Release|Any CPU.ActiveCfg = Release|Any CPU
19+
{4ABF8C07-C533-407E-9EC9-534C2916C907}.Release|Any CPU.Build.0 = Release|Any CPU
20+
{D5D0239D-FF95-4897-9484-1898AB7E82F5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21+
{D5D0239D-FF95-4897-9484-1898AB7E82F5}.Debug|Any CPU.Build.0 = Debug|Any CPU
22+
{D5D0239D-FF95-4897-9484-1898AB7E82F5}.Release|Any CPU.ActiveCfg = Release|Any CPU
23+
{D5D0239D-FF95-4897-9484-1898AB7E82F5}.Release|Any CPU.Build.0 = Release|Any CPU
24+
EndGlobalSection
25+
GlobalSection(SolutionProperties) = preSolution
26+
HideSolutionNode = FALSE
27+
EndGlobalSection
28+
EndGlobal
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# NOTES:
2+
# The # Symbol at the start of a line counts as a Comment. To include in dialog, use a \#
3+
# The . Symbol will cause a pause unless escaped with \. (ex: Mr. Oshiro has a pause, Mr\. Oshiro does not)
4+
# Newlines automatically create a Page Break, unless there is an {n} command on the previous line
5+
# Commands: Anything inside of curly braces {...} is a command and should not be translated.
6+
7+
# Inline Text Commands:
8+
# {~}wavy text{/~}
9+
# {!}impact text{/!}
10+
# {>> x}changes speed at which characters are displayed{>>}
11+
# {# 000000}this text is black{#} (uses HEX color values)
12+
# {+MENU_BEGIN} inserts the dialog from the MENU_BEGIN value (in English, "CLIMB")
13+
# {n} creates a newline, without a page break
14+
# {0.5} creates a 0.5 second pause
15+
# {big}this text is large{/big}
16+
17+
# Gameplay Control Commands (should never change)
18+
# {trigger x} this triggers an in-game event
19+
# {anchor} controls the visual position of the textbox in-game
20+
21+
# Ghost Module Options
22+
MODOPTIONS_GHOSTMODULE_TITLE= Ghost-eline
23+
MODOPTIONS_GHOSTMODULE_MODE= Mode
24+
MODOPTIONS_GHOSTMODULE_MODE_OFF= OFF
25+
MODOPTIONS_GHOSTMODULE_MODE_RECORD= RECORD
26+
MODOPTIONS_GHOSTMODULE_MODE_PLAY= PLAY
27+
MODOPTIONS_GHOSTMODULE_MODE_ON= BOTH
28+
MODOPTIONS_GHOSTMODULE_NAME= Ghost Name
29+
MODOPTIONS_GHOSTMODULE_SHOWOTHERNAMES= Show Other's Names
30+
MODOPTIONS_GHOSTMODULE_INNEROPACITY= Near Ghost Visibility
31+
MODOPTIONS_GHOSTMODULE_INNERHAIROPACITY= Near Ghost Hair Visibility
32+
MODOPTIONS_GHOSTMODULE_OUTEROPACITY= Far Ghost Visibility
33+
MODOPTIONS_GHOSTMODULE_OUTERHAIROPACITY= Far Ghost Hair Visibility
34+
MODOPTIONS_GHOSTMODULE_INNERRADIUS= Near Ghost Radius
35+
MODOPTIONS_GHOSTMODULE_BORDERSIZE= Gradient Region
36+
MODOPTIONS_GHOSTMODULE_SHOWDEATHS= Show Recorded Deaths
37+
MODOPTIONS_GHOSTMODULE_GHOSTCOUNT= Ghosts

GhostMod/Ghost.cs

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
using FMOD.Studio;
2+
using Microsoft.Xna.Framework;
3+
using Monocle;
4+
using System;
5+
using System.Collections;
6+
using System.Collections.Generic;
7+
using System.Linq;
8+
using System.Text;
9+
using System.Threading.Tasks;
10+
using YamlDotNet.Serialization;
11+
12+
namespace Celeste.Mod.Ghost {
13+
public class Ghost : Actor {
14+
15+
public Player Player;
16+
17+
public PlayerSprite Sprite;
18+
public PlayerHair Hair;
19+
public int MachineState;
20+
21+
public GhostData Data;
22+
public int FrameIndex = 0;
23+
public GhostFrame? ForcedFrame;
24+
public GhostFrame PrevFrame => ForcedFrame ?? (Data == null ? default(GhostFrame) : Data[FrameIndex - 1]);
25+
public GhostFrame Frame => ForcedFrame ?? (Data == null ? default(GhostFrame) : Data[FrameIndex]);
26+
public bool AutoForward = true;
27+
28+
public GhostName Name;
29+
30+
protected float alpha;
31+
protected float alphaHair;
32+
33+
protected bool playerHadControl;
34+
35+
public Ghost(Player player)
36+
: this(player, null) {
37+
}
38+
public Ghost(Player player, GhostData data)
39+
: base(player.Position) {
40+
Player = player;
41+
Data = data;
42+
43+
Depth = 1;
44+
45+
Sprite = new PlayerSprite(player.Sprite.Mode);
46+
Sprite.HairCount = player.Sprite.HairCount;
47+
Add(Hair = new PlayerHair(Sprite));
48+
Add(Sprite);
49+
50+
Hair.Color = Player.NormalHairColor;
51+
}
52+
53+
public override void Added(Scene scene) {
54+
base.Added(scene);
55+
56+
Hair.Facing = Frame.Facing;
57+
Hair.Start();
58+
UpdateHair();
59+
60+
if (Data != null && Data.Name != GhostModule.Settings.Name)
61+
Scene.Add(Name = new GhostName(this, Data.Name));
62+
}
63+
64+
public override void Removed(Scene scene) {
65+
base.Removed(scene);
66+
67+
Name?.RemoveSelf();
68+
}
69+
70+
public void UpdateHair() {
71+
if (!Frame.HasData)
72+
return;
73+
74+
Hair.Color = Frame.HairColor;
75+
Hair.Alpha = alphaHair;
76+
Hair.Facing = Frame.Facing;
77+
Hair.SimulateMotion = Frame.HairSimulateMotion;
78+
}
79+
80+
public void UpdateSprite() {
81+
if (!Frame.HasData)
82+
return;
83+
84+
Position = Frame.Position;
85+
Sprite.Rotation = Frame.Rotation;
86+
Sprite.Scale = Frame.Scale;
87+
Sprite.Scale.X = Sprite.Scale.X * (float) Frame.Facing;
88+
Sprite.Color = Frame.Color * alpha;
89+
90+
Sprite.Rate = Frame.SpriteRate;
91+
Sprite.Justify = Frame.SpriteJustify;
92+
93+
try {
94+
if (Sprite.CurrentAnimationID != Frame.CurrentAnimationID)
95+
Sprite.Play(Frame.CurrentAnimationID);
96+
Sprite.SetAnimationFrame(Frame.CurrentAnimationFrame);
97+
} catch {
98+
// Play likes to fail randomly as the ID doesn't exist in an underlying dict.
99+
// Let's ignore this for now.
100+
}
101+
}
102+
103+
public override void Update() {
104+
Visible = ((GhostModule.Settings.Mode & GhostModuleMode.Play) == GhostModuleMode.Play);
105+
Visible &= Frame.HasData;
106+
if (Data != null && Data.Dead)
107+
Visible &= GhostModule.Settings.ShowDeaths;
108+
109+
if (Player.InControl && AutoForward && ForcedFrame == null) {
110+
do {
111+
FrameIndex++;
112+
} while (
113+
(PrevFrame.HasData && !PrevFrame.InControl) || // Skip any frames we're not in control in.
114+
(!PrevFrame.HasData && FrameIndex < Data.Frames.Count) // Skip any frames not containing the data chunk.
115+
);
116+
}
117+
playerHadControl = Player.InControl;
118+
119+
UpdateSprite();
120+
UpdateHair();
121+
122+
if (Data != null && Data.Opacity != null) {
123+
alpha = Data.Opacity.Value;
124+
alphaHair = Data.Opacity.Value;
125+
} else {
126+
float dist = (Player.Position - Position).LengthSquared();
127+
dist -= GhostModule.Settings.InnerRadiusDist;
128+
if (dist < 0f)
129+
dist = 0f;
130+
if (GhostModule.Settings.BorderSize == 0) {
131+
dist = dist < GhostModule.Settings.InnerRadiusDist ? 0f : 1f;
132+
} else {
133+
dist /= GhostModule.Settings.BorderSizeDist;
134+
}
135+
alpha = Calc.LerpClamp(GhostModule.Settings.InnerOpacityFactor, GhostModule.Settings.OuterOpacityFactor, dist);
136+
alphaHair = Calc.LerpClamp(GhostModule.Settings.InnerHairOpacityFactor, GhostModule.Settings.OuterHairOpacityFactor, dist);
137+
}
138+
139+
Visible &= alpha > 0f;
140+
141+
if (Name != null)
142+
Name.Alpha = alpha;
143+
144+
base.Update();
145+
}
146+
147+
}
148+
}

0 commit comments

Comments
 (0)