-
Notifications
You must be signed in to change notification settings - Fork 4
/
GulperLeviathanPrefab.cs
133 lines (119 loc) · 5.57 KB
/
GulperLeviathanPrefab.cs
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
using System.Collections;
using System.Collections.Generic;
using DeExtinction.Mono;
using ECCLibrary;
using ECCLibrary.Data;
using ECCLibrary.Mono;
using Nautilus.Assets;
using Nautilus.Utility;
using UnityEngine;
namespace DeExtinction.Prefabs.Creatures;
internal class GulperLeviathanPrefab : CreatureAsset
{
private readonly GameObject _prefabModel;
public GulperLeviathanPrefab(PrefabInfo prefabInfo, GameObject prefabModel) : base(prefabInfo)
{
CreatureDataUtils.AddCreaturePDAEncyclopediaEntry(this, CommonDatabankPaths.Leviathans, null, null, 8,
Plugin.AssetBundle.LoadAsset<Texture2D>("Gulper_Ency"),
Plugin.AssetBundle.LoadAsset<Sprite>("Gulper_Popup"));
_prefabModel = prefabModel;
}
protected override CreatureTemplate CreateTemplate()
{
var template = new CreatureTemplate(_prefabModel,
BehaviourType.Leviathan, EcoTargetType.Leviathan, 5000)
{
SwimRandomData = new SwimRandomData(0.1f, 12f, new Vector3(40, 6, 40), 4f, 1f, true),
AvoidTerrainData = new AvoidTerrainData(0.9f, 14f, 30f, 35f, 0.5f, 10),
StayAtLeashData = new StayAtLeashData(0.4f, 12, 60),
LocomotionData = new LocomotionData(12f, 0.4f, 3, 0.6f),
Mass = 2000,
CellLevel = LargeWorldEntity.CellLevel.Far,
AnimateByVelocityData = new AnimateByVelocityData(24),
AttackLastTargetData = new AttackLastTargetData(0.8f, 20f, 0.6f, 10f, 10f),
AggressiveToPilotingVehicleData = new AggressiveToPilotingVehicleData(30f, 0.2f),
EyeFOV = -0.5f,
BehaviourLODData = new BehaviourLODData(60, 200, 300),
ScannerRoomScannable = true,
RespawnData = new RespawnData(false),
AggressiveWhenSeeTargetList = new List<AggressiveWhenSeeTargetData>()
{
new(EcoTargetType.Shark, 1.5f, 80f, 3),
new(EcoTargetType.SubDecoy, 2f, 35f, 2),
new(EcoTargetType.MediumFish, 1.5f, 15f, 2)
},
CanBeInfected = false
};
return template;
}
protected override void ApplyMaterials(GameObject prefab)
{
#if SUBNAUTICA
MaterialUtils.ApplySNShaders(prefab, 8, 3, 3);
#elif BELOWZERO
MaterialUtils.ApplySNShaders(prefab, 7.5f, 2, 3);
#endif
}
protected override IEnumerator ModifyPrefab(GameObject prefab, CreatureComponents components)
{
var spine2 = prefab.SearchChild("Spine2").transform;
var trailManagerBuilder = new TrailManagerBuilder(components, spine2, 3)
{
Trails = new Transform[]
{
spine2.SearchChild("Spine3").transform, spine2.SearchChild("Spine4").transform,
spine2.SearchChild("Spine5").transform, spine2.SearchChild("Spine6").transform,
spine2.SearchChild("Spine7").transform, spine2.SearchChild("Spine8").transform,
spine2.SearchChild("Spine9").transform
}
};
var trailManager = trailManagerBuilder.Apply();
trailManager.rootSegment = prefab.transform.Find("FakeTrailManagerRoot");
var mouth = prefab.SearchChild("Mouth");
var lClawTrigger = prefab.SearchChild("LClaw");
var rClawTrigger = prefab.SearchChild("RClaw");
var voice = prefab.AddComponent<CreatureVoice>();
var emitter = prefab.AddComponent<FMOD_CustomEmitter>();
emitter.followParent = true;
voice.emitter = emitter;
voice.minInterval = 15;
voice.maxInterval = 22;
voice.closeIdleSound = AudioUtils.GetFmodAsset("GulperRoar");
voice.farIdleSound = AudioUtils.GetFmodAsset("GulperRoarFar");
voice.farThreshold = 70;
voice.playSoundOnStart = true;
voice.animator = components.Animator;
voice.animatorTriggerParam = "roar";
var gulperBehaviour = prefab.AddComponent<GulperBehaviour>();
gulperBehaviour.creature = components.Creature;
var meleeAttack = CreaturePrefabUtils.AddMeleeAttack<GulperMeleeAttackMouth>(prefab, components, mouth, true, 100);
meleeAttack.canBeFed = false;
meleeAttack.eatHungerDecrement = 0.05f;
meleeAttack.eatHappyIncrement = 0.1f;
meleeAttack.biteAggressionDecrement = 0.02f;
meleeAttack.biteAggressionThreshold = 0.1f;
meleeAttack.lastTarget = components.LastTarget;
meleeAttack.creature = components.Creature;
meleeAttack.liveMixin = components.LiveMixin;
meleeAttack.animator = components.Creature.GetAnimator();
AddClawAttack(prefab, "LClaw", "swipeL", components);
AddClawAttack(prefab, "RClaw", "swipeR", components);
yield break;
}
private void AddClawAttack(GameObject prefab, string triggerName, string animationName, CreatureComponents components)
{
var clawObject = prefab.SearchChild(triggerName);
var clawAttack = CreaturePrefabUtils.AddMeleeAttack<GulperMeleeAttackClaw>(prefab, components, clawObject, true, 40);
clawAttack.canBeFed = false;
clawAttack.eatHungerDecrement = 0.05f;
clawAttack.eatHappyIncrement = 0.1f;
clawAttack.biteAggressionDecrement = 0.02f;
clawAttack.biteAggressionThreshold = 0.1f;
clawAttack.lastTarget = components.LastTarget;
clawAttack.creature = components.Creature;
clawAttack.liveMixin = components.LiveMixin;
clawAttack.animator = components.Creature.GetAnimator();
clawAttack.animationTriggerName = animationName;
clawAttack.clawObject = clawObject;
}
}