Skip to content

Commit

Permalink
Recording Station Base
Browse files Browse the repository at this point in the history
  • Loading branch information
Raoul1808 committed Sep 24, 2022
1 parent dba6fbb commit a4f59ae
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 0 deletions.
25 changes: 25 additions & 0 deletions Ahorn/entities/recordingStation.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
module RecordingStations

using ..Ahorn, Maple

@mapdef Entity "RecordingStations/RecordingStation" RecordingStation(x::Integer, y::Integer)

const placements = Ahorn.PlacementDict(
"Recording Station (Recording Stations)" => Ahorn.EntityPlacement(
RecordingStation
)
)

function Ahorn.selection(entity::RecordingStation)
x, y = Ahorn.position(entity)
width = 32
height = 16

return Ahorn.Rectangle(x - 16, y, width, height)
end

# TODO: change sprite
sprite = "objects/pico8Console"
Ahorn.render(ctx::Ahorn.Cairo.CairoContext, entity::RecordingStation, room::Maple.Room) = Ahorn.drawSprite(ctx, sprite, 0, 0)

end
36 changes: 36 additions & 0 deletions Entities/RecordingStation.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using Celeste;
using Celeste.Mod.Entities;
using Microsoft.Xna.Framework;
using Monocle;

namespace RecordingStations.Entities
{
/// <summary>
/// A Recording Station the player can interact with.
/// </summary>
[CustomEntity("RecordingStations/RecordingStation")]
public class RecordingStation : Entity
{
public TalkComponent InteractComponent;

public RecordingStation(EntityData data, Vector2 offset)
: base (data.Position + offset)
{
Depth = 1000;
Vector2 drawAt = new Vector2(data.Width / 2.0f, 0.0f);
Add(InteractComponent = new TalkComponent(
new Rectangle(-8, 0, 16, 16),
drawAt,
Interact));

Image image = new Image(GFX.Game["objects/pico8Console"]);
image.JustifyOrigin(0.5f, 0.5f);
Add(image);
}

public void Interact(Player player)
{
RecordingSystem.AdvanceNext();
}
}
}
3 changes: 3 additions & 0 deletions RecordingStations.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,13 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Entities\RecordingStation.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="RecordingStationsModule.cs" />
<Compile Include="RecordingSystem.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="Ahorn\entities\recordingStation.jl" />
<Content Include="everest.yaml" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
Expand Down
3 changes: 3 additions & 0 deletions RecordingStationsModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

namespace RecordingStations
{
/// <summary>
/// Base class for the mod
/// </summary>
public class RecordingStationsModule : EverestModule
{
public static RecordingStationsModule Instance;
Expand Down
28 changes: 28 additions & 0 deletions RecordingSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using Celeste.Mod;

namespace RecordingStations
{
/// <summary>
/// This is the base class for the recording and playback system.
/// </summary>
public static class RecordingSystem
{
public enum RecordingMode
{
Idle,
Recording,
Playback,
}

public static RecordingMode CurrentMode { get; private set; } = RecordingMode.Idle;

public static void AdvanceNext()
{
CurrentMode++;
if (CurrentMode > RecordingMode.Playback)
CurrentMode = RecordingMode.Idle;

Logger.Log("RecStation", "Changing mode to " + CurrentMode);
}
}
}

0 comments on commit a4f59ae

Please sign in to comment.