void OnSerializing(StreamingContext context) { if (position != null) { return; } position = buildingBlock.transform.position.Serialize(); }
public override bool Equals(object other) { if (!(other is SerializedVector3)) { return(false); } SerializedVector3 v3 = (SerializedVector3)other; return(x.Equals(v3.x) && y.Equals(v3.y) && z.Equals(v3.z)); }
public StructureComponent(BuildingPart bp, SerializedVector3 v3, SerializedQuaternion q) { Grade = bp.buildingBlock.grade; Prefab = bp.buildingBlock.LookupPrefabName(); LocalPosition = v3; LocalRotation = q; Health = (float)((int)Math.Floor((double)(bp.Health / 85)) * 85); if (bp.buildingBlock.HasSlot(BaseEntity.Slot.Lock)) { var baseLock = bp.buildingBlock.GetSlot(BaseEntity.Slot.Lock) as BaseLock; if (baseLock == null) { HasCodeLock = false; HasKeyLock = false; } else if (baseLock.GetComponent<CodeLock>()) { HasCodeLock = true; HasKeyLock = false; CodeLock codeLock = baseLock.GetComponent<CodeLock>(); if (!string.IsNullOrEmpty((string)codeLock.GetFieldValue("code"))) { LockCode = (string)codeLock.GetFieldValue("code"); LockWList = new List<ulong>(); LockWList = (List<ulong>)codeLock.GetFieldValue("whitelistPlayers"); } } else if (baseLock.GetComponent<KeyLock>()) { HasCodeLock = false; HasKeyLock = true; KeyLock keyLock = baseLock.GetComponent<KeyLock>(); int keyCode = (int)keyLock.GetFieldValue("keyCode"); keyCode = (bool)keyLock.GetFieldValue("firstKeyCreated") ? keyCode |= 0x80 : (int)keyLock.GetFieldValue("keyCode"); LockCode = keyCode.ToString(); } } }
public void AddComponent(Deployable deployable) { if (Origo == null) { Origo = new Origo(new SerializedVector3(deployable.transform.position), new SerializedQuaternion(deployable.transform.rotation)); } var v3 = new SerializedVector3(deployable.transform.position - Origo.Position.ToVector3()); var q = new SerializedQuaternion(deployable.transform.rotation); var component = new DeployableComponent(deployable, v3, q); if (component == null) { Pluton.Logger.LogDebug("[StructureRecorder] Deployable component is null!"); return; } if (!DeployableComponents.ContainsKey(component.ToString())) { DeployableComponents.Add(component.ToString(), component); } else { DeployableComponents[component.ToString()] = component; } }
public void AddComponent(BuildingPart bp) { if (Origo == null) { Origo = new Origo(new SerializedVector3(bp.Location), new SerializedQuaternion(bp.buildingBlock.transform.rotation)); } var v3 = new SerializedVector3(bp.Location - Origo.Position.ToVector3()); var q = new SerializedQuaternion(bp.buildingBlock.transform.rotation); var component = new StructureComponent(bp, v3, q); if (component == null) { Pluton.Logger.LogDebug("[StructureRecorder] BuildingPart component is null!"); return; } if (!StructureComponents.ContainsKey(component.ToString())) { StructureComponents.Add(component.ToString(), component); } else { StructureComponents[component.ToString()] = component; } }
public bool Equals(SerializedVector3 v3) { return(v3.ToVector3().Equals(ToVector3())); }
public StructureComponent(string str, SerializedVector3 v3, SerializedQuaternion q, int i) { throw new NotImplementedException(); }
void OnSerializing(StreamingContext context) { position = buildingBlock.transform.position.Serialize(); }
public void RemoveComponent(Spawnable spawnable) { var v3 = new SerializedVector3(spawnable.transform.position - Origo.Position.ToVector3()); var q = new SerializedQuaternion(spawnable.transform.rotation); var component = new SpawnableComponent(spawnable, v3, q); if (SpawnableComponents.ContainsKey(component.ToString())) { SpawnableComponents.Remove(component.ToString()); } }
public void RemoveComponent(BuildingPart bp) { var v3 = new SerializedVector3(bp.Location - Origo.Position.ToVector3()); var q = new SerializedQuaternion(bp.buildingBlock.transform.rotation); var component = new StructureComponent(bp, v3, q); if (StructureComponents.ContainsKey(component.ToString())) { StructureComponents.Remove(component.ToString()); } }
void OnSerializing(StreamingContext context) { if (position != null) return; position = buildingBlock.transform.position.Serialize(); }
public SpawnableComponent(Spawnable spawnable, SerializedVector3 v3, SerializedQuaternion q) { Prefab = spawnable.GetComponent<BaseNetworkable>().LookupPrefabName(); LocalPosition = v3; LocalRotation = q; }
public Origo(SerializedVector3 v3, SerializedQuaternion q) { Position = v3; Rotation = q; }
public bool Equals(SerializedVector3 v3) { return v3.ToVector3().Equals(ToVector3()); }