Untitled
unknown
plain_text
a year ago
3.9 kB
14
Indexable
# --AUTHOR--
# Jonathon D. Phillips
# Epic: Liyability
# X/Twitter: LiyabilityJP
# Discord: syntaxErr0rz#7445
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }
using { /UnrealEngine.com/Temporary/SpatialMath }
using { /Verse.org/Assets }
using { /Verse.org/Colors }
using { /Verse.org/Random }
vote_option := enum{ ONE, TWO }
vote_action := enum{ ADD, REMOVE }
vote_event := struct:
Option:vote_option
Action:vote_action
vote_system_device := class(creative_device):
@editable
VoteTimer:timer_device=timer_device{}
@editable
CustomPlayspace:custom_playspace=custom_playspace{}
@editable
CloseButtonText:string="EXIT"
@editable
FirstOptionText:string=""
@editable
FirstOptionTrigger:trigger_device=trigger_device{}
@editable
SecondOptionText:string=""
@editable
SecondOptionTrigger:trigger_device=trigger_device{}
@editable
FontColor:color=color{}
FirstVoteOptionTexture:texture=Textures.VoteOption1
SecondVoteOptionTexture:texture=Textures.VoteOption2
var PlayerVoteUIMap:[player]player_vote_ui=map{}
var FirstOptionVotes:int=0
var SecondOptionVotes:int=0
VoteHandledEvent<public>:event()=event(){}
VoteReceivedEvent<public>:event(vote_event)=event(vote_event){}
OnBegin<override>()<suspends>:void=
Sleep(0.0)
Self.CustomPlayspace.Init(Self)
Sleep(0.0)
for (Player : Self.CustomPlayspace.GetPlayers()). Player.InitVoteUI()
Self.VoteTimer.Start()
race:
Self.VoteTimer.SuccessEvent.Await()
sync:
loop:
Self.CustomPlayspace.JoinInProgressEvent.Await().HandleJoinInProgress()
loop:
Self.CustomPlayspace.LeaveInProgressEvent.Await().HandleLeaveInProgress()
loop:
Self.VoteReceivedEvent.Await().HandleVoteEvent()
Self.HandleVotes()
(InAgent:agent).HandleJoinInProgress<private>():void=
if (InPlayer := player[InAgent]). InPlayer.InitVoteUI()
(InAgent:agent).HandleLeaveInProgress<private>():void=
if (InPlayer := player[InAgent]). InPlayer.DestroyVoteUI()
(InPlayer:player).InitVoteUI<private>():void=
if (not PlayerVoteUIMap[InPlayer]):
PlayerVoteUI := player_vote_ui:
Player := InPlayer
ParentDevice := Self
if (set PlayerVoteUIMap[InPlayer] = PlayerVoteUI):
PlayerVoteUI.Init()
(InPlayer:player).DestroyVoteUI<private>():void=
if (PlayerVoteUI := PlayerVoteUIMap[InPlayer]):
set PlayerVoteUI.MaybeVoteOption = false
PlayerVoteUI.Destroy()
(InVoteEvent:vote_event).HandleVoteEvent<private>():void=
if (InVoteEvent.Action = vote_action.REMOVE):
if (InVoteEvent.Option = vote_option.ONE). set Self.FirstOptionVotes -= 1
else if (InVoteEvent.Option = vote_option.TWO). set Self.SecondOptionVotes -= 1
else if (InVoteEvent.Action = vote_action.ADD):
if (InVoteEvent.Option = vote_option.ONE). set Self.FirstOptionVotes += 1
else if (InVoteEvent.Option = vote_option.TWO). set Self.SecondOptionVotes += 1
Self.VoteHandledEvent.Signal()
HandleVotes<private>():void=
if (Self.FirstOptionVotes > Self.SecondOptionVotes):
Self.FirstOptionTrigger.Trigger()
else if (Self.FirstOptionVotes < Self.SecondOptionVotes):
Self.SecondOptionTrigger.Trigger()
else if (GetRandomInt(0,1) = 0). FirstOptionTrigger.Trigger()
else. SecondOptionTrigger.Trigger()
for (PlayerVoteUI : Self.PlayerVoteUIMap):
PlayerVoteUI.Destroy()Editor is loading...
Leave a Comment