mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-09 21:59:16 +00:00
add events
This commit is contained in:
parent
36b877c358
commit
ca38f789fe
@ -3,6 +3,7 @@ using QSB.ConversationSync;
|
||||
using QSB.DeathSync;
|
||||
using QSB.ElevatorSync;
|
||||
using QSB.GeyserSync;
|
||||
using QSB.Instruments.Events;
|
||||
using QSB.OrbSync;
|
||||
using QSB.TimeSync;
|
||||
using QSB.Tools;
|
||||
@ -11,9 +12,6 @@ using System.Collections.Generic;
|
||||
|
||||
namespace QSB.Events
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates instances of all of the events QSB uses.
|
||||
/// </summary>
|
||||
public static class EventList
|
||||
{
|
||||
public static bool Ready { get; private set; }
|
||||
@ -43,7 +41,8 @@ namespace QSB.Events
|
||||
new OrbSlotEvent(),
|
||||
new OrbUserEvent(),
|
||||
new ConversationEvent(),
|
||||
new ConversationStartEndEvent()
|
||||
new ConversationStartEndEvent(),
|
||||
new PlayInstrumentEvent()
|
||||
};
|
||||
|
||||
_eventList.ForEach(ev => ev.SetupListener());
|
||||
|
@ -34,5 +34,6 @@
|
||||
public static string QSBOrbUser = "QSBOrbUser";
|
||||
public static string QSBConversation = "QSBConversation";
|
||||
public static string QSBConversationStartEnd = "QSBConversationStartEnd";
|
||||
public static string QSBPlayInstrument = "QSBPlayInstrument";
|
||||
}
|
||||
}
|
||||
|
23
QSB/Instruments/Events/PlayInstrumentEvent.cs
Normal file
23
QSB/Instruments/Events/PlayInstrumentEvent.cs
Normal file
@ -0,0 +1,23 @@
|
||||
using QSB.Events;
|
||||
using QSB.Messaging;
|
||||
|
||||
namespace QSB.Instruments.Events
|
||||
{
|
||||
public class PlayInstrumentEvent : QSBEvent<PlayInstrumentMessage>
|
||||
{
|
||||
public override EventType Type => EventType.FullStateRequest;
|
||||
|
||||
public override void SetupListener() => GlobalMessenger<InstrumentType, bool>.AddListener(EventNames.QSBPlayerStatesRequest, Handler);
|
||||
|
||||
public override void CloseListener() => GlobalMessenger<InstrumentType, bool>.RemoveListener(EventNames.QSBPlayerStatesRequest, Handler);
|
||||
|
||||
private void Handler(InstrumentType type, bool state) => SendEvent(CreateMessage(type, state));
|
||||
|
||||
private PlayInstrumentMessage CreateMessage(InstrumentType type, bool state) => new PlayInstrumentMessage
|
||||
{
|
||||
AboutId = LocalPlayerId,
|
||||
Type = type,
|
||||
State = state
|
||||
};
|
||||
}
|
||||
}
|
25
QSB/Instruments/Events/PlayInstrumentMessage.cs
Normal file
25
QSB/Instruments/Events/PlayInstrumentMessage.cs
Normal file
@ -0,0 +1,25 @@
|
||||
using QSB.Messaging;
|
||||
using UnityEngine.Networking;
|
||||
|
||||
namespace QSB.Instruments.Events
|
||||
{
|
||||
public class PlayInstrumentMessage : PlayerMessage
|
||||
{
|
||||
public InstrumentType Type;
|
||||
public bool State;
|
||||
|
||||
public override void Deserialize(NetworkReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
Type = (InstrumentType)reader.ReadInt32();
|
||||
State = reader.ReadBoolean();
|
||||
}
|
||||
|
||||
public override void Serialize(NetworkWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
writer.Write((int)Type);
|
||||
writer.Write(State);
|
||||
}
|
||||
}
|
||||
}
|
17
QSB/Instruments/InstrumentType.cs
Normal file
17
QSB/Instruments/InstrumentType.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace QSB.Instruments
|
||||
{
|
||||
public enum InstrumentType
|
||||
{
|
||||
CHERT,
|
||||
ESKER,
|
||||
FELDSPAR,
|
||||
GABBRO,
|
||||
REIBECK,
|
||||
SOLANUM
|
||||
}
|
||||
}
|
@ -148,6 +148,9 @@
|
||||
<Compile Include="Events\EventNames.cs" />
|
||||
<Compile Include="DeathSync\PlayerDeathEvent.cs" />
|
||||
<Compile Include="Events\IQSBEvent.cs" />
|
||||
<Compile Include="Instruments\Events\PlayInstrumentEvent.cs" />
|
||||
<Compile Include="Instruments\Events\PlayInstrumentMessage.cs" />
|
||||
<Compile Include="Instruments\InstrumentType.cs" />
|
||||
<Compile Include="Instruments\QSBCamera\CameraController.cs" />
|
||||
<Compile Include="Instruments\QSBCamera\CameraManager.cs" />
|
||||
<Compile Include="Instruments\QSBCamera\CameraMode.cs" />
|
||||
|
Loading…
Reference in New Issue
Block a user