This repository has been archived by the owner on Nov 1, 2024. It is now read-only.
forked from new-frontiers-14/frontier-station-14
-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathsingulo_emitter.m
65 lines (59 loc) · 1.85 KB
/
singulo_emitter.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# This is a script to be loaded into GNU Octave.
# - Notes -
# + Be sure to check all parameters are up to date with game before use.
# + This plots *worst-case* performance, the assumption is that it shouldn't ever randomly fail.
# + The assumption is that there is one emitter per shield point.
# + Keep in mind that to prevent the generator being destroyed, either shield must be above a limit.
# This limit is (level*2)+1.
# The timestep used for simulation is one second.
global emitter_state emitter_timer shield_energy
emitter_state = 0
emitter_timer = 0
shield_energy = 0
function shield_clamp ()
global shield_energy
# ContainmentFieldConnection.SharedEnergyPool
shield_energy = min(max(shield_energy, 0), 25)
endfunction
function shield_tick ()
global shield_energy
shield_energy -= 1
shield_clamp()
endfunction
function shield_hit ()
global shield_energy
emitter_count = 2 # one per connection side
receive_power = 6 # ContainmentFieldGeneratorComponent.IStartCollide.CollideWith
power_per_connection = receive_power / 2 # ContainmentFieldGeneratorComponent.ReceivePower
shield_energy += power_per_connection * emitter_count
shield_clamp()
endfunction
function retval = scenario (x)
global emitter_state emitter_timer shield_energy
# Tick (degrade) shield
shield_tick()
# Timer...
if emitter_timer > 0
emitter_timer -= 1
else
# Note the logic here is written to match how EmitterComponent does it.
# Fire first...
shield_hit()
# Then check if < fireBurstSize
if emitter_state < 3
# Then increment & reset
emitter_state += 1
# to fireInterval
emitter_timer = 2
else
# Reset state
emitter_state = 0
# Worst case, fireBurstDelayMax
emitter_timer = 10
endif
endif
retval = shield_energy
endfunction
# x is in seconds.
x = 0:1:960
plot(x, arrayfun(@scenario, x))