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

"Live" power system implementation #602

Closed
4 of 5 tasks
Grenkin1988 opened this issue Aug 22, 2016 · 33 comments
Closed
4 of 5 tasks

"Live" power system implementation #602

Grenkin1988 opened this issue Aug 22, 2016 · 33 comments

Comments

@Grenkin1988
Copy link
Contributor

Grenkin1988 commented Aug 22, 2016

Power system discussion
Currently, initially developed by @TheRiven , we have “static” power system:

  • Power generator produce amount of power
  • Power consumers consume it
    Power level = sum of power generators – sum of power consumers.
    It is already possible to change power level of objects on fly representing not operating objects.
    But we need to solve issue () when generators are refueling. Right now generator stops working and all things that need power also. This could be solved by refueling generator earlier that it has absolute zero.

Another solution is to have “live” power system:

  • Power generators produce amount of power per time.
  • Power consumers need amount/time power for operation
  • Something should accumulate power excess.
    This looks a little bit more realistic but this would involve implementation of this produce/consume logic.

We need to decide what we what now. Later this would be very difficult to change. Lets discuss this and find out all drawbacks of both types.
@quill18 just to make sure quill is involved in core discussion :-)

As decided, implementation of “Live” power system is going on.

New power system is in place
Connection is used to represent that Furniture has connection to power system.
System can contain multiple Grid.
In the future logic for new Grid generation depending on wires could be added.
In XML – new tag: <PowerConnection inputRate="" outputRate="5" capacity=""/>
inputRate – power consumption
outputRate – power production
capacity – maximum accumulated power

Implementation iterations:

@GamerInspired
Copy link

I think I prefer the "live" power system as I could be expanded on more easily later on.

@sboigelot
Copy link
Collaborator

We could also take the advantage to make the system more generic then just power.

It could be any stream requirement.

For instance RAM or CPU usage. Some computer are producer of CPU power, some machine use it, etc..

@Ferr013
Copy link

Ferr013 commented Aug 22, 2016

I think the "live" solution could be more realistic: imagine a nuclear reactor that produces (x) Watt per hour, or a dam with an hydroelectric turbine. We could assume that the power they produce is constant through time, so we can average an amount of power available each second and apply the same approach to power-consumers. The power in excess could be stored in a backup battery (in case the generators are damaged).
Since we are in space, it could be possible to have also solar panels (that have to be installed in a room with index zero) as well as the already implemented uranium based power supply!

@Grenkin1988
Copy link
Contributor Author

I was thinking to have this pattern for all furniture. It just should have <Consume> and <Produce>

@Xeni91
Copy link
Contributor

Xeni91 commented Aug 22, 2016

@Grenkin1988 do we have to differntiate this? Why cant we just use a <power> tag and increase it with generators and decrease it with consuming furniture?

@Grenkin1988
Copy link
Contributor Author

@Xeni91 My last comment was not about power. It was just thoughts about generic solution. Some objects could produce multiple things, and consume multiple things

@mikejbrown
Copy link
Contributor

So like a generic resource system? We could have (say) IProducer and IConsumer interfaces which classes implement as needed. A consumer could then register a callback with a producer, or a producer manager class, saying that it wants to know any time a new unit of resource X is produced... Then the internal logic of the callbacks can be very simple. The trickiest thing would be to keep connections up to date as objects are built/destroyed. Is this the sort of thing you are thinking of?

@Grenkin1988
Copy link
Contributor Author

Grenkin1988 commented Aug 22, 2016

@mikejbrown Some kind of. But let's focus on power system right now :-) Producer/Consumer pattern is topic for another issue. Should I create one?

@quill18
Copy link
Member

quill18 commented Aug 22, 2016

@sboigelot I like the concept of a generic "stream" to/from resource consumers/producers.

I also like the idea of it being "live". Unlike base Rimworld, I think it would be nice if things only consumed power while performing their task. This could lead to surges in demand, making batteries (and/or capacitors) very important parts of the network.

@quill18
Copy link
Member

quill18 commented Aug 22, 2016

It's possible that all consumers -- but really "spiky" ones in particular, like lasers -- should probably act as their own capacitor/battery. They will "consume" up to X power to charge their battery, but then stop consuming from the network while their battery is full.

@mikejbrown
Copy link
Contributor

@quill18 definitely like needing power only when working & having a real need for batteries... but only as long as you don't have Rimworld's zzzzt event! :)

@Grenkin1988
Copy link
Contributor Author

Grenkin1988 commented Aug 22, 2016

For now most people is for "live' power system. But more feedback is needed. We should also remember that somebody going to implement Utility System - Pipes, Power Conduits, Air Ducts and so on

@Grenkin1988
Copy link
Contributor Author

@quill18 @sboigelot I opened another issue to discuss this #604

@TheRiven
Copy link
Contributor

As with most I would agree that switching to a live system would probably be a good next stage for the power system. 👍

And yeah it will definitely need to keep that future Utility system in mind so it will be easier to put them together later.

@Grenkin1988
Copy link
Contributor Author

If nobody against I am going to do some prototyping for this. For "live" system with possibility for improvements with connections

@ajahraus
Copy link

@quill18 I love the idea of batteries and capacitors. I think that they could provide a fun game mechanic.

Like perhaps batteries should be good for storing power (i.e. store large amounts of charge for long periods of time) but bad for providing power (i.e. charge/discharge slowly or else they take some type of 'damage').

Capacitors on the other hand change and discharge very quickly (making them great for high power activities like laser weapons) but gradually lose charge over time, making them bad for storage.

Maybe in a space fight between ships, being able to fire laser cannons more quickly depends on how many capacitors you can keep charged? Perhaps it's too early for this type of discussion, but I think it has potential.

@Grenkin1988
Copy link
Contributor Author

Grenkin1988 commented Aug 24, 2016

#761 More to be added soon

@vogonistic vogonistic added this to the Version 0.1 milestone Aug 24, 2016
@vogonistic vogonistic changed the title [Discussion] [Question] Power system discussion Power system discussion Aug 24, 2016
@vogonistic
Copy link
Collaborator

After reading the code in #793 I realized that PowerRelated is a connection between a Furniture and the PowerGrid. Have you considered putting the whole system in a namespace Power and call them Grid and Connection? It'd would be PowerConnection in the XML.

The new job system I'm working on is in a namespace ProjectPorcupine.Jobs

@Grenkin1988
Copy link
Contributor Author

@vogonistic All my new code is in PowerSystem folder. But I think there is no such thing as namespase in Unity? But I definitely could go for PowerConnection

@vogonistic
Copy link
Collaborator

Unity has namespaces and it works fine in my tests.

https://docs.unity3d.com/540/Documentation/Manual/Namespaces.html

@NogginBops
Copy link
Contributor

@Grenkin1988 You just need to put the classes in a namespace and you have a namespace. Unity doesn't care.

@Grenkin1988
Copy link
Contributor Author

Next iteration ready for review #968

@Grenkin1988
Copy link
Contributor Author

Grenkin1988 commented Aug 29, 2016

New live power system is in place and all existing Furniture updated to use new system

@Grenkin1988 Grenkin1988 changed the title Power system discussion "Live" power system implementation Aug 30, 2016
@Grenkin1988
Copy link
Contributor Author

Added fully operating accumulator with placeholder image #1079

@Grenkin1988
Copy link
Contributor Author

Next would be save/load but I would prefer to wait with it before we finished or data format discussion.

P.S.: just interesting does anyone read my updates :-)

@vogonistic
Copy link
Collaborator

I read everything :)

@mikejbrown
Copy link
Contributor

mikejbrown commented Sep 30, 2016

Where is this on the save/load logic? This is currently assigned to v0.1. Are you close or do you want to bump the last step to v0.2?

If you want to wait for the data format to settle it might be best to bump it in case it changes for v0.2.

@mikejbrown mikejbrown mentioned this issue Oct 2, 2016
19 tasks
@mikejbrown
Copy link
Contributor

Alternately if anyone wants to claim "Implement save/load logic for system" please do so here and submit your own PR.

@mikejbrown
Copy link
Contributor

Okay, bumping this.

@mikejbrown mikejbrown removed this from the Version 0.1 milestone Oct 3, 2016
@bjubes
Copy link
Collaborator

bjubes commented Oct 3, 2016

@mikejbrown neither @TheRiven or @Grenkin1988 have branches on their repos so I assume that any work that is not already merged into master is non-existent or is being implemented by someone else. as said by @Grenkin1988 he held of on saving b/c of the data format discussion

@mikejbrown mikejbrown added this to the Version 0.2 milestone Oct 5, 2016
@dusho
Copy link
Contributor

dusho commented Oct 16, 2016

what is meant by save/load here.. only current statuses of accumulators? If yes, then it should be covered by #1520

@dusho
Copy link
Contributor

dusho commented Oct 25, 2016

now that #1520 is merged, this can be closed, I guess.. unless there is still something missing...

@koosemose
Copy link
Collaborator

Closing as this seems to be addressed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests