-
Notifications
You must be signed in to change notification settings - Fork 45
/
Copy pathChunk.cs
83 lines (74 loc) · 3.07 KB
/
Chunk.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
// Decompiled with JetBrains decompiler
// Type: StardewValley.Chunk
// Assembly: Stardew Valley, Version=1.5.6.22018, Culture=neutral, PublicKeyToken=null
// MVID: BEBB6D18-4941-4529-AC12-B54F0C61CC20
// Assembly location: C:\Program Files (x86)\Steam\steamapps\common\Stardew Valley\Stardew Valley.dll
using Microsoft.Xna.Framework;
using Netcode;
using StardewValley.Network;
using System;
using System.Xml.Serialization;
namespace StardewValley
{
public class Chunk : INetObject<NetFields>
{
[XmlElement("position")]
public NetPosition position = new NetPosition();
[XmlIgnore]
public readonly NetFloat xVelocity = new NetFloat().Interpolated(true, true);
[XmlIgnore]
public readonly NetFloat yVelocity = new NetFloat().Interpolated(true, true);
[XmlIgnore]
public readonly NetBool hasPassedRestingLineOnce = new NetBool(false);
[XmlIgnore]
public int bounces;
private readonly NetInt netDebrisType = new NetInt();
[XmlIgnore]
public bool hitWall;
[XmlElement("xSpriteSheet")]
public readonly NetInt xSpriteSheet = new NetInt();
[XmlElement("ySpriteSheet")]
public readonly NetInt ySpriteSheet = new NetInt();
[XmlIgnore]
public float rotation;
[XmlIgnore]
public float rotationVelocity;
private readonly NetFloat netScale = new NetFloat().Interpolated(true, true);
private readonly NetFloat netAlpha = new NetFloat();
public int debrisType
{
get => (int) (NetFieldBase<int, NetInt>) this.netDebrisType;
set => this.netDebrisType.Value = value;
}
public float scale
{
get => (float) (NetFieldBase<float, NetFloat>) this.netScale;
set => this.netScale.Value = value;
}
public float alpha
{
get => (float) (NetFieldBase<float, NetFloat>) this.netAlpha;
set => this.netAlpha.Value = value;
}
[XmlIgnore]
public NetFields NetFields { get; } = new NetFields();
public Chunk()
{
this.NetFields.AddFields((INetSerializable) this.position.NetFields, (INetSerializable) this.xVelocity, (INetSerializable) this.yVelocity, (INetSerializable) this.netDebrisType, (INetSerializable) this.xSpriteSheet, (INetSerializable) this.ySpriteSheet, (INetSerializable) this.netScale, (INetSerializable) this.netAlpha, (INetSerializable) this.hasPassedRestingLineOnce);
if (LocalMultiplayer.IsLocalMultiplayer(true))
this.NetFields.DeltaAggregateTicks = (ushort) 10;
else
this.NetFields.DeltaAggregateTicks = (ushort) 30;
}
public Chunk(Vector2 position, float xVelocity, float yVelocity, int debrisType)
: this()
{
this.position.Value = position;
this.xVelocity.Value = xVelocity;
this.yVelocity.Value = yVelocity;
this.debrisType = debrisType;
this.alpha = 1f;
}
public float getSpeed() => (float) Math.Sqrt((double) (float) (NetFieldBase<float, NetFloat>) this.xVelocity * (double) (float) (NetFieldBase<float, NetFloat>) this.xVelocity + (double) (float) (NetFieldBase<float, NetFloat>) this.yVelocity * (double) (float) (NetFieldBase<float, NetFloat>) this.yVelocity);
}
}