Skip to content

Commit 4af65ef

Browse files
committed
Overwrite GitHub repo with updated local files
1 parent 5090916 commit 4af65ef

13 files changed

Lines changed: 2117 additions & 654 deletions

ExampleMap - Copy.w3x

19.1 KB
Binary file not shown.

ExampleMap.w3x

2.02 KB
Binary file not shown.
7.07 KB
Binary file not shown.
7.67 KB
Binary file not shown.

imports/Splats/LightningData.slk

Lines changed: 1284 additions & 0 deletions
Large diffs are not rendered by default.

wurst.build

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,3 @@
22
projectName: TransportNetwork
33
dependencies:
44
- https://github.com/wurstscript/wurstStdlib2
5-
buildMapData:
6-
name: MyMapName
7-
fileName: MyMapFile
8-
author: Spellbound

wurst/Book.wurst

Lines changed: 51 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -19,40 +19,43 @@ public class Book
1919
Page lastPage
2020

2121
construct(int pageSize)
22-
pages = new HashMap<int, Page>
23-
maxItemsPerPage = pageSize
24-
numberOfPages = 0
25-
firstPage = null
26-
lastPage = null
27-
new Page(this)
22+
this.pages = new HashMap<int, Page>
23+
this.maxItemsPerPage = pageSize
24+
this.numberOfPages = 0
25+
this.firstPage = null
26+
this.lastPage = null
2827

2928
ondestroy
3029
destroy pages
3130

3231
function addPage(Page page)
33-
numberOfPages++
34-
page.number = numberOfPages
35-
pages.put(numberOfPages, page)
36-
firstPage = pages.get(1)
37-
lastPage = pages.get(numberOfPages)
32+
this.numberOfPages++
33+
page.number = this.numberOfPages
34+
this.pages.put(this.numberOfPages, page)
35+
this.firstPage = this.pages.get(1)
36+
this.lastPage = this.pages.get(this.numberOfPages)
3837

3938
/** this will not automatically refactor the list to remove blank spaces. Only remove last pages.*/
4039
function removePage(Page page)
41-
pages.remove(page.number)
42-
numberOfPages--
43-
lastPage = pages.get(numberOfPages)
40+
this.pages.remove(page.number)
41+
this.numberOfPages--
42+
if this.numberOfPages < 1
43+
this.firstPage = null
44+
this.lastPage = null
45+
else
46+
this.lastPage = this.pages.get(this.numberOfPages)
4447

4548
function getPage(int pageNumber) returns Page
46-
return pages.get(pageNumber)
49+
return this.pages.get(pageNumber)
4750

48-
function addUnitUI(UnitUI ui)
49-
lastPage.addItem(ui)
51+
function addPassenger(Passenger passenger)
52+
this.lastPage.addItem(passenger)
5053

51-
function removeUnitUI(UnitUI ui) returns int
52-
return ui.page.removeItem(ui)
54+
function removePassenger(Passenger passenger) returns int
55+
return passenger.page.removeItem(passenger)
5356

5457
function isEmpty() returns bool
55-
if pages.get(1) == null
58+
if this.pages.get(1) == null
5659
return true
5760
return false
5861

@@ -61,52 +64,52 @@ public class Page
6164
int number
6265
int maxSize
6366
Book book
64-
LinkedList<UnitUI> items
67+
LinkedList<Passenger> items
6568

6669
construct(Book whichBook)
67-
items = new LinkedList<UnitUI>
68-
number = 0
69-
maxSize = whichBook.maxItemsPerPage
70-
book = whichBook
70+
this.items = new LinkedList<Passenger>
71+
this.number = 0
72+
this.maxSize = whichBook.maxItemsPerPage
73+
this.book = whichBook
7174
whichBook.addPage(this)
7275

7376
ondestroy
74-
destroy items
77+
destroy this.items
7578

7679
/** if this current Page has reached its limit, a new page with a page number + 1 will be created, added to the same book, and returned.*/
77-
function addItem(UnitUI ui) returns thistype
78-
if items.size() < maxSize
79-
items.push(ui)
80-
ui.page = this
80+
function addItem(Passenger passenger) returns thistype
81+
if this.items.size() < this.maxSize
82+
this.items.push(passenger)
83+
passenger.page = this
8184
else
82-
let newPage = new Page(book)
83-
newPage.items.push(ui)
84-
ui.page = newPage
85+
let newPage = new Page(this.book)
86+
newPage.items.push(passenger)
87+
passenger.page = newPage
8588
return newPage
8689
return this
8790

88-
static function getNumFromItem(UnitUI ui) returns int
89-
return ui.page.number
91+
static function getNumFromItem(Passenger passenger) returns int
92+
return passenger.page.number
9093

9194
/** removes a frame from a Page and returns the number of that Page or the one before it if the Page becomes empty from that action. */
92-
function removeItem(UnitUI ui) returns int
93-
items.remove(ui)
94-
ui.page = null
95-
if items.isEmpty()
96-
let num = number - 1
97-
book.removePage(this)
95+
function removeItem(Passenger passenger) returns int
96+
this.items.remove(passenger)
97+
passenger.page = null
98+
if this.items.isEmpty()
99+
let num = this.number - 1
100+
this.book.removePage(this)
98101
destroy this
99102
return num
100103
else
101-
for pgNum = number to book.numberOfPages
102-
let currentPage = book.pages.get(pgNum)
103-
let nextPage = book.pages.get(pgNum + 1)
104+
for pgNum = this.number to this.book.numberOfPages
105+
let currentPage = this.book.pages.get(pgNum)
106+
let nextPage = this.book.pages.get(pgNum + 1)
104107
if nextPage != null
105108
while currentPage.items.size() < currentPage.maxSize and not nextPage.items.isEmpty()
106-
let ico = nextPage.items.dequeue()
107-
currentPage.items.push(ico)
108-
ico.page = currentPage
109+
let pass = nextPage.items.dequeue()
110+
currentPage.items.push(pass)
111+
pass.page = currentPage
109112
if nextPage.items.isEmpty()
110113
nextPage.book.removePage(nextPage)
111114
destroy nextPage
112-
return number
115+
return this.number

wurst/Demo.wurst

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import TransportNetwork
44
import UnitIndexer
55
import Assets
66

7-
constant LOAD_TIME = 1.
8-
constant UNLOAD_TIME = 1.
7+
constant LOAD_TIME = .5
8+
constant UNLOAD_TIME = .5
99
constant LOAD_RANGE = 160.
1010

1111

@@ -95,5 +95,6 @@ init
9595

9696
EventListener.add(EVENT_PLAYER_UNIT_DEATH) ->
9797
let u = EventData.getTriggerUnit()
98-
destroy networkHash.get(u)
99-
networkHash.remove(u)
98+
if networkHash.has(u)
99+
destroy networkHash.get(u)
100+
networkHash.remove(u)

wurst/HealthBar.wurst

Lines changed: 36 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -35,58 +35,60 @@ public class HealthBar
3535
private static let barList = new LinkedList<thistype>
3636

3737
framehandle hpBar
38-
unit source
38+
LinkedList<unit> assignments = new LinkedList<unit>
3939
bool isListed // prevents from having to search through a list all the time
40-
player owner
4140

42-
construct(framehandle parentFrame, unit u, player play, real height, real width)
41+
construct(framehandle parentFrame, real height, real width)
4342
hpBar = createSimpleFrame("MySimpleBar", parentFrame, 0)
4443
..setTexture(Textures.human_statbar_color3, 0, false)
4544
..setSize(width, height)
4645
..setPoint(FRAMEPOINT_TOPLEFT, parentFrame, FRAMEPOINT_BOTTOMLEFT)
4746
..hide()
48-
source = u
49-
owner = play
50-
isListed = false
47+
this.isListed = false
5148

49+
// this shouldn't be used at all tbh
5250
ondestroy
53-
unlist()
54-
hpBar.remove()
55-
source = null
51+
// hpBar.remove() // destroying framehandles can desync the game
52+
this.hpBar.hide()
53+
this.hpBar = null
5654

5755
function update()
58-
let percentage = source.getHP() / source.getMaxHP()
59-
int red
60-
int blue
61-
int green
62-
if percentage > .5
63-
let newPer = (percentage-.5)/.5
64-
red = ((HIGH_PEAK_RED * newPer) + HALF_RED).toInt()
65-
green = ((HIGH_PEAK_GREEN * newPer) + HALF_GREEN).toInt()
66-
blue = ((HIGH_PEAK_BLUE * newPer) + HALF_BLUE).toInt()
67-
else
68-
let newPer = percentage/.5
69-
red = ((LOW_PEAK_RED * newPer) + EMPTY_RED).toInt()
70-
green = ((LOW_PEAK_GREEN * newPer) + EMPTY_GREEN).toInt()
71-
blue = ((LOW_PEAK_BLUE * newPer) + EMPTY_BLUE).toInt()
72-
let barCol = color(red, green, blue)
73-
hpBar.setVertexColor(BlzConvertColor(255, barCol.red, barCol.green, barCol.blue))
74-
hpBar.setValue(percentage * 100.)
75-
76-
function unlist()
56+
for u in this.assignments
57+
let percentage = u.getHP() / u.getMaxHP()
58+
int red
59+
int blue
60+
int green
61+
if percentage > .5
62+
let newPer = (percentage-.5)/.5
63+
red = ((HIGH_PEAK_RED * newPer) + HALF_RED).toInt()
64+
green = ((HIGH_PEAK_GREEN * newPer) + HALF_GREEN).toInt()
65+
blue = ((HIGH_PEAK_BLUE * newPer) + HALF_BLUE).toInt()
66+
else
67+
let newPer = percentage/.5
68+
red = ((LOW_PEAK_RED * newPer) + EMPTY_RED).toInt()
69+
green = ((LOW_PEAK_GREEN * newPer) + EMPTY_GREEN).toInt()
70+
blue = ((LOW_PEAK_BLUE * newPer) + EMPTY_BLUE).toInt()
71+
let barCol = color(red, green, blue)
72+
if localPlayer == u.getOwner()
73+
this.hpBar.setVertexColor(BlzConvertColor(255, barCol.red, barCol.green, barCol.blue))
74+
this.hpBar.setValue(percentage * 100.)
75+
76+
function unassign(unit u)
77+
this.assignments.remove(u)
78+
this.hpBar.hide(u.getOwner())
7779
if isListed
7880
barList.remove(this)
79-
isListed = false
80-
hpBar.hide()
81+
this.isListed = false
8182
if barList.isEmpty()
8283
clock.release()
8384

84-
function list()
85+
function assign(unit u)
86+
this.assignments.push(u)
87+
this.hpBar.show(u.getOwner())
88+
this.update()
8589
if not isListed
8690
barList.push(this)
87-
isListed = true
88-
hpBar.show(owner)
89-
update()
91+
this.isListed = true
9092
if barList.size() == 1
9193
clock = getTimer()
9294
clock.startPeriodic(INTERVAL, function callback)

wurst/MousePos.wurst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ import ClosureEvents
55
public real array mouseX
66
public real array mouseY
77
public vec2 array mousePos
8-
//public unit array mouseFocusUnit
8+
// public unit array mouseFocusUnit
99

1010
init
1111
EventListener.add(EVENT_PLAYER_MOUSE_MOVE) ->
1212
let id = EventData.getTriggerPlayer().getId()
1313
mouseX[id] = BlzGetTriggerPlayerMouseX()
1414
mouseY[id] = BlzGetTriggerPlayerMouseY()
1515
mousePos[id] = vec2(mouseX[id], mouseY[id])
16-
//mouseFocusUnit[id] = BlzGetMouseFocusUnit()
16+
// mouseFocusUnit[id] = BlzGetMouseFocusUnit()

0 commit comments

Comments
 (0)