-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathCShipPerformanceDesc.cpp
77 lines (47 loc) · 1.85 KB
/
CShipPerformanceDesc.cpp
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
66
67
68
69
70
71
72
73
74
75
76
77
// CShipPerformanceDesc.cpp
//
// CShipPerformanceDesc class
// Copyright (c) 2016 by Kronosaur Productions, LLC. All Rights Reserved.
#include "PreComp.h"
CShipPerformanceDesc CShipPerformanceDesc::m_Null;
void CShipPerformanceDesc::Init (SShipPerformanceCtx &Ctx)
// Init
//
// Initialize the performance descriptor from the parameters accumulated in
// the context block.
{
// Adjust speed if our armor is too heavy or too light
Ctx.rArmorSpeedBonus = Ctx.pClass->GetHullDesc().GetArmorLimits().CalcArmorSpeedBonus(Ctx.Armor) * LIGHT_SPEED * 0.01;
// If this is positive (a bonus) then increase the speed limit.
if (Ctx.rArmorSpeedBonus > 0.0)
Ctx.rMaxSpeedLimit = Min(Ctx.rMaxSpeedLimit + Ctx.rArmorSpeedBonus, LIGHT_SPEED);
// Equipment installed
m_Abilities = Ctx.Abilities;
// Initialize our maneuvering performance
m_RotationDesc = Ctx.RotationDesc;
m_IntegralRotationDesc.InitFromDesc(Ctx.RotationDesc);
// Initialize reactor desc
m_ReactorDesc = Ctx.ReactorDesc;
// Compute our drive parameters. We start with the core stats
m_DriveDesc = Ctx.DriveDesc;
// Adjust max speed.
if (Ctx.rArmorSpeedBonus != 0.0)
m_DriveDesc.AddMaxSpeed(Ctx.rArmorSpeedBonus);
// Apply the speed limit
m_DriveDesc.SetMaxSpeed(Min(m_DriveDesc.GetMaxSpeed(), Ctx.rMaxSpeedLimit));
// If drive damaged, cut thrust in half
if (Ctx.bDriveDamaged)
m_DriveDesc.AdjThrust(0.5);
// If we're running at half speed...
if (Ctx.bDriveDamaged)
m_DriveDesc.AdjMaxSpeed(Min(Ctx.rOperatingSpeedAdj, 0.5));
else if (Ctx.rOperatingSpeedAdj != 1.0)
m_DriveDesc.AdjMaxSpeed(Ctx.rOperatingSpeedAdj);
// Cargo space
Ctx.CargoDesc.ValidateCargoSpace(Ctx.iMaxCargoSpace);
m_CargoDesc = Ctx.CargoDesc;
// Other flags
m_fShieldInterference = Ctx.bShieldInterference;
// Done
m_fInitialized = true;
}