-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Start Fog Of War #52 - Finish indirect fire - Implement an Event Relay - Improve LOS algorithm - Japanese environment
- Loading branch information
layagyasz
committed
Jun 5, 2018
1 parent
83ae7d8
commit 660f6f7
Showing
66 changed files
with
766 additions
and
280 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
using System; | ||
using Cardamom.Utilities; | ||
|
||
namespace PanzerBlitz | ||
{ | ||
public class EventRelay | ||
{ | ||
// Unit Events | ||
public EventHandler<EventArgs> OnUnitLoad; | ||
public EventHandler<ValuedEventArgs<Unit>> OnUnitUnload; | ||
public EventHandler<ValuedEventArgs<UnitConfiguration>> OnUnitConfigurationChange; | ||
public EventHandler<MovementEventArgs> OnUnitMove; | ||
public EventHandler<EventArgs> OnUnitFire; | ||
public EventHandler<ValuedEventArgs<Tile>> OnUnitRemove; | ||
public EventHandler<EventArgs> OnUnitDestroy; | ||
public EventHandler<ValuedEventArgs<Army>> OnUnitCapture; | ||
|
||
// Army Events | ||
public EventHandler<NewUnitEventArgs> OnUnitAdded; | ||
|
||
public void Hook(Match Match) | ||
{ | ||
foreach (var army in Match.Armies) Hook(army); | ||
} | ||
|
||
public void Hook(Army Army) | ||
{ | ||
Army.OnUnitAdded += HandleUnitAdded; | ||
foreach (var unit in Army.Units) Hook(unit); | ||
} | ||
|
||
public void Hook(Unit Unit) | ||
{ | ||
Unit.OnLoad += HandleUnitLoad; | ||
Unit.OnUnload += HandleUnitUnload; | ||
Unit.OnConfigurationChange += HandleUnitConfigurationChange; | ||
Unit.OnMove += HandleUnitMove; | ||
Unit.OnFire += HandleUnitFire; | ||
Unit.OnRemove += HandleUnitRemove; | ||
Unit.OnDestroy += HandleUnitDestroy; | ||
Unit.OnCapture += HandleUnitCapture; | ||
} | ||
|
||
void HandleUnitAdded(object Sender, NewUnitEventArgs E) | ||
{ | ||
Hook(E.Unit); | ||
OnUnitAdded?.Invoke(Sender, E); | ||
} | ||
|
||
void HandleUnitLoad(object Sender, EventArgs E) | ||
{ | ||
OnUnitLoad?.Invoke(Sender, E); | ||
} | ||
|
||
void HandleUnitUnload(object Sender, ValuedEventArgs<Unit> E) | ||
{ | ||
OnUnitUnload?.Invoke(Sender, E); | ||
} | ||
|
||
void HandleUnitConfigurationChange(object Sender, ValuedEventArgs<UnitConfiguration> E) | ||
{ | ||
OnUnitConfigurationChange?.Invoke(Sender, E); | ||
} | ||
|
||
void HandleUnitMove(object Sender, MovementEventArgs E) | ||
{ | ||
OnUnitMove?.Invoke(Sender, E); | ||
} | ||
|
||
void HandleUnitFire(object Sender, EventArgs E) | ||
{ | ||
OnUnitFire?.Invoke(Sender, E); | ||
} | ||
|
||
void HandleUnitRemove(object Sender, ValuedEventArgs<Tile> E) | ||
{ | ||
OnUnitRemove?.Invoke(Sender, E); | ||
} | ||
|
||
void HandleUnitDestroy(object Sender, EventArgs E) | ||
{ | ||
OnUnitDestroy?.Invoke(Sender, E); | ||
} | ||
|
||
void HandleUnitCapture(object Sender, ValuedEventArgs<Army> E) | ||
{ | ||
OnUnitCapture?.Invoke(Sender, E); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.