Beispiel #1
0
 public bool ItemACIChange(double timeStamp)
 {
     if (!HasWorldItem ||
         worlditem != player.Inventory.ActiveCarryItem ||
         !worlditem.Is(WIMode.Equipped))
     {
         //unequip, then requip if anything has changed
         AddAction(ToolAction.Unequip);
         AddAction(ToolAction.Equip);
     }
     return(true);
 }
Beispiel #2
0
        public static bool CanLaunch(Weapon weapon, IWIBase projectileBase)
        {
            if (weapon == null || projectileBase == null)
            {
                return(false);                                               //whoops
            }

            if (!projectileBase.Is <Projectile>())
            {
                return(false);                                               //can't launch it if it's not a projectile
            }

            //find out of the projectile keyword matches
            WorldItem projectileWorldItem = null;

            if (projectileBase.IsWorldItem)
            {
                projectileWorldItem = projectileBase.worlditem;
            }
            else if (!WorldItems.Get.PackPrefab(projectileBase.PackName, projectileBase.PrefabName, out projectileWorldItem))
            {
                return(false);
            }
            //alright, see if the projectile type matches
            Projectile projectile = null;

            if (projectileWorldItem.Is <Projectile>(out projectile))
            {
                return(weapon.ProjectileType == projectile.ProjectileType);
            }

            return(false);
        }
Beispiel #3
0
        public static string GetExamineInfo(IItemOfInterest targetObject)
        {
            string               examineString = string.Empty;
            WorldItem            worlditem     = null;
            List <WIExamineInfo> info          = new List <WIExamineInfo>();

            if (targetObject.IOIType == ItemOfInterestType.WorldItem)
            {
                worlditem = targetObject.worlditem;
                Examinable examinable = null;
                if (worlditem.Is <Examinable>(out examinable))
                {
                    examineString = examinable.State.StaticExamineMessage;
                }
                else
                {
                    worlditem.Examine(info);
                    //get all the examine info from each script
                    //if we have enough skill, add it to the introspection
                    if (info.Count == 0)
                    {
                        //TODO this sucks come up with a better line
                        if (worlditem.Props.Global.MaterialType != WIMaterialType.None && worlditem.Props.Global.Flags.Size != WISize.NoLimit)
                        {
                            examineString = "It's " + Colors.ColorWrap(worlditem.Props.Global.Flags.Size.ToString(), Colors.Get.MessageSuccessColor)
                                            + " and is made mostly of " + Colors.ColorWrap(worlditem.Props.Global.MaterialType.ToString(), Colors.Get.MessageSuccessColor);
                        }
                    }

                    examineString = worlditem.DisplayName;

                    for (int i = 0; i < info.Count; i++)
                    {
                        WIExamineInfo examineInfo    = info[i];
                        bool          displaySuccess = true;
                        if (!string.IsNullOrEmpty(examineInfo.RequiredSkill))
                        {
                            displaySuccess = false;
                            float skillUsageLevel = 0f;
                            if (Skills.Get.HasLearnedSkill(examineInfo.RequiredSkill, out skillUsageLevel) && skillUsageLevel >= examineInfo.RequiredSkillUsageLevel)
                            {
                                displaySuccess = true;
                            }
                        }
                        if (displaySuccess)
                        {
                            examineString = examineInfo.StaticExamineMessage;
                        }
                        else if (!string.IsNullOrEmpty(examineInfo.ExamineMessageOnFail))
                        {
                            examineString = examineInfo.ExamineMessageOnFail;
                        }
                    }
                }
            }
            return(examineString);
        }
Beispiel #4
0
        public void OnAbsorbWorldItem(WorldItem worlditem)
        {
            Flammable flammable = null;

            if (worlditem.Is <Flammable>(out flammable))
            {
                State.TotalFuel += flammable.State.FuelRemaining;
            }
        }
Beispiel #5
0
        public void OnItemOfInterestLeave()
        {
            Visitable visitable = null;

            if (worlditem.Is <Visitable>(out visitable))
            {
                Creature  creature           = null;
                WorldItem lastItemOfInterest = visitable.LastItemOfInterestToLeave;
                LandTrap  landTrap           = null;
                WaterTrap waterTrap          = null;
                if (lastItemOfInterest.Is <LandTrap>(out landTrap))
                {
                    landTrap.IntersectingDens.Remove(this);
                }
                else if (lastItemOfInterest.Is <WaterTrap>(out waterTrap))
                {
                    waterTrap.IntersectingDens.Remove(this);
                }
            }
        }
Beispiel #6
0
        public void OnItemOfInterestVisit()
        {
            //Debug.Log("On item of interest visit");
            Visitable visitable = null;

            if (worlditem.Is <Visitable>(out visitable))
            {
                Creature  creature           = null;
                ITrap     trap               = null;
                WorldItem lastItemOfInterest = visitable.LastItemOfInterestToVisit;
                LandTrap  landTrap           = null;
                WaterTrap waterTrap          = null;
                if (lastItemOfInterest.Is <LandTrap>(out landTrap) && !landTrap.Exceptions.Contains(NameOfCreature))
                {
                    //Debug.Log("Found a land trap");
                    landTrap.IntersectingDens.SafeAdd(this);
                }
                else if (lastItemOfInterest.Is <WaterTrap>(out waterTrap) && !waterTrap.Exceptions.Contains(NameOfCreature))
                {
                    //Debug.Log("Found a water trap");
                    waterTrap.IntersectingDens.SafeAdd(this);
                }
            }
        }
Beispiel #7
0
        public void OnItemOfInterestVisit()
        {
            Visitable visitable = null;

            if (worlditem.Is <Visitable> (out visitable))
            {
                Creature  creature           = null;
                ITrap     trap               = null;
                WorldItem lastItemOfInterest = visitable.LastItemOfInterestToVisit;
                WaterTrap waterTrap          = null;
                if (lastItemOfInterest.Is <WaterTrap> (out waterTrap) && !waterTrap.Exceptions.Contains(State.NameOfFish))
                {
                    Debug.Log("Found a water trap");
                    waterTrap.IntersectingDens.SafeAdd(this);
                }
            }
        }
Beispiel #8
0
        public List <T> GetLocations <T>() where T : WIScript
        {
            List <T> locationList = new List <T>();

            for (int i = 0; i < spline.splineNodesArray.Count; i++)
            {
                T         location          = null;
                WorldItem locationWorldItem = null;
                if (spline.splineNodesArray[i].gameObject.HasComponent <WorldItem>(out locationWorldItem))
                {
                    if (locationWorldItem.Is <T>(out location))
                    {
                        locationList.Add(location);
                    }
                }
            }
            return(locationList);
        }
Beispiel #9
0
        public override bool Use(IItemOfInterest targetObject, int flavorIndex)
        {
            WorldItem            worlditem            = null;
            List <string>        introspectionStrings = new List <string>();
            List <WIExamineInfo> info = new List <WIExamineInfo>();
            int numLocationsRevealed  = 0;

            if (targetObject.IOIType == ItemOfInterestType.WorldItem)
            {
                worlditem = targetObject.worlditem;
                Examinable examinable = null;
                if (worlditem.Is <Examinable>(out examinable))
                {
                    Frontiers.GUI.GUIIntrospectionDisplay.IntrospectionMessage message = new Frontiers.GUI.GUIIntrospectionDisplay.IntrospectionMessage();
                    message.CenterText      = false;
                    message.Delay           = 0f;
                    message.FocusItem       = worlditem;
                    message.SkipOnLoseFocus = worlditem.Is(WIMode.World | WIMode.Frozen);
                    message.LongForm        = examinable.State.LongFormDisplay;
                    message.Message         = examinable.State.StaticExamineMessage;
                    message.IconName        = string.Empty;

                    GUIManager.Get.NGUIIntrospectionDisplay.AddMessage(message, true);

                    for (int i = 0; i < examinable.State.LocationsToReveal.Count; i++)
                    {
                        if (Player.Local.Surroundings.Reveal(examinable.State.LocationsToReveal[i]))
                        {
                            Profile.Get.CurrentGame.MarkedLocations.SafeAdd(examinable.State.LocationsToReveal[i]);
                            numLocationsRevealed++;
                        }
                    }
                }
                else
                {
                    worlditem.Examine(info);
                    //get all the examine info from each script
                    //if we have enough skill, add it to the introspection
                    if (info.Count == 0)
                    {
                        //TODO this sucks come up with a better line
                        if (worlditem.Props.Global.MaterialType != WIMaterialType.None && worlditem.Props.Global.Flags.Size != WISize.NoLimit)
                        {
                            introspectionStrings.Insert(0, "It's " + Colors.ColorWrap(worlditem.Props.Global.Flags.Size.ToString(), Colors.Get.MessageSuccessColor)
                                                        + " and is made mostly of " + Colors.ColorWrap(worlditem.Props.Global.MaterialType.ToString(), Colors.Get.MessageSuccessColor));
                        }
                    }

                    introspectionStrings.Insert(0, worlditem.DisplayName);

                    for (int i = 0; i < info.Count; i++)
                    {
                        WIExamineInfo examineInfo    = info[i];
                        bool          displaySuccess = true;
                        if (!string.IsNullOrEmpty(examineInfo.RequiredSkill))
                        {
                            displaySuccess = false;
                            float skillUsageLevel = 0f;
                            if (Skills.Get.HasLearnedSkill(examineInfo.RequiredSkill, out skillUsageLevel) && skillUsageLevel >= examineInfo.RequiredSkillUsageLevel)
                            {
                                displaySuccess = true;
                            }
                        }
                        if (displaySuccess)
                        {
                            if (examineInfo.LocationsToReveal.Count > 0)
                            {
                                for (int j = 0; j < examineInfo.LocationsToReveal.Count; j++)
                                {
                                    if (Player.Local.Surroundings.Reveal(examineInfo.LocationsToReveal[j]))
                                    {
                                        Profile.Get.CurrentGame.MarkedLocations.SafeAdd(examineInfo.LocationsToReveal[j]);
                                        numLocationsRevealed++;
                                    }
                                }
                            }
                            introspectionStrings.Add(examineInfo.StaticExamineMessage);
                        }
                        else if (!string.IsNullOrEmpty(examineInfo.ExamineMessageOnFail))
                        {
                            introspectionStrings.Add(examineInfo.ExamineMessageOnFail);
                        }
                    }

                    Frontiers.GUI.GUIIntrospectionDisplay.IntrospectionMessage message = new Frontiers.GUI.GUIIntrospectionDisplay.IntrospectionMessage();
                    message.CenterText      = false;
                    message.Delay           = 0f;
                    message.FocusItem       = worlditem;
                    message.SkipOnLoseFocus = worlditem.Is(WIMode.World | WIMode.Frozen);
                    message.Message         = introspectionStrings.JoinToString("\n");
                    message.LongForm        = introspectionStrings.Count > 4 || message.Message.Length > 220;
                    message.IconName        = string.Empty;

                    GUIManager.Get.NGUIIntrospectionDisplay.AddMessage(message, true);
                }
                if (numLocationsRevealed > 0)
                {
                    GUIManager.PostSuccess(numLocationsRevealed.ToString() + " locations revealed on World Map");
                    Player.Get.AvatarActions.ReceiveAction(AvatarAction.LocationReveal, WorldClock.AdjustedRealTime);
                }
                worlditem.OnExamine.SafeInvoke();
                return(true);
            }
            return(false);
        }
Beispiel #10
0
        public bool BelongsToPack(WorldItem worlditem)
        {
            Creature creature = null;

            return(worlditem.Is <Creature>(out creature) && String.Equals(creature.State.PackTag, State.PackTag));
        }
Beispiel #11
0
        public void OnPlayerUseWorldItemSecondary(object secondaryResult)
        {
            WIListResult dialogResult = secondaryResult as WIListResult;

            switch (dialogResult.SecondaryResult)
            {
            case "PourOnSelf":
                MasterAudio.PlaySound(MasterAudio.SoundType.PlayerInterface, "FillLiquidContainer");
                Player.Local.Status.RemoveCondition("BurnedByFire");
                Player.Local.Status.AddCondition("Wet");
                State.Contents.Clear();
                break;

            case "Drink":
                WorldItem liquid = null;
                if (WorldItems.Get.PackPrefab(State.Contents.PackName, State.Contents.PrefabName, out liquid))                                                                  //this is tricky - we want to drink it without destroying the prefab
                {
                    FoodStuff foodstuff = null;
                    if (liquid.Is <FoodStuff>(out foodstuff))                                                                                   //DON'T consume the foodstuff!
                    {
                        FoodStuff.Drink(foodstuff);
                        State.Contents.InstanceWeight--;
                        GUIManager.PostInfo("Drank 1 " + State.Contents.DisplayName + ", " + State.Contents.InstanceWeight.ToString() + "/" + State.Capacity.ToString() + " left.");
                    }
                }
                break;

            case "Pour Out":
                //two options here
                //if we're in the inventory then we want to add our contents to the selected stack
                //if we're in the world we want to dump it into the world
                bool playSound = false;
                if (PrimaryInterface.IsMaximized("Inventory"))
                {
                    WIStack selectedStack = Player.Local.Inventory.SelectedStack;
                    if (Stacks.Can.Stack(selectedStack, State.Contents))
                    {
                        WIStackError error = WIStackError.None;
                        for (int i = 0; i < State.Contents.InstanceWeight; i++)
                        {
                            StackItem contents = State.Contents.ToStackItem();
                            if (!Stacks.Push.Item(selectedStack, contents, ref error))
                            {
                                break;
                            }
                            else
                            {
                                playSound = true;
                            }
                        }
                    }
                }
                else
                {
                    State.Contents.Clear();
                    GUIManager.PostInfo("Discarded contents");
                    if (Player.Local.Surroundings.IsWorldItemInRange)
                    {
                        Flammable flammable = null;
                        if (Player.Local.Surroundings.WorldItemFocus.worlditem.Is <Flammable>(out flammable) && flammable.IsOnFire)
                        {
                            flammable.Extinguish();
                        }
                    }
                    playSound = true;
                }
                if (playSound)
                {
                    MasterAudio.PlaySound(MasterAudio.SoundType.PlayerInterface, "FillLiquidContainer");
                }
                break;

            default:
                break;
            }
        }
Beispiel #12
0
 protected void FindWater()
 {
     if (Physics.Raycast(worlditem.Position + Vector3.up * 10, Vector3.down, out mWaterHit, 100f, Globals.LayerFluidTerrain))
     {
         WorldItem   bodyOfWaterWorlditem = null;
         BodyOfWater bodyOfWater          = null;
         Ocean       ocean = null;
         if (mWaterHit.collider.attachedRigidbody.gameObject.HasComponent <WorldItem>(out bodyOfWaterWorlditem) && bodyOfWaterWorlditem.Is <BodyOfWater>(out bodyOfWater))
         {
             Water = bodyOfWater;
         }
         else if (mWaterHit.collider.attachedRigidbody.gameObject.HasComponent <Ocean>(out ocean))
         {
             Water = ocean;
         }
         else
         {
             State.IsSubmerged = false;
             enabled           = false;
             return;
         }
     }
 }
Beispiel #13
0
        //this function is meant to be used with the HouseOfHealing skill
        //i've only been able to get this process to work a few times
        //the idea is to super-load the last visited HOH
        //then load its interior and put the player in one of its beds
        //great in theory but in practice something always f***s up
        protected IEnumerator SpawnInClosestStructureOverTime(Vector3 despawnPosition, List <MobileReference> structureReferences, Action <Bed> OnFinishAction)
        {
            if (mSpawningPlayer)
            {
                //whoops
                yield break;
            }
            mSpawningPlayer = true;

            CurrentStartupPosition = null;

            float           closestDistanceSoFar           = Mathf.Infinity;
            StackItem       closestStructureStateSoFar     = null;
            StackItem       currentStructureState          = null;
            MobileReference currentStructureReference      = null;
            MobileReference closestStructureReferenceSoFar = null;
            Vector3         closestStructurePositionSoFar  = despawnPosition;
            WorldChunk      currentChunk = null;

            //find out which structure is the closest
            for (int i = 0; i < structureReferences.Count; i++)
            {
                currentStructureReference = structureReferences [i];
                //Debug.Log ("SPAWNMANAGER: Checking structure reference " + currentStructureReference.FullPath.ToString ());
                if (WIGroups.LoadStackItem(currentStructureReference, out currentStructureState))
                {
                    if (currentStructureState.Is <Structure> ())
                    {
                        //get the chunk for this item
                        if (GameWorld.Get.ChunkByID(currentStructureReference.ChunkID, out currentChunk))
                        {
                            Vector3 structureWorldPosition = WorldChunk.ChunkPositionToWorldPosition(currentChunk.ChunkBounds, currentStructureState.ChunkPosition);
                            structureWorldPosition += currentChunk.ChunkOffset;
                            float currentDistance = Vector3.Distance(despawnPosition, structureWorldPosition);
                            if (currentDistance < closestDistanceSoFar)
                            {
                                closestDistanceSoFar           = currentDistance;
                                closestStructureStateSoFar     = currentStructureState;
                                closestStructureReferenceSoFar = currentStructureReference;
                                closestStructurePositionSoFar  = structureWorldPosition;
                            }
                        }
                    }
                }
            }

            if (closestStructureStateSoFar == null)
            {
                yield break;
            }

            //move the player to the position of the new item
            //this will help us to super-load the structure
            Player.Local.Position = closestStructurePositionSoFar;

            //reset the current loading structure
            mSpawnStructureWorldItem = null;
            Structure spawnStructure = null;
            Bed       loadedBed      = null;

            //super-load the item
            //yield return null;
            //WorldItems.Get.SuspendActiveStateChecking = true;
            StartCoroutine(WIGroups.SuperLoadChildItem(closestStructureReferenceSoFar.GroupPath, closestStructureReferenceSoFar.FileName, SpawnStructureLoaded, 0f));
            WIGroup lastGroupLoaded = null;

            while (mSpawnStructureWorldItem == null)
            {
                yield return(null);
            }

            //WorldItems.Get.SuspendActiveStateChecking = false;
            //okay next we have to load the structure interior
            mSpawnStructureWorldItem.ActiveStateLocked = false;
            mSpawnStructureWorldItem.ActiveState       = WIActiveState.Active;
            mSpawnStructureWorldItem.ActiveStateLocked = true;
            yield return(null);

            //now that the player is where they're supposed to be we can resume active state checking
            //but keep the structure itself locked
            //Player.Local.Position = mSpawnStructureWorldItem.Position;
            //ColoredDebug.Log ("Sending player to spawn structure position " + mSpawnStructureWorldItem.Position.ToString (), "Yellow");

            spawnStructure = mSpawnStructureWorldItem.Get <Structure> ();
            spawnStructure.LoadPriority = StructureLoadPriority.SpawnPoint;
            if (spawnStructure.Is(StructureLoadState.ExteriorUnloaded))
            {
                yield return(StartCoroutine(spawnStructure.CreateStructureGroups(StructureLoadState.ExteriorLoaded)));

                Structures.AddExteriorToLoad(spawnStructure);
                while (spawnStructure.Is(StructureLoadState.ExteriorLoading | StructureLoadState.ExteriorWaitingToLoad))
                {
                    yield return(null);
                }
            }
            if (spawnStructure.Is(StructureLoadState.ExteriorLoaded))
            {
                Structures.AddInteriorToLoad(spawnStructure);
                while (spawnStructure.Is(StructureLoadState.InteriorWaitingToLoad | StructureLoadState.InteriorLoading))
                {
                    yield return(null);
                }
                spawnStructure.RefreshColliders(true);
                spawnStructure.RefreshRenderers(true);
                //finally we search for a bed
            }
            spawnStructure.StructureGroup.Load();
            while (!spawnStructure.StructureGroup.Is(WIGroupLoadState.Loaded))
            {
                yield return(null);
            }

            yield return(null);

            //wait a tick to let the group catch up
            //wait a tick to let the group catch up
            yield return(null);

            List <WorldItem> bedWorldItems = new List <WorldItem> ();

            while (bedWorldItems.Count == 0)
            {
                yield return(StartCoroutine(WIGroups.GetAllChildrenByType(spawnStructure.StructureGroup.Props.PathName, new List <string> ()
                {
                    "Bed"
                }, bedWorldItems, spawnStructure.worlditem.Position, Mathf.Infinity, 1)));

                //can't use WaitForSeconds because timescale will be zero
                double waitUntil = WorldClock.RealTime + 0.1f;
                while (WorldClock.RealTime < waitUntil)
                {
                    yield return(null);
                }
            }

            WorldItem bedWorldItem = bedWorldItems [0];

            while (!bedWorldItem.Is(WILoadState.Initialized))
            {
                yield return(null);
            }
            loadedBed = bedWorldItem.Get <Bed> ();
            //Player.Local.Position = loadedBed.BedsidePosition;
            mSpawningPlayer = false;
            mSpawnStructureWorldItem.ActiveStateLocked = false;
            OnFinishAction(loadedBed);
            Player.Local.Surroundings.StructureEnter(spawnStructure);
            yield break;
        }
Beispiel #14
0
    protected void GainFocusOnObject()
    {
        WorldItem worlditem = gameObject.GetComponent <WorldItem>();

        if (worlditem == null || worlditem.Destroyed)
        {
            return;
        }

        if (mHasAddedFocusMats || !Profile.Get.CurrentPreferences.Immersion.WorldItemOverlay)
        {
            return;
        }

        bool useHighlight = worlditem.CanEnterInventory;
        bool useOutline   = true;      //by default

        if (VRManager.VRMode)
        {
            useHighlight = false;
        }
        else
        {
            for (int i = 0; i < ForceHighlightScripts.Count; i++)
            {
                if (worlditem.Is(ForceHighlightScripts[i]))
                {
                    useHighlight = true;
                    break;
                }
            }
            for (int i = 0; i < ForceNoHighlightScripts.Count; i++)
            {
                if (worlditem.Is(ForceNoHighlightScripts[i]))
                {
                    useHighlight = false;                    //overrides
                    break;
                }
            }
            for (int i = 0; i < ForceNoOutlineScripts.Count; i++)
            {
                if (worlditem.Is(ForceNoOutlineScripts[i]))
                {
                    useOutline = false;
                    break;
                }
            }
        }

        if (MaterialsBeforeFocus == null)
        {
            MaterialsBeforeFocus = new Dictionary <Renderer, List <Material> >();
        }

        for (int i = 0; i < worlditem.Renderers.Count; i++)
        {
            List <Material> preFocusMaterials = null;
            if (!MaterialsBeforeFocus.TryGetValue(worlditem.Renderers[i], out preFocusMaterials))
            {
                preFocusMaterials = new List <Material>();
                MaterialsBeforeFocus.Add(worlditem.Renderers[i], preFocusMaterials);
            }
            else
            {
                preFocusMaterials.Clear();
            }
            preFocusMaterials.AddRange(worlditem.Renderers[i].sharedMaterials);
        }

        if (useHighlight)
        {
            AddMatToRenderers(worlditem.Renderers, Mats.Get.FocusHighlightMaterial, "_TintColor");
        }
        if (useOutline)
        {
            if (CustomMats == null)
            {
                CustomMats = new List <Material>();
            }

            if (worlditem.Props.Global.UseCutoutShader)
            {
                AddCustomMatToRenderers(worlditem.Renderers, Mats.Get.FocusOutlineCutoutMaterial, CustomMats, "_OutlineColor");
            }
            else
            {
                AddMatToRenderers(worlditem.Renderers, Mats.Get.FocusOutlineMaterial, "_OutlineColor");
            }
        }
        mHasAddedFocusMats = true;
    }
Beispiel #15
0
 public bool ControlRestore(double timeStamp)
 {
     if (HasWorldItem)
     {
         Equippable equippable = null;
         if (worlditem.Is <Equippable>(out equippable))
         {
             equippable.RefreshColliders();
         }
     }
     return(true);
 }