public void PickupItem(WorldItem worldItem) { int freeSlot = FindFreeSlot(); if (freeSlot == -1) { return; } slots[freeSlot].SetItem(worldItem.GetItem()); worldItem.Pickup(); }
static void InitializeTemplate( ) { foreach (GameObject go in Selection.gameObjects) { WorldItem wi = null; if (go.HasComponent <WorldItem> (out wi)) { Debug.Log("Initializing template in " + wi.name); wi.InitializeTemplate(); } } }
public IEnumerator SetUp() { player = MonoBehaviour.Instantiate(Resources.Load <GameObject>("Tests/Player")); yield return(null); // Wait for prefab to load character = player.GetComponent <Character>(); worldItem = WorldItem.Create(Resources.Load <Item>("Items/item"), 1); yield return(null); // Wait for prefab to load character.Inventory.Give(worldItem); itemScript = character.HandItemContainer.gameObject.GetComponentInChildren <ItemScript>(); }
public void Awake() { WorldItem w = gameObject.GetComponent <WorldItem>(); w.OnGainPlayerFocus += OnGainPlayerFocus; w.OnLosePlayerFocus += OnLosePlayerFocus; if (IsSpecialObject) { OnBecomeSpecialObject(); } }
protected void LoseAttention() { WorldItem worlditem = gameObject.GetComponent <WorldItem>(); if (worlditem == null || worlditem.Destroyed) { return; } RemoveMatFromRenderers(worlditem.Renderers, Mats.Get.AttentionOutlineMaterial); mHasAddedAttentionMats = false; }
private void DownloadWorld(WorldItem world) { world.State = WorldState.Downloading; Remote.DownloadWorld(world.World.ID, o => { SaveWorld(world.World, o); world.State = WorldState.Existing; Console.WriteLine(o.Length); }); }
private void AddItem(ServerWorld world) { GameObject newItem = Instantiate(worldItemPrefab); // set parent newItem.transform.SetParent(contentPanel, false); // initialise WorldItem worldItem = newItem.GetComponent <WorldItem>(); worldItem.Initialise(world, loader); }
protected override TreeViewItem BuildRoot() { _loadedStyle = EditorStyles.boldLabel; _activeStyle = new GUIStyle(EditorStyles.boldLabel); _activeStyle.fontStyle = FontStyle.BoldAndItalic; var id = 0; var rootItem = new TreeViewItem { id = id++, depth = -1, displayName = "Root" }; var worldItem = new WorldItem { Store = WorldManager.Instance.Variables, World = WorldManager.Instance, id = id++, displayName = "World" }; rootItem.AddChild(worldItem); var playerItem = new PlayerItem { Store = Player.Instance.Variables, Player = Player.Instance, id = id++, displayName = "Player" }; rootItem.AddChild(playerItem); var zonesItem = new TreeViewItem { id = id++, displayName = "Zones" }; rootItem.AddChild(zonesItem); foreach (var zone in WorldManager.Instance.Zones) { if (zone != null) { var zoneItem = new ZoneItem { Store = zone.Variables, Zone = zone, id = id++, displayName = zone.Zone.Name }; zonesItem.AddChild(zoneItem); foreach (var npc in zone.Npcs) { var npcItem = new NpcItem { Store = npc.Variables, Npc = npc, id = id++, displayName = string.IsNullOrEmpty(npc.Name) ? "(Npc)" : npc.Name }; zoneItem.AddChild(npcItem); } } } SetExpanded(zonesItem.id, true); SetupDepthsFromParentsAndChildren(rootItem); return(rootItem); }
public void GhostFadeOut(WorldItem ghost) { if (ghost.hasInstance) { GhostFadeAnim anim = ghost.Instance.gameObject.GetComponent <GhostFadeAnim>(); if (anim != null) { pendingActions++; anim.StartGhostFade(false, true); } } }
public void DestroyItem() { if (this.item == null) { return; } WorldItem worldItem = this; this.item.OnDirty -= new Action <Item>(worldItem.OnItemDirty); this.item.Remove(0f); this.item = null; }
public void LoadWorlds() { GameManager.LoadData(); ClearActiveChildren(worldsHolder); foreach (GameManager.World world in GameManager.worlds.Values) { WorldItem item = Instantiate(worldItemTemplate, worldsHolder); item.gameObject.SetActive(true); item.world = world; } LayoutRebuilder.MarkLayoutForRebuild(worldsHolder.parent as RectTransform); }
public virtual bool IsObjectPermitted(WorldItem potentialOccupant, ReceptacleSettings settings) { if (State.Locked) { return(false); } if (potentialOccupant == null) { return(false); } if (((int)potentialOccupant.Size) > ((int)settings.MaxSize)) { //TODO use Stacks size comparison, this is error prone Debug.Log("Too big"); return(false); } if (settings.PermittedScripts.Count > 0) { if (!potentialOccupant.HasAtLeastOne(settings.PermittedScripts)) { return(false); } } if (settings.PermittedSubcats.Count > 0) { if (!settings.PermittedSubcats.Contains(potentialOccupant.Subcategory)) { return(false); } } if (settings.PermittedMaterials != WIMaterialType.None) { if (!Flags.Check((uint)settings.PermittedMaterials, (uint)potentialOccupant.Props.Global.MaterialType, Flags.CheckType.MatchAny)) { return(false); } } if (settings.PermittedItems.Count > 0) { foreach (string permittedItemName in settings.PermittedItems) { if (!Stacks.Can.Stack(potentialOccupant, permittedItemName)) { return(false); } } } return(true); }
public void Update( ) { while (mIncoming.Count > 0) { WorldItem deadWorldItem = mIncoming.Dequeue( ); deadWorldItem.transform.parent = transform; deadWorldItem.gameObject.layer = Globals.LayerNumHidden; deadWorldItem.transform.localPosition = Vector3.zero; //deadWorldItem.StopAllCoroutines (); //deadWorldItem.gameObject.SetActive (false); GameObject.Destroy(deadWorldItem.gameObject, 1.0f); } }
protected Vector3 GetPos(Transform t) { Vector3 pos = t.position; WorldItem item = t.GetComponent <WorldItem>(); if (item != null) { pos = item.GetPosition(); } return(pos); }
public override void OnActivated() { WorldItem structureWorldItem = null; StackItem structureStackitem = null; if (WIGroups.FindChildItem(StructurePath, out structureWorldItem)) { if (Player.Local.Surroundings.IsVisitingStructure(structureWorldItem.Get <Structure> ())) { HasCompleted = true; } } }
private void Start() { var table = new List <string>(); for (int i = 0; i < loottable.Count; i++) { table.Add(loottable[UnityEngine.Random.Range(0, loottable.Count)]); } foreach (var item in table) { WorldItem.Create(Database.GetItemByID(item), transform.Find("spawnpoint").position, -1, atPoint: true); } }
public void CallForHelp(WorldItem creatureInNeed, IItemOfInterest sourceOfTrouble) { if (sourceOfTrouble != null) { for (int i = 0; i < SpawnedCreatures.Count; i++) { if (SpawnedCreatures[i] != null && SpawnedCreatures[i].worlditem != creatureInNeed) { SpawnedCreatures[i].AttackThing(sourceOfTrouble); } } } }
public void LookForDemolitionController( ) { WorldItem demolitionControllerWorldItem = null; if (WIGroups.FindChildItem(State.DemolitionControllerPath, out demolitionControllerWorldItem)) { DemolitionController = demolitionControllerWorldItem.Get <StructureDemolitionController> (); DemolitionController.AddDemolishable(this); //don't let our colliders turn off worlditem.ActiveState = WIActiveState.Active; worlditem.ActiveStateLocked = true; } }
public override void CheckIfCompleted() { WorldItem questItem = null; if (GameWorld.Get.QuestItem(ItemName, out questItem)) { if (questItem.State == State) { HasCompleted = true; Status |= MissionStatus.Completed; } } }
public void OpenSellWindow(WorldItem itemToSell) // Called from GM. The window that pops up: "Do you want to sell this item"? { sellWindow.SetActive(true); sellWindowItemImage.sprite = itemToSell.GetWorldItemSprites().normalSprites[0]; sellWindowItemName.text = itemToSell.myGameItem.itemProperties.displayedName; sellWindowItemPrice.text = itemToSell.myGameItem.itemProperties.sellPriceFlorets.ToString(); sellWindowItemDescription.text = itemToSell.myGameItem.itemProperties.itemDescription; selectedWorldItem = itemToSell; //instancesOfCurrentItem = GM.GetInstancesOfGameItemOwnedWorldAndInv(itemToSell.gameItem.itemProperties.itemID); //currentItem = itemToSell[0]; }
private void HandleItemPickup(WorldItem targetItem) { Vector3 local_pos = targetItem.transform.position - cam_controller.transform.position; if (Physics.Raycast(cam_controller.transform.position, local_pos, out RaycastHit hit_info, local_pos.magnitude)) { if (!hit_info.transform.GetComponentsInChildren <WorldItem>().Contains(targetItem)) { return; } } AddItemToInventory(targetItem); }
public bool CanEquip() { if (Holstered) { return(false); } if (!HasWorldItem && player.Inventory.HasActiveCarryItem) { worlditem = player.Inventory.ActiveCarryItem; return(true); } return(false); }
bool CheckForWorldDuplicate(WorldItem loadedItem) // Called at load to stop world items duplicating { PlacePoint point = GameObject.Find(loadedItem.myGameItem.placedPointName).GetComponent <PlacePoint>(); if (point.empty == false) { Destroy(loadedItem.gameObject); return(true); } else { return(false); } }
protected IEnumerator FadeOutDetect() { WorldItem worlditem = gameObject.GetComponent <WorldItem>(); mFadingOutDetection = true; yield return(null); while (mDetectionIntensity > 0.001f) { mDetectionIntensity -= (float)WorldClock.ARTDeltaTime; } RemoveMatFromRenderers(worlditem.Renderers, mDetectionMaterial); mFadingOutDetection = false; yield break; }
public override void OnEditorRefresh() { if (Triggers.Count > 0) { State.TriggerNames.Clear(); for (int i = 0; i < Triggers.Count; i++) { if (Triggers[i] != null) { WorldItem TriggerWorlditem = Triggers[i].GetComponent <WorldItem>(); State.TriggerNames.Add(TriggerWorlditem.FileName); } } } }
void Refund(BasePlayer player, BaseEntity entity) { if (entity as WorldItem) { WorldItem worlditem = entity as WorldItem; if (worlditem.item != null && worlditem.item.info != null) { player.inventory.GiveItem(worlditem.item.info.itemid, 1, true); } } else if (entity as BuildingBlock) { RefundBuildingBlock(player, entity as BuildingBlock); } }
public void OnItemOfInterestLeave() { Visitable visitable = null; if (worlditem.Is <Visitable> (out visitable)) { Creature creature = null; WorldItem lastItemOfInterest = visitable.LastItemOfInterestToLeave; WaterTrap waterTrap = null; if (lastItemOfInterest.Is <WaterTrap> (out waterTrap)) { waterTrap.IntersectingDens.Remove(this); } } }
public override void OnHitByProjectile(CellFace cellFace, WorldItem worldItem) { //收集掉落物 ++ll; if (ll >= 2) { ll = 0; return; } int value = subsystemTerrain.Terrain.GetCellValueFast(cellFace.Point.X, cellFace.Point.Y, cellFace.Point.Z); int level = ILibrary.getItemId(value); int maxcnt = (int)Math.Pow((double)2, (double)level) * 128; //计算最大容量 if (Terrain.ExtractContents(value) == HandledBlocks[0]) { try { ComponentBlockEntity componentBlockEntity = subsystemBlockEntities.GetBlockEntity(cellFace.X, cellFace.Y, cellFace.Z); if (componentBlockEntity == null) { toast("没有找到Blockentity"); return; } ComponentSingleChest singleChestData = componentBlockEntity.Entity.FindComponent <ComponentSingleChest>(true); if (singleChestData == null) { toast("没有找到componentchest"); return; } if (worldItem.ToRemove) { return; } Pickable pickable = worldItem as Pickable; int num = pickable?.Count ?? 1; int num2 = saveInventory(singleChestData, worldItem.Value, num, maxcnt); if (num2 < num) { subsystemAudio.PlaySound("Audio/PickableCollected", 1f, 0f, worldItem.Position, 3f, autoDelay: true); } if (num2 <= 0) { worldItem.ToRemove = true; } else if (pickable != null) { pickable.Count = num2; } } catch (Exception e) { toast(e.ToString()); } } }
/// <summary> /// Clear any dialogue lines or choices /// currently shown. /// </summary> public void ClearDialogue() { currentNode = null; foreach (DialogueUIChoice choice in choiceView.GetComponentsInChildren <DialogueUIChoice>()) { Destroy(choice.gameObject); } choiceView.SetActive(false); lineView.SetActive(false); if (currentSpeaker != null) { currentSpeaker.ShowSpeechBubble(false); currentSpeaker = null; } }
protected virtual bool AddToReceptaclePivot(WorldItem potentialOccupant, ReceptaclePivot pivotInFocus) { if (State.Locked || mAddingToReceptaclePivot) { return(false); } if (pivotInFocus.IsOccupied || !IsObjectPermitted(potentialOccupant, pivotInFocus.Settings)) { return(false); } mAddingToReceptaclePivot = true; StartCoroutine(AddToReceptaclePivotOverTime(potentialOccupant, pivotInFocus)); return(true); }
private static void myUpdateLastObject(int parentTag, WorldItem worldItem) { TreeViewItem t = GetParentByTag(parentTag); lock (myTreeView) { if (t != null) { TreeViewItem lastActions = t.Items[1] as TreeViewItem; if (lastActions != null) { TreeViewItem lastObject = lastActions.Items[0] as TreeViewItem; if (lastObject != null) { TreeViewItem newLastObject = new TreeViewItem(); TreeViewItem oldLastObject = lastActions.Items[0] as TreeViewItem; newLastObject.Header = "Last object"; newLastObject.IsExpanded = lastObject.IsExpanded; newLastObject.Items.Add("Serial = " + worldItem.Serial); newLastObject.Items.Add("ID = " + worldItem.ID); if (!string.IsNullOrEmpty(worldItem.Name)) newLastObject.Items.Add("Name = " + worldItem.Name); newLastObject.Items.Add("X = " + worldItem.X); newLastObject.Items.Add("Y = " + worldItem.Y); newLastObject.Items.Add("Z = " + worldItem.Z); lastActions.Items[0] = newLastObject; lastActions.Items.Refresh(); } } } } }
public static void UpdateLastObject(int parentTag, WorldItem worldItem) { if (myTreeView.CheckAccess()) myUpdateLastObject(parentTag, worldItem); else myTreeView.Dispatcher.BeginInvoke(myUpdateLastObjectDelegate, new object[] { parentTag, worldItem }); }
protected override Boolean Paint(Vector2f point) { switch (Mode) { case EMode.Normal: String baseType = CurrentObject.GetType().Name; WorldObject currentObject = null; switch (baseType) { case "Element": currentObject = new Element((Element)CurrentObject); break; case "DisplaceableElement": currentObject = new DisplaceableElement((DisplaceableElement)CurrentObject); break; case "GroundElement": currentObject = new GroundElement((GroundElement)CurrentObject); break; case "WorldItem": currentObject = new WorldItem((WorldItem)CurrentObject); break; } Int32 x = (Int32)(point.X - currentObject.Halfsize.X); Int32 y = (Int32)(point.Y - currentObject.Halfsize.Y); currentObject.SetMap(MapMan.GetCurrent(), x, y); return true; default: return false; } }
void FillWorldsList() { var loadListRes = (MyLoadListResult)m_loadWorldsAsync; var availableSaves = loadListRes.AvailableSaves; availableSaves.Sort((x, y) => { return x.Item1.CompareTo(y.Item1); }); gamesListBox.Items.Clear(); if (availableSaves.Count != 0) { foreach (var save in availableSaves) { WorldItem worldItem = new WorldItem() { SessionName = save.Item2.SessionName, SessionPath = save.Item1, SessionDir = System.IO.Path.GetFileName(save.Item1) }; gamesListBox.Items.Add(worldItem); if (MySandboxGame.ConfigDedicated.LoadWorld == worldItem.SessionPath) gamesListBox.SelectedIndex = gamesListBox.Items.Count - 1; } } startTypeRadio_CheckedChanged(null, null); gamesListBox.Sorted = true; }