Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Electricity system #1371

Merged
merged 96 commits into from
Dec 29, 2023
Merged
Changes from 1 commit
Commits
Show all changes
96 commits
Select commit Hold shift + click to select a range
b815234
basic setup
stilnat Nov 30, 2023
a9a8073
adding quickgraph
stilnat Nov 30, 2023
6adfee5
add electric device interface
stilnat Nov 30, 2023
01f4cc9
making vertex coordinates
stilnat Nov 30, 2023
be52087
getting back tileobjects from coordinates
stilnat Dec 1, 2023
581e328
handle power in circuits
stilnat Dec 1, 2023
4118ed7
add edges when adding electric device
stilnat Dec 1, 2023
921b01a
add generator prefab
stilnat Dec 1, 2023
848aa6d
add interface implementations
stilnat Dec 1, 2023
c5ef0b5
add switch light script
stilnat Dec 1, 2023
beacd7c
add electric connectors
stilnat Dec 1, 2023
b5ff483
simple electric adjacency connector
stilnat Dec 1, 2023
7ba27cb
updating electric prefabs and adding battery script
stilnat Dec 1, 2023
a84d5ff
little fix and prefab update
stilnat Dec 1, 2023
1733b9a
update stuff
stilnat Dec 1, 2023
c9f3d42
LITTLE FIX
stilnat Dec 1, 2023
0e90820
Merge branch 'develop' into electricity
stilnat Dec 1, 2023
ed1df27
fix asset grid ref
stilnat Dec 1, 2023
53aa0d2
disable all unnecessary components
stilnat Dec 1, 2023
3597cb9
Merge branch 'make-construction-hologram-real-hologram' into electricity
stilnat Dec 1, 2023
3de2ddb
fix stuff
stilnat Dec 1, 2023
aa1fcd5
some fix
stilnat Dec 2, 2023
79db9c3
some fix
stilnat Dec 2, 2023
07066d2
allow disabling destroy logic
stilnat Dec 2, 2023
91de672
remove item code
stilnat Dec 2, 2023
3048bea
Merge branch 'actor-custom-destroy' into electricity
stilnat Dec 2, 2023
c9a5581
fix null exception
stilnat Dec 2, 2023
0273fdb
fix unwanted diagonal connections
stilnat Dec 2, 2023
8e64143
fix some null ref exceptions and refactor code
stilnat Dec 6, 2023
89a6864
mostly doc
stilnat Dec 6, 2023
d91aef5
refactor and doc
stilnat Dec 6, 2023
72ea6bd
refactor
stilnat Dec 6, 2023
9cf8ca9
remove the call destroy stuff on actors
stilnat Dec 6, 2023
9a7a4de
add sound for fuel power generator
stilnat Dec 6, 2023
29d6b99
add togglable generator
stilnat Dec 6, 2023
de742e2
fix generator asset
stilnat Dec 6, 2023
0c8ef32
add smess batteries
stilnat Dec 6, 2023
26cf6f7
add id for fuel powered generator sound
stilnat Dec 6, 2023
b664c91
Merge branch 'develop' into electricity
stilnat Dec 7, 2023
e442d5e
Remove electric stuff
stilnat Dec 7, 2023
4631f16
removed more electric stuff
stilnat Dec 7, 2023
4d2d36d
Merge branch 'develop' into electricity
stilnat Dec 7, 2023
6946ba4
smes battery power level update
stilnat Dec 7, 2023
c84f15d
make pacman vibrate
stilnat Dec 8, 2023
eabd2a3
fix power status update
stilnat Dec 8, 2023
985c2c6
fix cable connections
stilnat Dec 8, 2023
0a44eed
fix battery usage
stilnat Dec 8, 2023
e7c0e84
power rate display on SMES
stilnat Dec 8, 2023
f4fb7ed
fix left over power not helping batteries
stilnat Dec 8, 2023
38ac53f
Add battery input display
stilnat Dec 9, 2023
a753696
add toggling of batteries
stilnat Dec 9, 2023
13d935c
doc and clean up
stilnat Dec 9, 2023
c55d598
add tick based rate for electricity
stilnat Dec 9, 2023
80a1716
some doc
stilnat Dec 9, 2023
39977f6
Merge branch 'develop' into electricity
stilnat Dec 9, 2023
3f7c296
fix to make build work
stilnat Dec 9, 2023
d562005
Merge branch 'develop' into electricity
stilnat Dec 11, 2023
cddabb3
fix build
stilnat Dec 12, 2023
75a8987
fix some stuff client side
stilnat Dec 12, 2023
879af4c
fix battery client syncing
stilnat Dec 12, 2023
c025e0f
fix solar panel and add network object
stilnat Dec 12, 2023
e456f34
remove useless prefab
stilnat Dec 12, 2023
ef5c522
fix solar panel asset
stilnat Dec 13, 2023
c38bfe5
replaced fuel power generator sound and added looping option
stilnat Dec 14, 2023
cdc4b2c
isolate vibrate logic
stilnat Dec 14, 2023
f561c28
Delete Assets/Content/Data/TileMap/Resources/Furniture/Machines/Elect…
stilnat Dec 14, 2023
8434cc0
Merge branch 'develop' into electricity
stilnat Dec 14, 2023
67c7a2b
Merge branch 'develop' into electricity
stilnat Dec 15, 2023
99ff05b
fix merge issues
stilnat Dec 15, 2023
0584718
fix generator sound
stilnat Dec 15, 2023
8c45d85
Merge branch 'develop' into electricity
stilnat Dec 15, 2023
37ccc86
Merge branch 'develop' into electricity
stilnat Dec 15, 2023
d32439c
fix broken stuff
stilnat Dec 15, 2023
5f68c97
fix cable not updating when deleting them
stilnat Dec 16, 2023
e2df7cd
add doc and clean up
stilnat Dec 16, 2023
e931032
Merge branch 'develop' into electricity
stilnat Dec 16, 2023
65943d4
Cleanup
iamteapot422 Dec 21, 2023
01b72a6
Cleanup 2: electric boogaloo
iamteapot422 Dec 21, 2023
6ef404a
change on tick to fixed update
stilnat Dec 21, 2023
3f7ba18
simplify battery consuming method
stilnat Dec 23, 2023
d10709b
little comment
stilnat Dec 23, 2023
946bcc4
Cleanup 3
iamteapot422 Dec 23, 2023
2a524c6
Cleanup 3
iamteapot422 Dec 23, 2023
b638c94
Cleanup 18
iamteapot422 Dec 23, 2023
aea0124
removed unused method
stilnat Dec 24, 2023
eaeb08e
probably infinite loop
stilnat Dec 24, 2023
7f89b58
charge storages properly
stilnat Dec 27, 2023
0cde29d
moving generic toggle to interaction
stilnat Dec 27, 2023
223504b
fix prefabs
stilnat Dec 27, 2023
f4d58d3
use min max method
stilnat Dec 27, 2023
c1447ae
renaming
stilnat Dec 27, 2023
886f9d1
Remove extra strings
iamteapot422 Dec 28, 2023
2e92541
Implement charge and drain algorithms
iamteapot422 Dec 28, 2023
c3a616a
fix exception when removing smes
stilnat Dec 28, 2023
a671d1c
Revert "Implement charge and drain algorithms"
stilnat Dec 28, 2023
5b7a7da
solve merge conflict
iamteapot422 Dec 29, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
getting back tileobjects from coordinates
stilnat committed Dec 1, 2023
commit be52087094003be7ad8ccc703852d80b4bde11bd
10 changes: 10 additions & 0 deletions Assets/Scripts/SS3D/Systems/Electricity/Circuit.cs
Original file line number Diff line number Diff line change
@@ -12,6 +12,16 @@ public class Circuit



public void AddConsumer(IPowerConsumer consumer)
{

}

public void AddProducer(IPowerProducer producer)
{

}


// when removing one element of the circuit, start a tree search for all connected elements to that element,
// accordingly updating circuits ?
24 changes: 20 additions & 4 deletions Assets/Scripts/SS3D/Systems/Electricity/ElectricitySystem.cs
Original file line number Diff line number Diff line change
@@ -27,10 +27,10 @@ public class ElectricitySystem : NetworkSystem

private struct VerticeCoordinates
{
short x;
short y;
byte layer;
byte direction;
public short x;
public short y;
public byte layer;
public byte direction;

public VerticeCoordinates(short xcoordinate, short yccordinate, byte zcoordinate, byte directionCoordinate)
{
@@ -91,6 +91,22 @@ private void HandleUpdate(ref EventContext context, in UpdateEvent updateEvent)
group => group.Key,
group => group.Select(item => item.Key).ToList()
);



foreach ( List<VerticeCoordinates> component in graphs.Values )
{
_circuits.Add(new Circuit());
foreach(VerticeCoordinates coord in component)
{
TileSystem tileSystem = Subsystems.Get<TileSystem>();
ITileLocation location = tileSystem.CurrentMap.GetTileLocation((TileLayer) coord.layer, new Vector3(coord.x, coord.y));

if(! location.TryGetPlacedObject(out PlacedTileObject placedObject, (Direction) coord.direction)) continue;

if (placedObject.GetComponent<IPowerConsumer>() != null) _circuits.Last().AddConsumer(placedObject.GetComponent<IPowerConsumer>());
}
}
}

public void AddElectricalElement(IElectricDevice device)
4 changes: 2 additions & 2 deletions Assets/Scripts/SS3D/Systems/Tile/TileMap.cs
Original file line number Diff line number Diff line change
@@ -110,14 +110,14 @@ public TileChunk GetChunk(Vector3 worldPosition)
}
}

private ITileLocation GetTileLocation(TileLayer layer, Vector3 worldPosition)
public ITileLocation GetTileLocation(TileLayer layer, Vector3 worldPosition)
{
TileChunk chunk = GetOrCreateChunk(worldPosition); // TODO: creates unnessary empty chunk when checking whether building can be done
return chunk.GetTileObject(layer, worldPosition);
}


private ITileLocation[] GetTileLocations(Vector3 worldPosition)
public ITileLocation[] GetTileLocations(Vector3 worldPosition)
{
ITileLocation[] tileObjects = new ITileLocation[TileHelper.GetTileLayers().Length];