14 [Obsolete(
"Use IsInFluid instead.")]
125 Value = valuesDictionary.GetValue<
int>(
"Value");
128 CreationTime = valuesDictionary.GetValue<
double>(
"CreationTime");
130 int ownerEntityID = valuesDictionary.GetValue(
"OwnerID", 0);
131 if (ownerEntityID != 0
138 valuesDictionary.SetValue(
"Class", GetType().FullName);
139 valuesDictionary.SetValue(
"Value",
Value);
140 valuesDictionary.SetValue(
"Position",
Position);
141 valuesDictionary.SetValue(
"Velocity",
Velocity);
142 valuesDictionary.SetValue(
"CreationTime",
CreationTime);
146 valuesDictionary.SetValue(
"OwnerID",
OwnerEntity.Id);
151 loader.SaveProjectile(subsystemProjectiles,
this, ref valuesDictionary);
163 Func<DrawBlockEnvironmentData> drawBlockEnvironmentData,
164 Func<float> calcVisibilityRange,
165 Func<SubsystemSky.CalculateFogDelegate> calculateFog,
166 Func<PrimitivesRenderer3D> primitivesRenderer) {
214 terrainRaycastResult =
null;
221 (body, distance) => {
224 "OnProjectileRaycastBody",
226 loader.OnProjectileRaycastBody(body,
this, distance, out
bool ignoreByThisMod);
227 ignore |= ignoreByThisMod;
239 bodyRaycastResult =
null;
248 if (chunkAtCell ==
null
252 TrailParticleSystem.IsStopped =
true;
279 "OnProjectileFlyOutOfLoadedChunks",
281 loader.OnProjectileFlyOutOfLoadedChunks(
this);
294 for (
int i = 0; i < blockBehaviors.Length; i++) {
304 bool ignoreBody =
false;
314 "OnProjectileHitBody",
316 loader.OnProjectileHitBody(
320 ref velocityAfterAttack,
321 ref angularVelocityAfterAttack,
330 if (attackPower > 0f) {
333 Owner.PlayerStats.RangedHits++;
349 ref
Vector3? pickableStuckMatrix) {
351 int cellValue =
CurrnetTerrain().GetCellValue(cellFace.
X, cellFace.
Y, cellFace.
Z);
353 float velocityLength =
Velocity.Length();
366 float num3 = velocityAfterHit.
Length();
368 bool triggerBlocksBehavior =
true;
370 float impactSoundLoudness = velocityLength > 5f ? 1f : 0f;
372 && velocityLength > 10f
375 "OnProjectileHitTerrain",
377 loader.OnProjectileHitTerrain(
379 terrainRaycastResult,
380 ref triggerBlocksBehavior,
382 ref impactSoundLoudness,
383 ref projectileGetStuck,
384 ref velocityAfterHit,
385 ref angularVelocityAfterHit
394 for (
int j = 0; j < blockBehaviors2.Length; j++) {
417 for (
int k = 0; k < 8; k++) {
420 if (terrainRaycastResult2.HasValue) {
422 terrainRaycastResult2.
Value.CellFace.X,
423 terrainRaycastResult2.
Value.CellFace.Y,
424 terrainRaycastResult2.
Value.CellFace.Z,
430 if (impactSoundLoudness > 0
434 if (projectileGetStuck) {
453 if (damagedBlockValue != 0
456 if (pickableStuckMatrix.HasValue) {
464 "OnProjectileTurnIntoPickable",
466 loader.OnProjectileTurnIntoPickable(
this, ref pickable);
470 if (pickable !=
null) {
484 Vector3? pickableStuckMatrix =
null;
486 CellFace? nullableCellFace = terrainRaycastResult.HasValue ?
new CellFace?(terrainRaycastResult.Value.CellFace) :
null;
491 if (terrainRaycastResult.HasValue
492 || bodyRaycastResult.HasValue) {
497 if (bodyRaycastResult.HasValue
498 && (!terrainRaycastResult.HasValue || bodyRaycastResult.Value.Distance < terrainRaycastResult.Value.Distance)) {
499 HitBody(bodyRaycastResult.Value, ref positionAtdt);
502 else if (terrainRaycastResult.HasValue) {
503 CellFace cellFace = nullableCellFace.Value;
504 HitTerrain(terrainRaycastResult.Value, cellFace, ref positionAtdt, ref pickableStuckMatrix);
507 if (terrainRaycastResult.HasValue
508 || bodyRaycastResult.HasValue) {
513 && (pickableStuckMatrix.HasValue ||
Velocity.Length() < 1f)) {
538 bool isProjectileInFluid = blockTheProjectileIn is
FluidBlock;
545 if (horizontalSpeed > 6f
546 && horizontalSpeed > 4f * MathF.Abs(
Velocity.Y)) {
549 isProjectileInFluid =
false;
560 if (surfaceHeight.HasValue
622 TrailParticleSystem.Position =
Position + v4;
624 TrailParticleSystem.IsStopped =
true;
654 if (chunkAtCell !=
null
677 bool shouldDrawBlock =
true;
678 float drawBlockSize = 0.3f;
684 loader.OnProjectileDraw(
697 if (shouldDrawBlock) {
bool Intersection(Vector3 point)
static float Saturate(float x)
static float Lerp(float x1, float x2, float f)
The spell "Attackment" is wrong, But it is not recommended to change it because many mods rely on thi...
virtual BlockDebrisParticleSystem CreateDebrisParticleSystem(SubsystemTerrain subsystemTerrain, Vector3 position, int value, float strength)
virtual float GetProjectileStickProbability(int value)
virtual bool GetAlignToVelocity(int value)
virtual float GetProjectilePower(int value)
void DrawBlock(PrimitivesRenderer3D primitivesRenderer, int value, Color color, float size, ref Matrix matrix, DrawBlockEnvironmentData environmentData)
绘制方块_用于绘制方块物品形态
virtual bool IsStickable_(int value)
virtual bool IsCollidable_(int value)
virtual float GetProjectileResilience(int value)
virtual float GetProjectileDamping(int value)
static int DamageItem(int value, int damageCount, Entity owner=null)
BoundingFrustum ViewFrustum
static void AttackBody(Attackment attackment)
SubsystemTerrain SubsystemTerrain
virtual void InitializeData(Func< Terrain > terrain, Func< DrawBlockEnvironmentData > drawBlockEnvironmentData, Func< float > calcVisibilityRange, Func< SubsystemSky.CalculateFogDelegate > calculateFog, Func< PrimitivesRenderer3D > primitivesRenderer)
Func< DrawBlockEnvironmentData > DrawBlockEnvironmentData
virtual void Draw(Camera camera, int drawOrder)
SubsystemProjectiles SubsystemProjectiles
int DamageToPickable
弹射物结算时掉的耐久
virtual float MinVelocityToAttack
SubsystemProjectiles m_subsystemProjectiles
Func< SubsystemSky.CalculateFogDelegate > CalculateFog
Func< float > CalcVisibilityRange
virtual void UpdateMovement(float dt, ref Vector3 positionAtdt)
ProjectileStoppedAction ProjectileStoppedAction
virtual void Save(SubsystemProjectiles subsystemProjectiles, ValuesDictionary valuesDictionary)
delegate float CalcVisibilityRangeDelegate()
SubsystemParticles SubsystemParticles
int? TurnIntoPickableBlockValue
virtual void OnProjectileFlyOutOfLoadedChunks()
bool StopTrailParticleInFluid
override void Load(ValuesDictionary valuesDictionary)
在进入加载存档时执行
virtual float AttackPower
virtual void Update(float dt)
override void UnderExplosion(Vector3 impulse, float damage)
virtual void Raycast(float dt, out BodyRaycastResult? bodyRaycastResult, out TerrainRaycastResult? terrainRaycastResult)
ITrailParticleSystem TrailParticleSystem
Func< PrimitivesRenderer3D > PrimitivesRenderer
virtual void UpdateTimeToRemove()
SubsystemAudio SubsystemAudio
virtual void HitBody(BodyRaycastResult bodyRaycastResult, ref Vector3 positionAtdt)
SubsystemPickables SubsystemPickables
virtual void HitTerrain(TerrainRaycastResult terrainRaycastResult, CellFace cellFace, ref Vector3 positionAtdt, ref Vector3? pickableStuckMatrix)
virtual bool ProcessOnHitAsProjectileBlockBehavior(CellFace? cellFace, ComponentBody componentBody, float dt)
virtual void Initialize(int value, Vector3 position, Vector3 velocity, Vector3 angularVelocity, Entity owner)
virtual void UpdateInChunk(float dt)
Func< Terrain > CurrnetTerrain
virtual void UpdateTrailParticleSystem(float dt)
virtual void TurnIntoPickable(Vector3? pickableStuckMatrix)
List< ComponentBody > BodiesToIgnore
弹射物飞行的时候会忽略List中的ComponentBody
virtual void Initialize(int value, Vector3 position, Vector3 velocity, Vector3 angularVelocity, ComponentCreature owner)
SubsystemTerrain m_subsystemTerrain
virtual bool OnHitAsProjectile(CellFace? cellFace, ComponentBody componentBody, WorldItem worldItem)
virtual void OnHitByProjectile(CellFace cellFace, WorldItem worldItem)
delegate float CalculateFogDelegate(Vector3 viewPosition, Vector3 position)
static Func< int, int > GetTemperatureAdjustmentAtHeight
static int ExtractContents(int value)
static int ToCell(float x)
Component FindComponent(Type type, string name, bool throwOnError)
static void HookAction(string HookName, Func< ModLoader, bool > action)
执行Hook
static Color MultiplyNotSaturated(Color c, float s)
static Matrix CreateTranslation(float x, float y, float z)
static Matrix CreateFromAxisAngle(Vector3 axis, float angle)
static float DistanceSquared(Vector3 v1, Vector3 v2)
static Vector3 TransformNormal(Vector3 v, Matrix m)
static Vector3 Normalize(Vector3 v)
static readonly Vector3 Zero
ComponentBody ComponentBody