Skip to content

Commit

Permalink
Electricity system (#1371)
Browse files Browse the repository at this point in the history
* basic setup

* adding quickgraph

* add electric device interface

* making vertex coordinates

* getting back tileobjects from coordinates

* handle power in circuits

* add edges when adding electric device

* add generator prefab

* add interface implementations

* add switch light script

* add electric connectors

* simple electric adjacency connector

* updating electric prefabs and adding battery script

* little fix and prefab update

* update stuff

* LITTLE FIX

* fix asset grid ref

* disable all  unnecessary components

* fix stuff

* some fix

* some fix

* allow disabling destroy logic

* remove item code

* fix null exception

* fix unwanted diagonal connections

* fix some null ref exceptions and refactor code

* mostly doc

* refactor and doc

* refactor

* remove the call destroy stuff on actors

* add sound for fuel power generator

* add togglable generator

* fix generator asset

* add smess batteries

* add id for fuel powered generator sound

* Remove electric stuff

* removed more electric stuff

* smes battery power level update

* make pacman vibrate

* fix  power status update

* fix cable connections

* fix battery usage

now batteries have a max rate of power they can output

* power rate display on SMES

* fix left over power not helping batteries

* Add battery input display

* add toggling of batteries

* doc and clean up

* add tick based rate for electricity

* some doc

* fix to make build work

* fix build

* fix some stuff client side

* fix battery client syncing

* fix solar panel and add network object

* remove useless prefab

* fix solar panel asset

* replaced fuel power generator sound and added looping option

* isolate vibrate logic

* Delete Assets/Content/Data/TileMap/Resources/Furniture/Machines/Electricity.meta

* fix merge issues

* fix generator sound

* fix broken stuff

* fix cable not updating when deleting them

* add doc and clean up

* Cleanup

* Cleanup 2: electric boogaloo

* change on tick to fixed update

* simplify battery consuming method

* little comment

* Cleanup 3

* Cleanup 3

* Cleanup 18

* removed unused method

* probably infinite loop

* charge storages properly

* moving generic toggle to interaction

* fix prefabs

* use min max method

* renaming

* Remove extra strings

* Implement charge and drain algorithms

* fix exception when removing smes

* Revert "Implement charge and drain algorithms"

This reverts commit 2e92541.

* solve merge conflict

---------

Co-authored-by: Mechar418 <[email protected]>
  • Loading branch information
stilnat and iamteapot422 authored Dec 29, 2023
1 parent 92d2b89 commit a67b12c
Show file tree
Hide file tree
Showing 71 changed files with 2,095 additions and 108 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Assets/Art/Sound/Furniture/Machines/Engineering.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Assets/Content/Addressables/AssetGroups/Sounds.asset
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ MonoBehaviour:
m_Address: Assets/Art/Sound/World/Airlocks/AirlockOpen.ogg
m_ReadOnly: 0
m_SerializedLabels: []
- m_GUID: 59b65ecaf8dffbf49876ab2768490b59
m_Address: Assets/Art/Sound/Furniture/Machines/Engineering/FuelPowerGenerator.ogg
m_ReadOnly: 0
m_SerializedLabels: []
m_ReadOnly: 0
m_Settings: {fileID: 11400000, guid: ddc57d0f5f9fb874e8a26db0c5b215e0, type: 2}
m_SchemaSet:
Expand Down
2 changes: 2 additions & 0 deletions Assets/Content/Data/Databases/Sounds.asset
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,6 @@ MonoBehaviour:
_value: {fileID: 8300000, guid: fc2485e75c5d3ab4e86e814043c9e9cb, type: 3}
- _key: AirlockOpen
_value: {fileID: 8300000, guid: 34297ba204a9f3944872f100baaa2369, type: 3}
- _key: FuelPowerGenerator
_value: {fileID: 8300000, guid: 59b65ecaf8dffbf49876ab2768490b59, type: 3}
_new:
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 4584c35d672b8a74797cc5efa123ce16, type: 3}
m_Name: SolarPanel
m_EditorClassIdentifier:
nameString: SolarPanel
prefab: {fileID: 6286745912349171764, guid: f0eca2b8867709749bc10f61917c4bdf, type: 3}
prefab: {fileID: 941367499997148975, guid: f0eca2b8867709749bc10f61917c4bdf, type: 3}
icon: {fileID: 0}
layer: 7
genericType: 0
Expand Down
62 changes: 56 additions & 6 deletions Assets/Content/Scenes/Game.unity
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,54 @@ MonoBehaviour:
_scenePathHash: 2499635508
<SceneId>k__BackingField: 10735852762014670918
<AssetPathHash>k__BackingField: 0
--- !u!1 &478499394
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 478499395}
- component: {fileID: 478499396}
m_Layer: 0
m_Name: ElectricitySystem
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &478499395
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 478499394}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -700.46924, y: -415.26047, z: 42.020546}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 1506918115}
m_RootOrder: 17
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &478499396
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 478499394}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: cec52cc8cb291414f83ee8b575949b02, type: 3}
m_Name:
m_EditorClassIdentifier:
_componentIndexCache: 7
_addedNetworkObject: {fileID: 1506918116}
_networkObjectCache: {fileID: 1506918116}
_tickRate: 0.2
--- !u!1 &516802433
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -1155,8 +1203,8 @@ MonoBehaviour:
<ChildNetworkObjects>k__BackingField: []
SerializedTransformProperties:
Position: {x: 0, y: 0, z: 0}
Rotation: {x: 0, y: 0, z: 0, w: 0}
LocalScale: {x: 0, y: 0, z: 0}
Rotation: {x: 0, y: 0, z: 0, w: 1}
LocalScale: {x: 1, y: 1, z: 1}
_isNetworked: 1
_isGlobal: 0
_initializeOrder: 0
Expand Down Expand Up @@ -1232,9 +1280,9 @@ MonoBehaviour:
<ChildNetworkObjects>k__BackingField:
- {fileID: 913757968}
SerializedTransformProperties:
Position: {x: 0, y: 0, z: 0}
Rotation: {x: 0, y: 0, z: 0, w: 0}
LocalScale: {x: 0, y: 0, z: 0}
Position: {x: -1.510847, y: -0.9550402, z: -2.0797422}
Rotation: {x: 0, y: 0, z: 0, w: 1}
LocalScale: {x: 1, y: 1, z: 1}
_isNetworked: 1
_isGlobal: 0
_initializeOrder: 0
Expand Down Expand Up @@ -1439,7 +1487,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 4468402021075485018, guid: cc5383d385556f443b2a7d3202f2b2c1, type: 3}
propertyPath: m_AnchoredPosition.y
value: -230.00006
value: -229.99997
objectReference: {fileID: 0}
- target: {fileID: 4468402021449001342, guid: cc5383d385556f443b2a7d3202f2b2c1, type: 3}
propertyPath: m_AnchoredPosition.x
Expand Down Expand Up @@ -1967,6 +2015,7 @@ Transform:
- {fileID: 1121348073}
- {fileID: 606666309}
- {fileID: 274660131}
- {fileID: 478499395}
m_Father: {fileID: 0}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
Expand All @@ -1993,6 +2042,7 @@ MonoBehaviour:
- {fileID: 1121348074}
- {fileID: 606666310}
- {fileID: 274660132}
- {fileID: 478499396}
<ParentNetworkObject>k__BackingField: {fileID: 0}
<ChildNetworkObjects>k__BackingField:
- {fileID: 516802435}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ GameObject:
- component: {fileID: -5414623717715724467}
- component: {fileID: 1498482382929386799}
- component: {fileID: -2628458568064459714}
- component: {fileID: 219113547575591534}
- component: {fileID: 2550114539843098724}
- component: {fileID: -2157900375506616301}
- component: {fileID: 7239473696267242548}
- component: {fileID: 4189468537532167386}
m_Layer: 0
m_Name: PacManGenerator
m_TagString: Untagged
Expand Down Expand Up @@ -51,19 +56,21 @@ MonoBehaviour:
<IsNested>k__BackingField: 0
<ComponentIndex>k__BackingField: 0
<PredictedSpawn>k__BackingField: {fileID: 0}
_networkBehaviours: []
_networkBehaviours:
- {fileID: 219113547575591534}
- {fileID: -2157900375506616301}
<ParentNetworkObject>k__BackingField: {fileID: 0}
<ChildNetworkObjects>k__BackingField: []
SerializedTransformProperties:
Position: {x: 0, y: 0, z: 0}
Rotation: {x: 0, y: 0, z: 0, w: 0}
LocalScale: {x: 0, y: 0, z: 0}
Rotation: {x: 0, y: 0, z: 0, w: 1}
LocalScale: {x: 1, y: 1, z: 1}
_isNetworked: 1
_isGlobal: 0
_initializeOrder: 0
_defaultDespawnType: 0
NetworkObserver: {fileID: 0}
<PrefabId>k__BackingField: 0
<PrefabId>k__BackingField: 157
<SpawnableCollectionId>k__BackingField: 0
_scenePathHash: 0
<SceneId>k__BackingField: 0
Expand Down Expand Up @@ -93,6 +100,82 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
key: {fileID: 11400000, guid: 59526bd88a8f878449573560e06a54f9, type: 2}
--- !u!114 &219113547575591534
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1918783493706165866}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 328b489d4f8c1f04983e195ee8635c19, type: 3}
m_Name:
m_EditorClassIdentifier:
_componentIndexCache: 0
_addedNetworkObject: {fileID: -5414623717715724467}
_networkObjectCache: {fileID: -5414623717715724467}
_powerProduction: 10
_skinnedMeshRenderer: {fileID: 1698900335226549537}
_enabled: 0
--- !u!114 &2550114539843098724
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1918783493706165866}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: c7a41c77d19af89459c70cd823369e19, type: 3}
m_Name:
m_EditorClassIdentifier:
_amplitude: 1
_frequency: 35
--- !u!114 &-2157900375506616301
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1918783493706165866}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 1bbc87ddd49b01f4098910ffdf858004, type: 3}
m_Name:
m_EditorClassIdentifier:
_componentIndexCache: 1
_addedNetworkObject: {fileID: -5414623717715724467}
_networkObjectCache: {fileID: -5414623717715724467}
--- !u!65 &7239473696267242548
BoxCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1918783493706165866}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2
m_Size: {x: 0.9038, y: 0.9088632, z: 0.8278526}
m_Center: {x: -0.012657881, y: 0.42530543, z: 0.015189469}
--- !u!114 &4189468537532167386
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1918783493706165866}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: b621d3404247f2e4da4ab459ad43eec7, type: 3}
m_Name:
m_EditorClassIdentifier:
_componentIndexCache: 255
_addedNetworkObject: {fileID: -5414623717715724467}
_networkObjectCache: {fileID: 0}
_on: 0
--- !u!1 &4271595947011161493
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -186,7 +269,6 @@ GameObject:
m_Component:
- component: {fileID: 608453462504062702}
- component: {fileID: 1698900335226549537}
- component: {fileID: 5323246766978482323}
m_Layer: 0
m_Name: Body
m_TagString: Untagged
Expand Down Expand Up @@ -266,16 +348,3 @@ SkinnedMeshRenderer:
m_Center: {x: -0.007445082, y: 0.4215365, z: -0.0044316053}
m_Extent: {x: 0.41407037, y: 0.42270422, z: 0.41059247}
m_DirtyAABB: 0
--- !u!65 &5323246766978482323
BoxCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4379219507269237858}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2
m_Size: {x: 0.83231133, y: 0.8492101, z: 0.78938055}
m_Center: {x: -0.009774417, y: 0.42334524, z: 0.013316378}
Loading

0 comments on commit a67b12c

Please sign in to comment.