private void BB(ItemActionData itemActionData) { ItemActionSpawnCustomVehicle.ItemActionDataSpawnCustomVehicle itemActionDataSpawnMinibike = (ItemActionSpawnCustomVehicle.ItemActionDataSpawnCustomVehicle)itemActionData; if (itemActionDataSpawnMinibike.PreviewRenderers == null || itemActionDataSpawnMinibike.PreviewRenderers.Length == 0 || itemActionDataSpawnMinibike.PreviewRenderers[0] == null) { itemActionDataSpawnMinibike.PreviewRenderers = itemActionDataSpawnMinibike.MinibikePreview.GetComponentsInChildren <Renderer>(); } World world = itemActionData.invData.world; bool flag = this.UB(itemActionData, ref itemActionDataSpawnMinibike.Position) && world.CanPlaceBlockAt(itemActionDataSpawnMinibike.invData.hitInfo.hit.blockPos, world.GetGameManager().GetPersistentLocalPlayer(), true); if (!flag && IsCustomBoat(itemActionData)) { flag = CheckWaterInRange(itemActionData, ref itemActionDataSpawnMinibike.Position); } if (itemActionDataSpawnMinibike.ValidPosition != flag) { itemActionDataSpawnMinibike.ValidPosition = flag; for (int i = 0; i < itemActionDataSpawnMinibike.PreviewRenderers.Length; i++) { itemActionDataSpawnMinibike.PreviewRenderers[i].material.color = ((!flag) ? new Color(2f, 0.25f, 0.25f) : new Color(0.25f, 2f, 0.25f)); } } Quaternion localRotation = itemActionDataSpawnMinibike.MinibikePreview.localRotation; localRotation.eulerAngles = new Vector3(-90f, itemActionData.invData.holdingEntity.rotation.y + 90f, 0f); itemActionDataSpawnMinibike.MinibikePreview.localRotation = localRotation; itemActionDataSpawnMinibike.MinibikePreview.position = itemActionDataSpawnMinibike.Position; }
private bool CheckWaterInRange(ItemActionData itemActionData, ref Vector3 ptr) { ItemActionSpawnCustomVehicle.ItemActionDataSpawnCustomVehicle itemActionDataSpawnMinibike = (ItemActionSpawnCustomVehicle.ItemActionDataSpawnCustomVehicle)itemActionData; Ray lookRay = itemActionDataSpawnMinibike.invData.holdingEntity.GetLookRay(); //if (Voxel.Raycast(GameManager.Instance.World, lookRay, 5f, 65536, 64, 0f)) if (Voxel.Raycast(GameManager.Instance.World, lookRay, 10f, false, true)) { ptr = Voxel.voxelRayHitInfo.hit.pos; Vector3 vector = new Vector3(ptr.x + 0.5f, ptr.y, ptr.z + 0.5f); BlockValue valor = GameManager.Instance.World.GetBlock(new Vector3i(vector)); Block block = Block.list[valor.type]; if (block.GetType().IsSubclassOf(typeof(BlockLiquid)) || block.GetType() == typeof(BlockLiquidv2)) { //DebugMsg("Hitting Liquid Block"); // needs to check if there's air on top of water valor = GameManager.Instance.World.GetBlock(new Vector3i(vector.x, vector.y + 1, vector.z)); block = Block.list[valor.type]; if (valor.type == 0) { //DebugMsg("Liquid Block has Air on top"); ptr = vector; return(true); } } } return(false); }
/** * When the item is no longer held in hand, destroy the preview object. */ public override void StopHolding(ItemActionData _actionData) { ItemActionSpawnEntity.ItemActionDataSpawnEntity itemActionDataSpawnEntity = (ItemActionSpawnEntity.ItemActionDataSpawnEntity)_actionData; if (itemActionDataSpawnEntity.EntityPreviewT != null && itemActionDataSpawnEntity.invData.holdingEntity is EntityPlayerLocal) { UnityEngine.Object.Destroy(itemActionDataSpawnEntity.EntityPreviewT.gameObject); } }
/** * When ticks update, update preview if the character has moved around. */ public override void OnHoldingUpdate(ItemActionData _actionData) { ItemActionSpawnEntity.ItemActionDataSpawnEntity itemActionDataSpawnEntity = (ItemActionSpawnEntity.ItemActionDataSpawnEntity)_actionData; if (itemActionDataSpawnEntity.EntityPreviewT != null && itemActionDataSpawnEntity.invData.holdingEntity is EntityPlayerLocal) { this.updatePreview(itemActionDataSpawnEntity); } }
public override void OnHoldingUpdate(ItemActionData _actionData) { ItemActionSpawnCustomVehicle.ItemActionDataSpawnCustomVehicle itemActionDataSpawnMinibike = (ItemActionSpawnCustomVehicle.ItemActionDataSpawnCustomVehicle)_actionData; if (itemActionDataSpawnMinibike.MinibikePreview != null && itemActionDataSpawnMinibike.invData.holdingEntity is EntityPlayerLocal) { this.BB(_actionData); } }
public override void CancelAction(ItemActionData _actionData) { ItemActionSpawnCustomVehicle.ItemActionDataSpawnCustomVehicle itemActionDataSpawnMinibike = (ItemActionSpawnCustomVehicle.ItemActionDataSpawnCustomVehicle)_actionData; if (itemActionDataSpawnMinibike.MinibikePreview != null && itemActionDataSpawnMinibike.invData.holdingEntity is EntityPlayerLocal) { UnityEngine.Object.Destroy(itemActionDataSpawnMinibike.MinibikePreview.gameObject); } }
public override void Cleanup(ItemActionData _data) { base.Cleanup(_data); ItemActionSpawnCustomVehicle.ItemActionDataSpawnCustomVehicle itemActionDataSpawnMinibike = _data as ItemActionSpawnCustomVehicle.ItemActionDataSpawnCustomVehicle; if (itemActionDataSpawnMinibike != null && itemActionDataSpawnMinibike.MinibikePreview != null && itemActionDataSpawnMinibike.invData != null && itemActionDataSpawnMinibike.invData.holdingEntity is EntityPlayerLocal) { UnityEngine.Object.Destroy(itemActionDataSpawnMinibike.MinibikePreview.gameObject); } }
/** * Garbage collection. */ public override void Cleanup(ItemActionData _data) { base.Cleanup(_data); ItemActionSpawnEntity.ItemActionDataSpawnEntity itemActionDataSpawnEntity = _data as ItemActionSpawnEntity.ItemActionDataSpawnEntity; if (itemActionDataSpawnEntity != null && itemActionDataSpawnEntity.EntityPreviewT != null && itemActionDataSpawnEntity.invData != null && itemActionDataSpawnEntity.invData.holdingEntity is EntityPlayerLocal) { UnityEngine.Object.Destroy(itemActionDataSpawnEntity.EntityPreviewT.gameObject); } }
public ItemActionPacket(ItemActionData action) : base() { writer.Write((byte)22); writer.Write((byte)action.action); writer.Write((byte)action.sourceContainer); writer.Write((byte)action.targetContainer); writer.Write(action.sourceSlot); writer.Write(action.targetSlot); }
public override void StartHolding(ItemActionData _actionData) { ItemActionSpawnCustomVehicle.ItemActionDataSpawnCustomVehicle itemActionDataSpawnMinibike = (ItemActionSpawnCustomVehicle.ItemActionDataSpawnCustomVehicle)_actionData; if (itemActionDataSpawnMinibike.MinibikePreview == null && itemActionDataSpawnMinibike.invData.holdingEntity is EntityPlayerLocal) { GameObject gameObject = (GameObject)ResourceWrapper.Load1P(itemActionDataSpawnMinibike.invData.holdingEntity.inventory.holdingItem.MeshFile); itemActionDataSpawnMinibike.MinibikePreview = UnityEngine.Object.Instantiate <Transform>(gameObject.transform); this.BB(_actionData); } }
private bool UB(ItemActionData itemActionData, ref Vector3 ptr) { ItemActionSpawnCustomVehicle.ItemActionDataSpawnCustomVehicle itemActionDataSpawnMinibike = (ItemActionSpawnCustomVehicle.ItemActionDataSpawnCustomVehicle)itemActionData; Ray lookRay = itemActionDataSpawnMinibike.invData.holdingEntity.GetLookRay(); if (Voxel.Raycast(GameManager.Instance.World, lookRay, 5f, 65536, 64, 0f)) { ptr = Voxel.voxelRayHitInfo.hit.pos; Vector3 vector = new Vector3(ptr.x + 0.5f, ptr.y, ptr.z + 0.5f); return(GameManager.Instance.World.GetBlock(new Vector3i(vector)).type == 0 && GameManager.Instance.World.GetBlock(new Vector3i(vector + Vector3.down)).type != 0 && GameManager.Instance.World.GetBlock(new Vector3i(vector + Vector3.up)).type == 0); } return(false); }
/** * Run this code when the entity is held in hand. */ public override void StartHolding(ItemActionData _actionData) { ItemActionSpawnEntity.ItemActionDataSpawnEntity itemActionDataSpawnEntity = (ItemActionSpawnEntity.ItemActionDataSpawnEntity)_actionData; EntityPlayerLocal entityPlayerLocal = itemActionDataSpawnEntity.invData.holdingEntity as EntityPlayerLocal; if (!entityPlayerLocal) { return; } if (itemActionDataSpawnEntity.EntityPreviewT != null) { UnityEngine.Object.DestroyImmediate(itemActionDataSpawnEntity.EntityPreviewT.gameObject); } GameObject original = DataLoader.LoadAsset <GameObject>(entityPlayerLocal.inventory.holdingItem.MeshFile); itemActionDataSpawnEntity.EntityPreviewT = UnityEngine.Object.Instantiate <GameObject>(original).transform; Vehicle.SetupPreview(itemActionDataSpawnEntity.EntityPreviewT); this.setupPreview(itemActionDataSpawnEntity); this.updatePreview(itemActionDataSpawnEntity); }
public override void ExecuteAction(ItemActionData _actionData, bool _bReleased) { FeedInventoryData feedInventoryData = (FeedInventoryData)_actionData; EntityAlive entityAlive = null; EntityAlive holdingEntity = feedInventoryData.invData.holdingEntity; feedInventoryData.ray = holdingEntity.GetLookRay(); if (Voxel.Raycast(feedInventoryData.invData.world, feedInventoryData.ray, 4f, -538750981, 128, this.SphereRadius)) { entityAlive = (ItemActionUseOther.GetEntityFromHit(Voxel.voxelRayHitInfo) as EntityAlive); } if (entityAlive != null) { foreach (string strCVar in this.lstTargetCvar) { Debug.Log("' Checking for CVAR: " + strCVar); if (entityAlive.Buffs.HasCustomVar(strCVar)) { if (entityAlive.Buffs.GetCustomVar(strCVar) > 100) { base.ExecuteAction(_actionData, _bReleased); if (feedInventoryData.bFeedingStarted) { entityAlive.Buffs.SetCustomVar(strCVar, 0f, true); } } return; } } } else { Debug.Log("No Target Entity"); } }
public bool IsCustomBoat(ItemActionData _actionData) { if (this.entityId < 0) { foreach (int v in EntityClass.list.Keys) { if (EntityClass.list[v].entityClassName == this.entityToSpawn) { //this.entityId = v; this.entityClass = EntityClass.list[v].classname; break; } } } //DebugMsg("ItemActionSpawnCustomVehicle.ReadFrom: entityToSpawn = " + this.entityToSpawn + " | ID = " + this.entityId.ToString() + " | class = " + this.entityClass); if (this.entityClass == typeof(EntityCustomBoat)) { //DebugMsg("It's a Boat!"); return(true); } //DebugMsg("NOT a Boat!"); return(false); }
public override void ExecuteAction(ItemActionData _actionData, bool _bReleased) { base.ExecuteAction(_actionData, _bReleased); }
/** * Executes the action data. */ public override void ExecuteAction(ItemActionData _actionData, bool _bReleased) { ItemActionSpawnEntity.ItemActionDataSpawnEntity itemActionDataSpawnEntity = (ItemActionSpawnEntity.ItemActionDataSpawnEntity)_actionData; if (!(_actionData.invData.holdingEntity is EntityPlayerLocal)) { return; } if (!_bReleased) { return; } if (Time.time - _actionData.lastUseTime < this.Delay) { return; } if (Time.time - _actionData.lastUseTime < Constants.cBuildIntervall) { return; } if (!itemActionDataSpawnEntity.ValidPosition) { return; } ItemInventoryData invData = _actionData.invData; if (this.entityId < 0) { foreach (KeyValuePair <int, EntityClass> keyValuePair in EntityClass.list.Dict) { if (keyValuePair.Value.entityClassName == this.entityToSpawn) { this.entityId = keyValuePair.Key; break; } } if (this.entityId == 0) { return; } } ItemValue holdingItemItemValue = invData.holdingEntity.inventory.holdingItemItemValue; if (!SingletonMonoBehaviour <ConnectionManager> .Instance.IsServer) { SingletonMonoBehaviour <ConnectionManager> .Instance.SendToServer(NetPackageManager.GetPackage <NetPackageVehicleSpawn>().Setup(this.entityId, itemActionDataSpawnEntity.Position, new Vector3(0f, invData.holdingEntity.rotation.y + 90f, 0f), holdingItemItemValue.Clone(), invData.holdingEntity.entityId), true); } else { Entity entity = EntityFactory.CreateEntity(this.entityId, itemActionDataSpawnEntity.Position + Vector3.up * 0.25f, new Vector3(0f, _actionData.invData.holdingEntity.rotation.y + 90f, 0f)); entity.SetSpawnerSource(EnumSpawnerSource.StaticSpawner); if (entity as EntityAlive != null) { (entity as EntityAlive).factionId = itemActionDataSpawnEntity.invData.holdingEntity.factionId; (entity as EntityAlive).belongsPlayerId = itemActionDataSpawnEntity.invData.holdingEntity.entityId; (entity as EntityAlive).factionRank = (byte)(itemActionDataSpawnEntity.invData.holdingEntity.factionRank - 1); } GameManager.Instance.World.SpawnEntityInWorld(entity); } if (itemActionDataSpawnEntity.EntityPreviewT != null && itemActionDataSpawnEntity.invData.holdingEntity is EntityPlayerLocal) { UnityEngine.Object.Destroy(itemActionDataSpawnEntity.EntityPreviewT.gameObject); } invData.holdingEntity.RightArmAnimationUse = true; (invData.holdingEntity as EntityPlayerLocal).DropTimeDelay = 0.5f; invData.holdingEntity.inventory.DecHoldingItem(1); invData.holdingEntity.PlayOneShot((this.soundStart != null) ? this.soundStart : "placeblock", false); }
public override void ExecuteAction(ItemActionData _actionData, bool _bReleased) { ItemActionSpawnCustomVehicle.ItemActionDataSpawnCustomVehicle itemActionDataSpawnMinibike = (ItemActionSpawnCustomVehicle.ItemActionDataSpawnCustomVehicle)_actionData; if (!(_actionData.invData.holdingEntity is EntityPlayerLocal)) { return; } if (!_bReleased) { return; } if (Time.time - _actionData.lastUseTime < this.Delay) { return; } if (Time.time - _actionData.lastUseTime < Constants.cBuildIntervall) { return; } if (!itemActionDataSpawnMinibike.ValidPosition) { return; } ItemInventoryData invData = _actionData.invData; if (this.entityId < 0) { foreach (int v in EntityClass.list.Keys) { if (EntityClass.list[v].entityClassName == this.entityToSpawn) { this.entityId = v; break; } } if (this.entityId == 0) { return; } } if (!Steam.Network.IsServer) { SingletonMonoBehaviour <ConnectionManager> .Instance.SendToServer(new NetPackageVehicleSpawn(this.entityId, itemActionDataSpawnMinibike.Position, new Vector3(0f, _actionData.invData.holdingEntity.rotation.y + 90f, 0f), invData.holdingEntity.inventory.holdingItemItemValue.Clone(), _actionData.invData.holdingEntity.entityId), true); } else { EntityVehicle entityVehicle = (EntityVehicle)EntityFactory.CreateEntity(this.entityId, itemActionDataSpawnMinibike.Position, new Vector3(0f, _actionData.invData.holdingEntity.rotation.y + 90f, 0f)); entityVehicle.SetSpawnerSource(EnumSpawnerSource.StaticSpawner); Vehicle vehicle = entityVehicle.GetVehicle(); string tag = "chassis"; if (invData.holdingEntity.inventory.holdingItem != null) { tag = invData.holdingEntity.inventory.holdingItem.VehicleSlotType; } vehicle.SetPartInSlot(tag, invData.holdingEntity.inventory.holdingItemItemValue.Clone()); vehicle.SaveVehiclePartsToInventory(); entityVehicle.SetOwner(GamePrefs.GetString(EnumGamePrefs.PlayerId)); GameManager.Instance.World.SpawnEntityInWorld(entityVehicle); } invData.holdingEntity.RightArmAnimationUse = true; GameManager.Instance.StartCoroutine(this.EB(invData, invData.holdingEntity.inventory.holdingItemIdx)); }
public override string RecordData() { if (data == null) { data = new Data(); } // Save position: var currentScene = SceneManager.GetActiveScene().buildIndex; var found = false; for (int i = 0; i < data.positions.Count; i++) { if (data.positions[i].scene == currentScene) { found = true; data.positions[i].position = transform.position; data.positions[i].rotation = transform.rotation; break; } } if (!found) { data.positions.Add(new PositionData(currentScene, transform.position, transform.rotation)); } // Save perspective: if (savePerspective) { var camera = UnityEngineUtility.FindCamera(null); var cameraController = camera.GetComponent <Opsive.UltimateCharacterController.Camera.CameraController>(); if (cameraController != null && cameraController.CanChangePerspectives) { data.firstPerson = (cameraController.ActiveViewType.GetType().FullName == cameraController.FirstPersonViewTypeFullName); } } // Save attributes: if (saveAttributes) { data.attributes.Clear(); var attributeManager = GetComponent <AttributeManager>(); if (attributeManager == null) { if (Debug.isDebugBuild) { Debug.LogWarning("UCC Saver can't save attributes. " + name + " doesn't have an Attribute Manager.", this); } } else { for (int i = 0; i < attributeManager.Attributes.Length; i++) { data.attributes.Add(attributeManager.Attributes[i].Value); } } } // Save inventory: if (saveInventory) { data.items.Clear(); var inventory = GetComponent <InventoryBase>(); if (inventory == null) { if (Debug.isDebugBuild) { Debug.LogWarning("UCC Saver can't save inventory. " + name + " doesn't have an Inventory component.", this); } } else { // Record equipped items: var equipped = new ItemType[inventory.SlotCount]; for (int i = 0; i < inventory.SlotCount; i++) { var equippedItem = inventory.GetItem(i); equipped[i] = (equippedItem != null) ? equippedItem.ItemType : null; } // Save items: var items = inventory.GetAllItems(); for (int i = 0; i < items.Count; i++) { var item = items[i]; if (item == null || item.ItemType == null) { continue; } var itemCount = inventory.GetItemTypeCount(item.ItemType); if (itemCount <= 0) { continue; } var isDuplicateItem = data.items.Find(x => x.itemID == item.ItemType.ID) != null; var itemData = new ItemData(); itemData.itemID = item.ItemType.ID; itemData.slot = item.SlotID; itemData.count = 1; itemData.equipped = item.ItemType == equipped[item.SlotID]; for (int j = 0; j < item.ItemActions.Length; j++) { var usableItem = item.ItemActions[j] as UsableItem; if (usableItem == null) { continue; } var itemActionData = new ItemActionData(); itemData.itemActionData.Add(itemActionData); itemActionData.id = usableItem.ID; itemActionData.count = isDuplicateItem ? 0 : inventory.GetItemTypeCount(usableItem.GetConsumableItemType()); itemActionData.consumableCount = usableItem.GetConsumableItemTypeCount(); } data.items.Add(itemData); } } } if (debug) { Debug.Log(JsonUtility.ToJson(data, true)); // [DEBUG] } var s = SaveSystem.Serialize(data); if (debug) { Debug.Log("UCC Saver on " + name + " saving: " + s, this); } return(s); }
public static Boolean FieldCalcMain(PLAYER caster, PLAYER target, AA_DATA tbl, Byte scriptId, UInt32 cursor) { ItemActionData tbl1 = new ItemActionData(tbl); return(FieldCalcMain(caster, target, tbl1, scriptId, cursor)); }
private static Boolean FieldCalcMain(PLAYER caster, PLAYER target, ItemActionData tbl, Byte scriptId, UInt32 cursor) { Context v = new Context { Caster = caster, Target = target, Tbl = tbl, Cursor = cursor, Flags = 0 }; v.TargetHp = v.TargetMp = 0; Byte num = scriptId; switch (num) { case 62: case 73: if (tbl.Info.VfxIndex == 289) { return(PersistenSingleton <UIManager> .Instance.ItemScene.FF9FItem_Vegetable()); } FldCalcSub_305(v); goto case 64; case 64: case 75: label_29: return(FieldCalcResult(v)); case 69: if (FldCalcSub_12A(v)) { if (target.cur.hp == target.max.hp) { v.Flags |= 1; goto case 64; } else { FldCalcSub_171(v); FldCalcSub_202(v); goto case 64; } } else { goto case 64; } case 70: if (FldCalcSub_12A(v)) { if (target.cur.mp == target.max.mp) { v.Flags |= 1; goto case 64; } else { FldCalcSub_171(v); FldCalcSub_21E(v); goto case 64; } } else { goto case 64; } case 71: if (FldCalcSub_12A(v)) { if (target.cur.hp == target.max.hp && target.cur.mp == target.max.mp) { v.Flags |= 1; goto case 64; } else { FldCalcSub_21F(v); goto case 64; } } else { goto case 64; } case 72: if (FldCalcSub_12B(v)) { FldCalcSub_220(v); goto case 64; } else { goto case 64; } case 74: return(PersistenSingleton <UIManager> .Instance.ItemScene.FF9FItem_Vegetable()); case 76: if (FldCalcSub_12A(v)) { FldCalcSub_223(v); goto case 64; } else { goto case 64; } default: switch (num) { case 10: if (FldCalcSub_12A(v)) { if (target.cur.hp == target.max.hp) { v.Flags |= 1; goto label_29; } else { FldCalcSub_137(v); FldCalcSub_146(v); FldCalcSub_144(v); FldCalcSub_156(v); FldCalcSub_202(v); goto label_29; } } else { goto label_29; } case 12: FldCalcSub_302(v); goto label_29; case 13: if (FldCalcSub_12B(v)) { FldCalcSub_204(v); goto label_29; } else { goto label_29; } default: goto label_29; } } }