public bool Activate(ItemReplacer item) { this.ResetItems(); this.m_ItemReplacer = item; this.ClearSlots(); bool flag = Player.Get().m_SwimController.IsActive(); if (item.m_ReplaceInfo.m_Craftable && !flag) { this.AddSlot(HUDItem.Action.Craft); } if (item.m_ReplaceInfo.m_CanBeAddedToInventory) { this.AddSlot(HUDItem.Action.Take); } if (item.m_ReplaceInfo.IsHeavyObject() && !item.m_ReplaceInfo.m_CanBeAddedToInventory && !MakeFireController.Get().IsActive()) { this.AddSlot(HUDItem.Action.PickUp); } if (item.m_ReplaceInfo.m_Eatable && !flag) { this.AddSlot(HUDItem.Action.Eat); } if (item.m_ReplaceInfo.CanDrink() && !flag) { this.AddSlot(HUDItem.Action.Drink); } if (item.m_ReplaceInfo.m_Harvestable && !flag) { this.AddSlot(HUDItem.Action.Harvest); } this.Activate(); return(true); }
private void OnSetAcre() { for (int i = 0; i < this.m_ToCollect.Count; i++) { Item component = this.m_ToCollect[i].GetComponent <Item>(); if (component != null) { component.m_Acre = this.m_Acre; } else { PlantFruit component2 = this.m_ToCollect[i].GetComponent <PlantFruit>(); if (component2 != null) { component2.m_Acre = this.m_Acre; } else { ItemReplacer component3 = this.m_ToCollect[i].GetComponent <ItemReplacer>(); if (component3 != null) { component3.m_Acre = this.m_Acre; } } } } }
private void UpdateDestroyOnReplaceObjects() { if (this.m_DestroyOnReplace == null) { return; } int i = 0; while (i < this.m_DestroyOnReplace.Count) { GameObject gameObject = this.m_DestroyOnReplace[i].ResolveGameObject(); if (gameObject) { ItemReplacer component = base.GetComponent <ItemReplacer>(); if (component != null) { component.m_DestroyOnReplace.Add(gameObject); } this.m_DestroyOnReplace.RemoveAt(i); } else { i++; } } }
public void OnDestroyPlant() { for (int i = 0; i < this.m_ToCollect.Count; i++) { if (this.m_ToCollect[i] != null) { PlantFruit component = this.m_ToCollect[i].GetComponent <PlantFruit>(); if (component && component.m_ItemInfo != null) { ItemsManager.Get().CreateItem(component.m_ItemInfo.m_ID, true, this.m_ToCollect[i].transform); } else { ItemReplacer component2 = this.m_ToCollect[i].GetComponent <ItemReplacer>(); if (component2) { ItemsManager.Get().CreateItem(component2.m_ReplaceInfo.m_ID, true, this.m_ToCollect[i].transform); } else { Food component3 = this.m_ToCollect[i].GetComponent <Food>(); if (component3) { component3.transform.SetParent(null); } } } } } }
public void OnTake(ItemReplacer item) { for (int i = 0; i < this.m_ToCollect.Count; i++) { if (this.m_ToCollect[i] != null && this.m_ToCollect[i] == item.gameObject) { this.m_ToCollect[i] = null; } } }
public void OnTake(ItemReplacer item) { if (this.m_GrownPlant) { AcreRespawnFruits component = this.m_GrownPlant.GetComponent <AcreRespawnFruits>(); if (component != null) { component.OnTake(item); } } }
private void Update() { int i = 0; while (i < this.m_SceneAsyncOperation.Count) { if (this.m_SceneAsyncOperation[i] == null || this.m_SceneAsyncOperation[i].isDone) { this.m_SceneAsyncOperation.RemoveAt(i); } else { i++; } } this.ApplyGraphicsSettings(); this.UpdateSlowMotion(); this.UpdateTimeScale(); this.UpdateCurentTimeInMinutes(); this.UpdateInputsDebug(); EventsManager.OnEvent(Enums.Event.PlayTime, Time.deltaTime); this.UpdateAnimalsSound(); this.UpdateLoading(); if (GreenHellGame.ROADSHOW_DEMO && Input.GetKeyDown(KeyCode.Escape)) { this.m_DebugPause = !this.m_DebugPause; CursorManager.Get().ShowCursor(this.m_DebugPause); this.Pause(this.m_DebugPause); if (this.m_DebugPause) { Player.Get().BlockMoves(); Player.Get().BlockRotation(); } else { Player.Get().UnblockMoves(); Player.Get().UnblockRotation(); } } this.UpdateFog(); if (this.m_TODSky.Cycle.Hour != this.m_LastEmissionColorChangeHour) { this.UpdateEmissiveMaterials(); this.m_LastEmissionColorChangeHour = this.m_TODSky.Cycle.Hour; } if (TwitchDemoManager.Get() != null) { TwitchDemoManager.Get().Update(); } this.UpdateDebugCutscene(); this.UpdateAA(); ItemReplacer.UpdateByDistance(); }
private void SetupItemReplacer(Dictionary <ItemReplacer, ItemReplacer> ir_map) { foreach (ItemReplacer itemReplacer in ir_map.Keys) { ItemReplacer itemReplacer2 = ir_map[itemReplacer]; itemReplacer2.m_DestroyOnReplace = new List <GameObject>(); for (int i = 0; i < itemReplacer.m_DestroyOnReplace.Count; i++) { GameObject item = this.FindNewByName(itemReplacer.m_DestroyOnReplace[i].name, ir_map); itemReplacer2.m_DestroyOnReplace.Add(item); } } }
void DragItem() { int clickedSlotID = Int32.Parse(name.Split('_')[1]); if (InventoryManager.itemsInInventory[clickedSlotID - 1] != null) { ItemReplacer.DragItem(InventoryManager.itemsInInventory[clickedSlotID - 1], clickedSlotID - 1); referenceObject.GetComponent <InventoryManager>().DeleteItem(clickedSlotID - 1); Destroy(hoveredItem); Destroy(descriptionBackground); hoveredItem = null; descriptionBackground = null; } }
public override void OnReplicationSerialize(P2PNetworkWriter writer, bool initial_state) { writer.Write(this.m_PlantDestroyed); if (this.m_PlantDestroyed) { writer.Write(this.m_ActivateScripts); writer.Write(this.m_DontDestroy); writer.Write(this.m_Layer); ItemReplacer component = base.GetComponent <ItemReplacer>(); if (component != null) { writer.WritePackedUInt32((uint)component.m_DestroyOnReplace.Count); for (int i = 0; i < component.m_DestroyOnReplace.Count; i++) { writer.Write(component.m_DestroyOnReplace[i]); } return; } writer.WritePackedUInt32(0u); } }
public void OnDestroyPlant() { if (DestroyablePlant.s_StandardShader == null) { DestroyablePlant.s_StandardShader = Shader.Find("Custom/WindLeavesC2Standard_not_moving"); } if (DestroyablePlant.m_Layer == -1) { DestroyablePlant.m_Layer = LayerMask.NameToLayer("SmallPlant"); } new Dictionary <ItemReplacer, ItemReplacer>(); for (int i = 0; i < this.m_Chunks.Count; i++) { if (!(this.m_Chunks[i] == null) && this.m_Chunks[i].activeSelf) { PlantFruit component = this.m_Chunks[i].GetComponent <PlantFruit>(); if (component) { ItemID item_id = (ItemID)Enum.Parse(typeof(ItemID), component.m_InfoName); ItemsManager.Get().CreateItem(item_id, true, this.m_Chunks[i].transform.position + component.m_BoxCollider.center, this.m_Chunks[i].transform.rotation); } else { ItemReplacer component2 = this.m_Chunks[i].GetComponent <ItemReplacer>(); if (component2) { component2.m_FromPlant = true; } DestroyablePlantChunk component3 = this.m_Chunks[i].GetComponent <DestroyablePlantChunk>(); if (component3 != null) { component3.Init(this.m_DontDestroy, this.m_ActivateScripts, DestroyablePlant.m_Layer); component3.OnPlantDestroy(); } } } } }
public ObservableCodeCollectionViewGallery(ItemsLayoutOrientation orientation = ItemsLayoutOrientation.Vertical, bool grid = true, int initialItems = 1000, bool addItemsWithTimer = false, ItemsUpdatingScrollMode scrollMode = ItemsUpdatingScrollMode.KeepItemsInView) { var layout = new Grid { RowDefinitions = new RowDefinitionCollection { new RowDefinition { Height = GridLength.Auto }, new RowDefinition { Height = GridLength.Auto }, new RowDefinition { Height = GridLength.Auto }, new RowDefinition { Height = GridLength.Auto }, new RowDefinition { Height = GridLength.Auto }, new RowDefinition { Height = GridLength.Auto }, new RowDefinition { Height = GridLength.Star } } }; IItemsLayout itemsLayout = grid ? new GridItemsLayout(3, orientation) : new LinearItemsLayout(orientation) as IItemsLayout; var itemTemplate = ExampleTemplates.PhotoTemplate(); var collectionView = new CollectionView { ItemsLayout = itemsLayout, ItemTemplate = itemTemplate, AutomationId = "collectionview", Header = "This is the header", ItemsUpdatingScrollMode = scrollMode }; var generator = new ItemsSourceGenerator(collectionView, initialItems, ItemsSourceType.ObservableCollection); var remover = new ItemRemover(collectionView); var adder = new ItemAdder(collectionView); var replacer = new ItemReplacer(collectionView); var mover = new ItemMover(collectionView); var inserter = new ItemInserter(collectionView); layout.Children.Add(generator); layout.Children.Add(remover); Grid.SetRow(remover, 1); layout.Children.Add(adder); Grid.SetRow(adder, 2); layout.Children.Add(replacer); Grid.SetRow(replacer, 3); layout.Children.Add(mover); Grid.SetRow(mover, 4); layout.Children.Add(inserter); Grid.SetRow(inserter, 5); layout.Children.Add(collectionView); Grid.SetRow(collectionView, 6); Content = layout; if (addItemsWithTimer) { generator.GenerateEmptyObservableCollectionAndAddItemsEverySecond(); } else { generator.GenerateItems(); } }
protected override bool UpdateCollisions(Triangle blade_t0, Triangle blade_t1, Triangle handle_t0, Triangle handle_t1, Vector3 hit_dir, bool damage_window, out CJObject cj_obj, out Collider collider, out bool collision_with_handle, float damage_window_start, float damage_window_end, out Vector3 hit_pos) { collision_with_handle = false; Vector3 zero = Vector3.zero; Vector3 zero2 = Vector3.zero; Quaternion identity = Quaternion.identity; cj_obj = null; collider = null; hit_pos = Vector3.zero; Item currentItem = this.m_Player.GetCurrentItem(Hand.Right); if (currentItem == null || currentItem.m_Info == null) { return(false); } ItemID id = currentItem.m_Info.m_ID; if (!this.m_PredictionData.ContainsKey((int)id)) { return(base.UpdateCollisions(blade_t0, blade_t1, handle_t0, handle_t1, hit_dir, damage_window, out cj_obj, out collider, out collision_with_handle, damage_window_start, damage_window_end, out hit_pos)); } AnimatorClipInfo[] currentAnimatorClipInfo = this.m_Animator.GetCurrentAnimatorClipInfo(1); AnimationClip animationClip = null; for (int i = 0; i < currentAnimatorClipInfo.Length; i++) { if (this.m_PredictionData[(int)id].ContainsKey(currentAnimatorClipInfo[i].clip)) { animationClip = currentAnimatorClipInfo[i].clip; } } if (animationClip == null) { return(base.UpdateCollisions(blade_t0, blade_t1, handle_t0, handle_t1, hit_dir, damage_window, out cj_obj, out collider, out collision_with_handle, damage_window_start, damage_window_end, out hit_pos)); } List <MeleeAttackPredictionData> list = this.m_PredictionData[(int)id][animationClip]; AnimatorStateInfo currentAnimatorStateInfo = this.m_Animator.GetCurrentAnimatorStateInfo(1); float num = 0.02f; float num2 = (this.m_LastAnimFrame >= 0f) ? (this.m_LastAnimFrame / currentAnimatorStateInfo.length) : 0f; float time = num2; float num3 = currentAnimatorStateInfo.normalizedTime - num2; int num4 = (int)(num3 / num); if (num4 < 1) { num4 = 1; } num3 /= (float)num4; for (int j = 0; j < num4; j++) { float num5 = num2 + num3 * (float)(j + 1); if (num5 < damage_window_start || num5 > damage_window_end) { this.m_LastAnimFrame = this.m_Animator.GetCurrentAnimatorStateInfo(1).length *num5; cj_obj = null; collider = null; time = num5; } else { Vector3 damagerStartPos = this.GetDamagerStartPos(num5, ref list); Vector3 damagerEndPos = this.GetDamagerEndPos(num5, ref list); Vector3 damagerStartPos2 = this.GetDamagerStartPos(time, ref list); Vector3 damagerEndPos2 = this.GetDamagerEndPos(time, ref list); this.m_BladeT0Triangle.p0 = damagerStartPos; this.m_BladeT0Triangle.p1 = damagerStartPos2; this.m_BladeT0Triangle.p2 = damagerEndPos; this.m_BladeT1Triangle.p0 = damagerStartPos2; this.m_BladeT1Triangle.p1 = damagerEndPos2; this.m_BladeT1Triangle.p2 = damagerEndPos; base.GetBoxParameters(this.m_BladeT0Triangle, this.m_BladeT1Triangle, out zero2, out zero, out identity); int num6 = Physics.OverlapBoxNonAlloc(zero2, zero, this.m_HitCollidersTmp, identity); this.SortCollisions(this.m_HitCollidersTmp, num6); for (int k = 0; k < num6; k++) { bool flag = false; Collider collider2 = this.m_HitCollidersTmp[k]; if (!(collider2 == this.m_Player.m_CharacterController.m_Controller)) { if (collider2.gameObject.IsWater()) { this.OnHitWater(collider2); } if ((!collider2.isTrigger || collider2.gameObject.IsAI() || collider2.gameObject.IsFish() || collider2.gameObject.GetComponent <Spikes>()) && !(collider2.gameObject == this.m_Player.gameObject) && !(collider2.gameObject == currentItem.gameObject) && !(collider2.transform.parent == Player.Get().transform.GetChild(0)) && !this.m_HitObjects.Contains(collider2.gameObject) && !(collider2.gameObject.GetComponent <Player>() != null) && !PlayerArmorModule.Get().IsgameObjectEquipedArmor(collider2.gameObject)) { Item component = collider2.gameObject.GetComponent <Item>(); if (!(component != null) || component.m_Info == null || (!component.m_Info.IsParasite() && !component.m_Info.IsArmor())) { ItemReplacer component2 = collider2.gameObject.GetComponent <ItemReplacer>(); if (component2) { string text = component2.m_ReplaceInfoName.ToString().ToLower(); if ((text.Contains("plant") && text != "plantain_lily_leaf") || text.Contains("leaf")) { goto IL_62D; } } ItemHold component3 = collider2.gameObject.GetComponent <ItemHold>(); if (component3) { string text2 = component3.m_InfoName.ToString().ToLower(); if ((text2.Contains("plant") && text2 != "plantain_lily_leaf") || text2.Contains("leaf")) { goto IL_62D; } } AI component4 = collider2.gameObject.GetComponent <AI>(); if (!component4 || !component4.m_GoalsModule || component4.m_GoalsModule.m_ActiveGoal == null || component4.m_GoalsModule.m_ActiveGoal.m_Type != AIGoalType.HumanJumpBack || component4.m_Animator.GetCurrentAnimatorStateInfo(0).normalizedTime >= 0.5f) { CJObject component5 = collider2.gameObject.GetComponent <CJObject>(); if (component5 == null) { Transform parent = collider2.gameObject.transform.parent; while (parent != null) { component5 = parent.GetComponent <CJObject>(); if (component5) { break; } parent = parent.parent; } } if (component5 != null && component5.GetHitCollisionType() == HitCollisionType.Bones) { if (base.CheckBonesIntersection(blade_t0, blade_t1, component5)) { flag = true; } } else { flag = true; } if (flag && damage_window) { float anim_frame = num5 * currentAnimatorStateInfo.length; this.SetupAnimFrameForHit(zero2, zero, identity, anim_frame, collider2); this.m_LastBoxHalfSizes = zero; this.m_LastBoxPos = zero2; this.m_LastBoxQuaternion = identity; this.m_LastAnimFrame = this.m_Animator.GetCurrentAnimatorStateInfo(1).length *num5; cj_obj = component5; collider = collider2; hit_pos = this.m_BladeT0Triangle.p0; float proportionalClamp = CJTools.Math.GetProportionalClamp(0f, 1f, num5, num2, currentAnimatorStateInfo.normalizedTime); this.m_AnimationStoppedHandPos = Vector3.Lerp(this.m_LastHandPos, this.m_RHand.transform.position, proportionalClamp); this.m_LastHandPos = this.m_RHand.position; return(true); } } } } } IL_62D :; } time = num5; } } this.m_LastBoxHalfSizes = zero; this.m_LastBoxPos = zero2; this.m_LastBoxQuaternion = identity; this.m_LastAnimFrame = this.m_Animator.GetCurrentAnimatorStateInfo(1).length *this.m_Animator.GetCurrentAnimatorStateInfo(1).normalizedTime; this.m_LastHandPos = this.m_RHand.position; cj_obj = null; collider = null; return(false); }
public void OnDestroyPlant() { if (DestroyablePlant.s_StandardShader == null) { DestroyablePlant.s_StandardShader = Shader.Find("Custom/WindLeavesC2Standard_not_moving"); } if (DestroyablePlant.m_Layer == -1) { DestroyablePlant.m_Layer = LayerMask.NameToLayer("SmallPlant"); } List <MeshCollider> list = new List <MeshCollider>(); Dictionary <ItemReplacer, ItemReplacer> dictionary = new Dictionary <ItemReplacer, ItemReplacer>(); for (int i = 0; i < this.m_Chunks.Count; i++) { if (!(this.m_Chunks[i] == null) && this.m_Chunks[i].activeSelf) { PlantFruit component = this.m_Chunks[i].GetComponent <PlantFruit>(); if (component) { ItemID item_id = (ItemID)Enum.Parse(typeof(ItemID), component.m_InfoName); ItemsManager.Get().CreateItem(item_id, true, this.m_Chunks[i].transform); } else { GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(this.m_Chunks[i], this.m_Chunks[i].transform.position, this.m_Chunks[i].transform.rotation); if (!this.m_DontDestroy) { gameObject.AddComponent <TinyPhysicsObject>(); } gameObject.AddComponent <Rigidbody>(); MeshCollider meshCollider = gameObject.AddComponent <MeshCollider>(); meshCollider.convex = true; this.ReplaceShader(gameObject); ObjectMaterial objectMaterial = gameObject.AddComponent <ObjectMaterial>(); objectMaterial.m_ObjectMaterial = EObjectMaterial.Bush; gameObject.layer = DestroyablePlant.m_Layer; list.Add(meshCollider); if (this.m_CopyScripts) { this.CopyComponents(this.m_Chunks[i], gameObject); } ItemReplacer component2 = this.m_Chunks[i].GetComponent <ItemReplacer>(); ItemReplacer component3 = gameObject.GetComponent <ItemReplacer>(); if (component2 && component3) { dictionary[component2] = component3; } this.DisableCollisionWithPlayer(meshCollider); } } } for (int j = 0; j < list.Count; j++) { for (int k = j + 1; k < list.Count; k++) { Physics.IgnoreCollision(list[j], list[k], true); } } this.SetupItemReplacer(dictionary); }
public ObservableCodeCollectionViewGallery(ItemsLayoutOrientation orientation = ItemsLayoutOrientation.Vertical, bool grid = true) { var layout = new Grid { RowDefinitions = new RowDefinitionCollection { new RowDefinition { Height = GridLength.Auto }, new RowDefinition { Height = GridLength.Auto }, new RowDefinition { Height = GridLength.Auto }, new RowDefinition { Height = GridLength.Auto }, new RowDefinition { Height = GridLength.Auto }, new RowDefinition { Height = GridLength.Star } } }; IItemsLayout itemsLayout = grid ? new GridItemsLayout(3, orientation) : new ListItemsLayout(orientation) as IItemsLayout; var itemTemplate = ExampleTemplates.PhotoTemplate(); var collectionView = new CollectionView { ItemsLayout = itemsLayout, ItemTemplate = itemTemplate }; var generator = new ItemsSourceGenerator(collectionView); var remover = new ItemRemover(collectionView); var adder = new ItemAdder(collectionView); var replacer = new ItemReplacer(collectionView); var mover = new ItemMover(collectionView); layout.Children.Add(generator); layout.Children.Add(remover); Grid.SetRow(remover, 1); layout.Children.Add(adder); Grid.SetRow(adder, 2); layout.Children.Add(replacer); Grid.SetRow(replacer, 3); layout.Children.Add(mover); Grid.SetRow(mover, 4); layout.Children.Add(collectionView); Grid.SetRow(collectionView, 5); Content = layout; generator.GenerateObservableCollection(); }