-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
160 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+215 Bytes
(100%)
NebulaPluginNova/Resources/Addons/NebulaRemakeLanguage.zip
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
using Nebula.Game.Statistics; | ||
using Virial; | ||
using Virial.Assignable; | ||
using Virial.Configuration; | ||
using Virial.Events.Player; | ||
using Virial.Game; | ||
|
||
namespace Nebula.Roles.Crewmate; | ||
|
||
public class Knight : DefinedRoleTemplate, DefinedRole | ||
{ | ||
private Knight() : base("knight", new(198, 97, 97), RoleCategory.CrewmateRole, Crewmate.MyTeam, [BlockCoolDownOption, BlockDurationOption]) { } | ||
|
||
RuntimeRole RuntimeAssignableGenerator<RuntimeRole>.CreateInstance(Virial.Game.Player player, int[] arguments) => new Instance(player); | ||
|
||
private static FloatConfiguration BlockCoolDownOption = NebulaAPI.Configurations.Configuration("options.role.knight.blockCoolDown", (2.5f, 60f, 2.5f), 30f, FloatConfigurationDecorator.Second); | ||
private static FloatConfiguration BlockDurationOption = NebulaAPI.Configurations.Configuration("options.role.knight.blockDuration", (1f, 10f, 0.5f), 5f, FloatConfigurationDecorator.Second); | ||
|
||
public static Knight MyRole = new Knight(); | ||
public class Instance : RuntimeAssignableTemplate, RuntimeRole | ||
{ | ||
DefinedRole RuntimeRole.Role => MyRole; | ||
public Instance(Virial.Game.Player player) : base(player) { } | ||
private static Image buttonSprite = SpriteLoader.FromResource("Nebula.Resources.Buttons.BlockButton.png", 115f); | ||
private AchievementToken<(bool cleared, int count)>? acTokenChallenge; | ||
private ModAbilityButton blockButton = null!; | ||
internal static Dictionary<byte, bool> BlockMurderingTab = new(); | ||
|
||
void RuntimeAssignable.OnActivated() | ||
{ | ||
BlockMurderingTab = new(); | ||
if (AmOwner) | ||
{ | ||
acTokenChallenge = new("knight.challenge", (false, 0), (val, _) => val.cleared); | ||
|
||
blockButton = Bind(new ModAbilityButton()).KeyBind(Virial.Compat.VirtualKeyInput.Ability); | ||
|
||
blockButton.SetSprite(buttonSprite.GetSprite()); | ||
blockButton.Availability = (button) => MyPlayer.CanMove; | ||
blockButton.Visibility = (button) => !MyPlayer.IsDead; | ||
blockButton.OnClick = (button) => | ||
{ | ||
button.ActivateEffect(); | ||
}; | ||
blockButton.OnEffectStart = (button) => | ||
{ | ||
acTokenChallenge!.Value.count = 0; | ||
RpcSetBlock.Invoke((MyPlayer.PlayerId, true)); | ||
}; | ||
blockButton.OnEffectEnd = (button) => | ||
{ | ||
RpcSetBlock.Invoke((MyPlayer.PlayerId, false)); | ||
button.StartCoolDown(); | ||
}; | ||
blockButton.CoolDownTimer = Bind(new Timer(BlockCoolDownOption).SetAsAbilityCoolDown().Start()); | ||
blockButton.EffectTimer = Bind(new Timer(BlockDurationOption)); | ||
blockButton.SetLabelType(Virial.Components.ModAbilityButton.LabelType.Standard); | ||
blockButton.SetLabel("block"); | ||
} | ||
} | ||
|
||
void RuntimeAssignable.OnInactivated() | ||
{ | ||
RpcSetBlock.Invoke((MyPlayer.PlayerId, false)); | ||
} | ||
|
||
[OnlyMyPlayer] | ||
void CheckKill(PlayerCheckKillEvent ev) | ||
{ | ||
//ev.Result = KillResult.Guard; | ||
//return; | ||
//Debug.Log($"{ev.Killer.PlayerId} {MyPlayer.PlayerId}"); | ||
if (ev.IsMeetingKill || ev.EventDetail == EventDetail.Curse) return; | ||
if (ev.Killer.PlayerId == MyPlayer.PlayerId) return; | ||
bool temp; | ||
//Debug.Log(result.ToString()); | ||
ev.Result = (BlockMurderingTab.TryGetValue(ev.Player.PlayerId, out temp) && temp) ? KillResult.Guard : KillResult.Kill; | ||
} | ||
|
||
[OnlyMyPlayer] | ||
void OnGuard(PlayerGuardEvent ev) | ||
{ | ||
if (AmOwner) | ||
{ | ||
Debug.Log("OnGuard"); | ||
new StaticAchievementToken("knight.common1"); | ||
new StaticAchievementToken("knight.common2"); | ||
acTokenChallenge!.Value.count++; | ||
if (acTokenChallenge!.Value.count >= 3) | ||
{ | ||
acTokenChallenge!.Value.cleared = true; | ||
} | ||
} | ||
} | ||
} | ||
private static readonly RemoteProcess<(byte playerId, bool status)> RpcSetBlock = new( | ||
"SetBlock", (message, _) => | ||
{ | ||
Instance.BlockMurderingTab[message.playerId] = message.status; | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters