ammonia thingy
This commit is contained in:
parent
97fb9100ab
commit
bec60f2152
9 changed files with 43 additions and 3 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
[gd_resource type="Resource" script_class="Substance" load_steps=2 format=3 uid="uid://dr65qbkum4emy"]
|
[gd_resource type="Resource" script_class="Substance" load_steps=3 format=3 uid="uid://dr65qbkum4emy"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://b8q5buwgvppyh" path="res://src/resources/substance.gd" id="1_551qc"]
|
[ext_resource type="Script" uid="uid://b8q5buwgvppyh" path="res://src/resources/substance.gd" id="1_551qc"]
|
||||||
|
[ext_resource type="Resource" uid="uid://dn10p6rbdd7qb" path="res://assets/substances/CH3COOH.tres" id="2_2qskh"]
|
||||||
|
|
||||||
[resource]
|
[resource]
|
||||||
script = ExtResource("1_551qc")
|
script = ExtResource("1_551qc")
|
||||||
|
|
@ -8,5 +9,8 @@ formula = &"CH_3COONa"
|
||||||
scientific_name = &"Ацетат натрия"
|
scientific_name = &"Ацетат натрия"
|
||||||
melting_point = 328.0
|
melting_point = 328.0
|
||||||
boiling_point = 9999999999.0
|
boiling_point = 9999999999.0
|
||||||
|
pHIonicOverrides = Dictionary[ExtResource("1_551qc"), float]({
|
||||||
|
ExtResource("2_2qskh"): 4.8
|
||||||
|
})
|
||||||
color = Color(1, 1, 1, 1)
|
color = Color(1, 1, 1, 1)
|
||||||
metadata/_custom_type_script = "uid://b8q5buwgvppyh"
|
metadata/_custom_type_script = "uid://b8q5buwgvppyh"
|
||||||
|
|
|
||||||
7
assets/substances/NH4OH.tres
Normal file
7
assets/substances/NH4OH.tres
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
[gd_resource type="Resource" script_class="Substance" load_steps=2 format=3 uid="uid://b2iqhriy265ik"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" uid="uid://b8q5buwgvppyh" path="res://src/resources/substance.gd" id="1_ctlfr"]
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
script = ExtResource("1_ctlfr")
|
||||||
|
metadata/_custom_type_script = "uid://b8q5buwgvppyh"
|
||||||
|
|
@ -23,7 +23,7 @@ script_export_mode=2
|
||||||
custom_template/debug=""
|
custom_template/debug=""
|
||||||
custom_template/release=""
|
custom_template/release=""
|
||||||
debug/export_console_wrapper=1
|
debug/export_console_wrapper=1
|
||||||
binary_format/embed_pck=true
|
binary_format/embed_pck=false
|
||||||
texture_format/s3tc_bptc=true
|
texture_format/s3tc_bptc=true
|
||||||
texture_format/etc2_astc=false
|
texture_format/etc2_astc=false
|
||||||
shader_baker/enabled=false
|
shader_baker/enabled=false
|
||||||
|
|
|
||||||
Binary file not shown.
BIN
exports/lab-electrolyte.pck
Normal file
BIN
exports/lab-electrolyte.pck
Normal file
Binary file not shown.
BIN
exports/lab.zip
Normal file
BIN
exports/lab.zip
Normal file
Binary file not shown.
BIN
exports/test.zip
BIN
exports/test.zip
Binary file not shown.
|
|
@ -8,6 +8,7 @@ class_name Substance
|
||||||
@export var boiling_point: float
|
@export var boiling_point: float
|
||||||
@export var liquid_transparency: float = 0.5
|
@export var liquid_transparency: float = 0.5
|
||||||
@export var pH: float = 7.0
|
@export var pH: float = 7.0
|
||||||
|
@export var pHIonicOverrides: Dictionary[Substance,float]
|
||||||
@export var color: Color
|
@export var color: Color
|
||||||
@export var pHColor: Gradient
|
@export var pHColor: Gradient
|
||||||
@export var prefer_scientific_name: bool
|
@export var prefer_scientific_name: bool
|
||||||
|
|
@ -15,3 +16,31 @@ class_name Substance
|
||||||
|
|
||||||
func get_formula() -> StringName:
|
func get_formula() -> StringName:
|
||||||
return scientific_name if prefer_scientific_name else formula
|
return scientific_name if prefer_scientific_name else formula
|
||||||
|
|
||||||
|
func get_ph(context: Array[Substance]):
|
||||||
|
var overriden_value: float = 0
|
||||||
|
var overrides: int = 0
|
||||||
|
|
||||||
|
for sub in context:
|
||||||
|
if pHIonicOverrides.has(sub):
|
||||||
|
overriden_value += pHIonicOverrides[sub]
|
||||||
|
overrides += 1
|
||||||
|
|
||||||
|
if overrides > 0:
|
||||||
|
return overriden_value / overrides
|
||||||
|
else:
|
||||||
|
return pH
|
||||||
|
|
||||||
|
func get_ph_runtime(context: Array[RuntimeSubstanceData]):
|
||||||
|
var overriden_value: float = 0
|
||||||
|
var overrides: int = 0
|
||||||
|
|
||||||
|
for sub in context:
|
||||||
|
if pHIonicOverrides.has(sub.substance):
|
||||||
|
overriden_value += pHIonicOverrides[sub.substance]
|
||||||
|
overrides += 1
|
||||||
|
|
||||||
|
if overrides > 0:
|
||||||
|
return overriden_value / overrides
|
||||||
|
else:
|
||||||
|
return pH
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ func update_material(substances: Array[RuntimeSubstanceData]) -> void:
|
||||||
|
|
||||||
for sub: RuntimeSubstanceData in substances:
|
for sub: RuntimeSubstanceData in substances:
|
||||||
var weight: float = sub.amount/total_weight
|
var weight: float = sub.amount/total_weight
|
||||||
pH += sub.substance.pH * weight
|
pH += sub.substance.get_ph_runtime(substances) * weight
|
||||||
|
|
||||||
for sub: RuntimeSubstanceData in substances:
|
for sub: RuntimeSubstanceData in substances:
|
||||||
var weight: float = sub.amount/total_weight
|
var weight: float = sub.amount/total_weight
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue