public StageData(Vector3 playerPos, Quaternion playerRot) { m_playerPos = Serializer.Serializevector3(playerPos); m_playerRot = Serializer.SerializeQuaternion(playerRot); m_disallowPlayer = false; NewEntry = true; }
/// <summary> /// Translate to a serializable form the given position and rotation /// to register the last player location of this stage /// </summary> public void OverridePlayerLocation(Vector3 pos, Quaternion rot) { m_playerPos = Serializer.Serializevector3(pos); m_playerRot = Serializer.SerializeQuaternion(rot); NewEntry = false; OverridedLocation = true; }
public static SerializedQuaternion SerializeQuaternion(Quaternion source) { SerializedQuaternion sq = new SerializedQuaternion(); sq.x = source.x; sq.y = source.y; sq.z = source.z; sq.w = source.w; return sq; }
public static SerializedQuaternion SerializeQuaternion(Quaternion source) { SerializedQuaternion sq = new SerializedQuaternion(); sq.x = source.x; sq.y = source.y; sq.z = source.z; sq.w = source.w; return(sq); }
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()); } }
public void RegisterLocation(Transform transform, bool registerScale) { m_position = Serializer.Serializevector3(transform.position); m_rotation = Serializer.SerializeQuaternion(transform.rotation); if (registerScale) { m_scale = Serializer.Serializevector3(transform.localScale); m_scaleRegistered = true; } }
public void RegisterPlayerLocation(Vector3 pos, Quaternion rot) { if (OverridedLocation) { OverridedLocation = false; } else { m_playerPos = Serializer.Serializevector3(pos); m_playerRot = Serializer.SerializeQuaternion(rot); } NewEntry = false; }
public void AddQuaternion(string key, Quaternion quat) { SerializedQuaternion _sqtn = Serializer.SerializeQuaternion(quat); if (m_quaternions == null) { m_quaternions = new Dictionary <string, SerializedQuaternion>(); m_quaternions.Add(key, _sqtn); } else { if (m_quaternions.ContainsKey(key)) { m_quaternions[key] = _sqtn; } else { m_quaternions.Add(key, _sqtn); } } }
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(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 void AddComponent(Spawnable spawnable) { if (Origo == null) { Origo = new Origo(new SerializedVector3(spawnable.transform.position), new SerializedQuaternion(spawnable.transform.rotation)); } 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 (component == null) { Pluton.Logger.LogDebug("[StructureRecorder] Deployable component is null!"); return; } if (!SpawnableComponents.ContainsKey(component.ToString())) { SpawnableComponents.Add(component.ToString(), component); } else { SpawnableComponents[component.ToString()] = component; } }
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) { SerializedQuaternion sq = new SerializedQuaternion(((Quaternion)value).x, ((Quaternion)value).y, ((Quaternion)value).z, ((Quaternion)value).w); JToken.FromObject(JsonConvert.SerializeObject(sq)).WriteTo(writer); }
public DeployableComponent(Deployable deployable, SerializedVector3 v3, SerializedQuaternion q) { Prefab = deployable.GetComponent <BaseNetworkable>().LookupPrefabName(); LocalPosition = v3; LocalRotation = q; if (deployable.GetComponent <SleepingBag>()) { SleepingBag sleepingBag = deployable.GetComponent <SleepingBag>(); DeployedBy = sleepingBag.deployerUserID; BagName = sleepingBag.niceName; HasOwner = true; HasStorage = false; HasPainting = false; IsCupBoard = false; } else if (deployable.GetComponent <BuildingPrivlidge>()) { IsCupBoard = true; BuildingPrivlidge buildingPrivlidge = deployable.GetComponent <BuildingPrivlidge>(); AuthedPlayers = new List <ProtoBuf.PlayerNameID>(); AuthedPlayers = buildingPrivlidge.authorizedPlayers; } else if (deployable.GetComponent <StorageContainer>()) { HasOwner = false; HasStorage = true; HasPainting = false; IsCupBoard = false; StorageContainer storageContainer = deployable.GetComponent <StorageContainer>(); ItemList = new List <Dictionary <string, object> >(); foreach (Item item in storageContainer.inventory.itemList) { var itemData = new Dictionary <string, object>(); itemData.Add("blueprint", item.IsBlueprint()); itemData.Add("id", item.info.itemid); itemData.Add("amount", item.amount); ItemList.Add(itemData); } if (storageContainer.HasSlot(BaseEntity.Slot.Lock)) { var baseLock = storageContainer.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(); } } } else if (deployable.GetComponent <Signage>()) { HasOwner = false; HasStorage = false; HasPainting = true; IsCupBoard = false; Signage signage = deployable.GetComponent <Signage>(); byte[] tempImg = FileStorage.server.Get(signage.textureID, FileStorage.Type.png, signage.net.ID); if (signage.textureID > 0 && tempImg != null) { Painting = tempImg; } PaintingLocked = signage.IsLocked(); } else { HasOwner = false; HasStorage = false; HasPainting = false; IsCupBoard = false; } }
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { SerializedQuaternion sq = JsonConvert.DeserializeObject <SerializedQuaternion>(JToken.Load(reader).ToString()); return(new Quaternion(sq.x, sq.y, sq.z, sq.w)); }
public static Quaternion DeserializeQuaternion(SerializedQuaternion source) { return(new Quaternion(source.x, source.y, source.z, source.w)); }
public SpawnableComponent(Spawnable spawnable, SerializedVector3 v3, SerializedQuaternion q) { Prefab = spawnable.GetComponent <BaseNetworkable>().LookupPrefabName(); LocalPosition = v3; LocalRotation = q; }
public StructureComponent(string str, SerializedVector3 v3, SerializedQuaternion q, int i) { throw new NotImplementedException(); }
public static Quaternion DeserializeQuaternion(SerializedQuaternion source) { return new Quaternion(source.x, source.y, source.z, source.w); }
public Origo(SerializedVector3 v3, SerializedQuaternion q) { Position = v3; Rotation = q; }