public void SendDamageToItem() { while (ItemsOfInterest.Count > 0) { IItemOfInterest itemOfInterest = ItemsOfInterest.Dequeue(); DamagePackage packageCopy = ObjectClone.Clone <DamagePackage>(ExplosionDamage); float adjustedDamage = Mathf.Lerp(ExplosionDamage.DamageSent * ForceAtEdge, ExplosionDamage.DamageSent * ForceAtCenter, NormalizedRadius); packageCopy.DamageSent = adjustedDamage; packageCopy.ForceSent = Mathf.Max(MinimumForce, packageCopy.ForceSent * NormalizedRadius); packageCopy.Point = itemOfInterest.Position; packageCopy.Origin = transform.position; packageCopy.Target = itemOfInterest; //Debug.Log("Force: " + packageCopy.Force.ToString()); DamageManager.Get.SendDamage(packageCopy); //characters and creatures are automatically stunned if (itemOfInterest.IOIType == ItemOfInterestType.WorldItem) { if (itemOfInterest.worlditem.Is <Creature>(out mCreatureCheck)) { mCreatureCheck.TryToStun(adjustedDamage); } else if (itemOfInterest.worlditem.Is <Character>(out mCharacterCheck)) { mCharacterCheck.TryToStun(adjustedDamage); } } } }
public void OnTriggerEnter(Collider other) { if (!IsInEffect) { return; } bool intersection = true; if (RequireLineOfSight) { Debug.Log("Requires line of sight, checking now..."); //check if we can see it RaycastHit hitInfo; if (Physics.Raycast( tr.position, Vector3.Normalize(tr.position - other.transform.position), out hitInfo, Collider.radius * 1.25f, OcclusionLayerMask)) { //we hit one of our occlusion layers on our way to the object //so this doesn't count as a hit intersection = false; } } IItemOfInterest ioi = null; if (WorldItems.GetIOIFromCollider(other, out ioi)) { ItemsOfInterest.SafeEnqueue(ioi); } }
protected void RespondToDamage(IItemOfInterest lastDamageSource, float normalizedDamage, bool isDead) { if (lastDamageSource == null) { Debug.Log("last damage source was null in character"); return; } //see if we were damaged by the player if (lastDamageSource.IOIType == ItemOfInterestType.Player || (lastDamageSource.IOIType == ItemOfInterestType.WorldItem && WorldItems.IsOwnedByPlayer(lastDamageSource.worlditem))) { Profile.Get.CurrentGame.Character.Rep.LosePersonalReputation(worlditem.FileName, worlditem.DisplayName, Globals.ReputationChangeLarge); if (!isDead) { Talkative talkative = worlditem.Get <Talkative> (); talkative.GiveSpeech(Characters.Get.SpeechInResponseToDamage( normalizedDamage, State.KnowsPlayer, Profile.Get.CurrentGame.Character.Rep.GetPersonalReputation(worlditem.FileName), State.GlobalReputation), null); //become hostile if (normalizedDamage > 0.75f) { AttackThing(Player.Local); } } } }
public override WIListOption GetListOption(IItemOfInterest targetObject) { base.GetListOption(targetObject); UsedFireStarter = false; if (Player.Local.Tool.IsEquipped && Player.Local.Tool.worlditem.Is <FireStarter>()) { UsedFireStarter = true; } Flammable flammable = null; if (targetObject.worlditem.Is <Flammable>(out flammable)) { if (flammable.IsOnFire && flammable.CanBeExtinguished) { mListOption.OptionText = "Extinguish Fire"; mListOption.NegateIcon = true; Usage.ProgressDialogMessage = "Extinguishing fire..."; } else if (flammable.CanBeIgnited) { mListOption.OptionText = DisplayName; mListOption.NegateIcon = false; Usage.ProgressDialogMessage = "Starting fire..."; } } return(mListOption); }
public override bool Use(IItemOfInterest targetObject, int flavorIndex) { if (targetObject.IOIType != ItemOfInterestType.WorldItem) { return(false); } PathMarker pathMarker = null; if (targetObject.worlditem.Is <PathMarker> (out pathMarker)) { switch (flavorIndex) { case flavorIndexMove: return(pathMarker.Move()); case flavorIndexRemove: return(pathMarker.RemoveFromPath()); case flavorIndexAdd: break; default: break; } } return(false); }
public override bool Use(IItemOfInterest targetObject, int flavorIndex) { bool result = false; //the target object is going to be a container //get the group owner of the container IStackOwner owner = null; GUIManager.PostDanger("Stole item"); GUIManager.PostDanger("Your crime was imperfect - traces were left behind."); GUIManager.PostDanger("Your reputation has suffered."); if (targetObject.worlditem.Group.HasOwner(out owner)) { //Debug.Log ("Item has owner " + owner.DisplayName); //check if the owner can see the player //use a random skill etc. float skillUseValue = UnityEngine.Random.value; if (skillUseValue > Mathf.Max(State.NormalizedUsageLevel, Globals.SkillFailsafeMasteryLevel)) { OnFailure(); result = false; } OnSuccess(); result = true; } else { //if it has no owner then we're successful by default result = true; } return(result); }
/*UPGRADE / SWAP OPTIONS * Path types: * ------- * Path * Trail * Road * ----- * PathMarker->TrailMarker->RoadMarker * PathMarker->CrossPath * TrailMarker->CrossTrail * RoadMarker->CrossRoad */ public override WIListOption GetListOption(IItemOfInterest targetObject) { //Debug.Log ("Getting list option for improve path"); WIListOption listOption = base.GetListOption(targetObject); listOption.Flavors.Clear(); mLastflavors.Clear(); HashSet <string> flavors = new HashSet <string> (); PathMarker targetPathMarker = null; if (targetObject.worlditem.Is <PathMarker> (out targetPathMarker)) { ImprovePathMarker(targetPathMarker, flavors); } //keep flavors in the dictionary, we don't know which will be relevant //it's only move and swap for now but there may be more int flavorNum = 0; foreach (string flavor in flavors) { //Debug.Log ("Adding flavor " + flavor); listOption.Flavors.Add(flavor); mLastflavors.Add(flavorNum, flavor); flavorNum++; } return(listOption); }
public void OnCollectiveThoughtStart() { if (mDestroyed) { return; } IItemOfInterest itemOfInterest = character.CurrentThought.CurrentItemOfInterest; switch (itemOfInterest.IOIType) { case ItemOfInterestType.Player: break; case ItemOfInterestType.Scenery: break; case ItemOfInterestType.WorldItem: if (itemOfInterest.worlditem.StackName.Contains("Wood Dummy")) { character.AttackThing(itemOfInterest); } else if (itemOfInterest.worlditem.Is <Obstruction>()) { character.AttackThing(itemOfInterest); } break; default: break; } }
protected void SetPrimaryTarget(IItemOfInterest newTarget) { if (newTarget == null) { return; } if (mFinished || Mode == HostileMode.CoolingOff) { return; } if (newTarget == mPrimaryTarget) { return; } mPrimaryTarget = newTarget; mCanSeePrimaryTarget = true; //set true for default now mTimeLastSawPrimaryTarget = WorldClock.AdjustedRealTime; Watch(); enabled = true; }
public override bool DoesContextAllowForUse(IItemOfInterest targetObject) { if (base.DoesContextAllowForUse(targetObject)) { Bandit bandit = null; if (targetObject.worlditem.Is <Bandit> (out bandit) && !bandit.WillAssociateWithPlayer) { return(false); } Character character = null; if (targetObject.worlditem.Is <Character> (out character)) { if (character.IsDead || character.IsStunned) { Debug.Log("Can't barter with dead characters"); return(false); } else if (targetObject.worlditem.Is <Hostile> ()) { return(false); } else { return(true); } } else { return(false); } } return(false); }
public bool CanSeeItemOfInterest(IItemOfInterest itemOfInterest, bool requireFieldOfView) { //if it's a visible item //we'll want to access its visibility modifiers IVisible mVisibleItemCheck = (IVisible)itemOfInterest; if (mVisibleItemCheck != null) { return(CanSeeVisibleItem(mVisibleItemCheck, requireFieldOfView)); } //otherwise we'll just check the item without multipliers //we calculate this every time because it could change due to external modifiers float mAwarenessDistance = Looker.AwarenessDistanceTypeToVisibleDistance(State.AwarenessDistance); if (State.ManualAwarenessDistance > 0) { mAwarenessDistance = State.ManualAwarenessDistance; } if (Looker.IsInVisibleRange(worlditem.Position, itemOfInterest.Position, mAwarenessDistance)) { if (!requireFieldOfView || Looker.IsInFieldOfView(worlditem.tr.forward, worlditem.Position, State.FieldOfView, itemOfInterest.Position)) { //it's in our field of view AND it's close enough to see //check to see if we can see it with the visible item's modifiers in place return(true); } } return(false); }
public void OnTriggerExit(Collider other) { if (VisitableLocation == null || !VisitableLocation.Initialized) { return; } if (other.isTrigger) { return; } if (other.gameObject.layer == Globals.LayerNumPlayer) { VisitableLocation.PlayerLeave(); if (VisitableLocation.PlayerOnly) { return; } } //do we care about any world items? if (other.gameObject.layer == Globals.LayerNumWorldItemActive && VisitableLocation.ItemsOfInterest.Count > 0) { mIoiCheck = null; if (WorldItems.GetIOIFromCollider(other, out mIoiCheck) && mIoiCheck.IOIType == ItemOfInterestType.WorldItem && mIoiCheck.worlditem.HasAtLeastOne(VisitableLocation.ItemsOfInterest)) { VisitableLocation.ItemOfInterestLeave(mIoiCheck.worlditem); } } }
public void AttackThing(IItemOfInterest itemOfInterest) { if (Profile.Get.CurrentGame.Difficulty.IsDefined("NoHostileCreatures")) { return; } Body.EyeMode = BodyEyeMode.Hostile; Hostile hostile = null; if (!worlditem.Is <Hostile> (out hostile)) { hostile = worlditem.GetOrAdd <Hostile> (); //copy the properties quickly Reflection.CopyProperties(Template.HostileTemplate, hostile.State); //copy the attacks directly hostile.TerritoryBase = Den; hostile.State.Attack1 = ObjectClone.Clone <AttackStyle> (Template.HostileTemplate.Attack1); hostile.State.Attack2 = ObjectClone.Clone <AttackStyle> (Template.HostileTemplate.Attack2); hostile.OnAttack1Start += OnAttack1; hostile.OnAttack2Start += OnAttack2; hostile.OnWarn += OnWarn; hostile.OnCoolOff += OnCoolOff; } if (!hostile.HasPrimaryTarget || hostile.PrimaryTarget != itemOfInterest) { hostile.PrimaryTarget = itemOfInterest; } hostile.RefreshAttackSettings(); Body.Animator.Idling = false; }
public SubmergedObject(IItemOfInterest seeker, IItemOfInterest target, float timeEnteredWater) { Seeker = seeker; Target = target; TimeEnteredWater = timeEnteredWater; TimeExitedWater = -1f; }
public bool SortSubmergedObjects(IItemOfInterest seeker, double interestInterval, out SubmergedObject subjergedObject) { subjergedObject = null; for (int i = SubmergedObjects.LastIndex(); i >= 0; i--) { SubmergedObject subObj = SubmergedObjects [i]; if (subObj == null || subObj.Target == null || subObj.Target.Destroyed || (subObj.Target.IOIType == ItemOfInterestType.WorldItem && subObj.Target.worlditem.Is <WaterTrap> ())) { SubmergedObjects.RemoveAt(i); } else { subObj.Seeker = seeker; if (subObj.Target.IOIType == ItemOfInterestType.Scenery) { //it's probably a fish or something //there's a very low probability that we care if (UnityEngine.Random.value < 0.0005f) { subObj.IsOfInterest = true; } else { subObj.IsOfInterest = false; SubmergedObjects.RemoveAt(i); } } else if (subObj.HasExitedWater && (WorldClock.AdjustedRealTime - subObj.TimeExitedWater) > interestInterval) { //just in case we're already targeting a submerged object subObj.IsOfInterest = false; SubmergedObjects.RemoveAt(i); } else if (subObj.Target.IOIType == ItemOfInterestType.Player && subObj.Target.player.IsDead) { subObj.IsOfInterest = false; SubmergedObjects.RemoveAt(i); } else if (subObj.Target.Position.y > Biomes.Get.TideWaterElevation) { //if the target's position is higher than the water position then it can't be underwater subObj.IsOfInterest = true; SubmergedObjects.RemoveAt(i); } else { subObj.IsOfInterest = true; } } } if (SubmergedObjects.Count > 0) { SubmergedObjects.Sort(); if (SubmergedObjects [0].IsOfInterest) { subjergedObject = SubmergedObjects [0]; } } return(subjergedObject != null); }
public void OnIntersectItemOfInterest() { if (!IsInUse) { return; } if (!string.IsNullOrEmpty(Extensions.AddComponentOnUse)) { while (SkillSphere.ItemsOfInterest.Count > 0) { IItemOfInterest ioi = SkillSphere.ItemsOfInterest.Dequeue(); //see if this is what we want if (ioi != null) { if (!(Extensions.IgnoreCaster && ioi.IOIType == ItemOfInterestType.Player && ioi.player == Player.Local)) { if (Flags.Check((uint)ioi.IOIType, (uint)Usage.TargetItemsOfInterest, Flags.CheckType.MatchAny) && ioi.HasAtLeastOne(Usage.TargetWIScriptNames)) { OnIntersectTarget(ioi); } } } } } }
public void OnTriggerExit(Collider other) { if (other.isTrigger || !GameManager.Is(FGameState.InGame)) { return; } IItemOfInterest ioi = null; if (WorldItems.GetIOIFromCollider(other, out ioi)) { if (LastExitedItemOfInterest != ioi) { LastExitedItemOfInterest = ioi; if (ioi.IOIType == ItemOfInterestType.Player) { Debug.Log("Player exited water in 'WaterSubmergeObjects'"); Player.Get.AvatarActions.ReceiveAction(AvatarAction.MoveExitWater, WorldClock.AdjustedRealTime); } else if (ioi.IOIType == ItemOfInterestType.WorldItem && ioi.worlditem.Is(WILoadState.Initialized)) { ioi.worlditem.OnExitBodyOfWater.SafeInvoke(); } OnItemOfInterestExitWater.SafeInvoke(); if (LastSubmergedItemOfInterest == ioi) { LastSubmergedItemOfInterest = null; } } } }
public bool AttackThingAction(IItemOfInterest itemOfInterest) { bool result = false; Hostile hostile = null; if (!worlditem.Is <Hostile> (out hostile)) { hostile = worlditem.GetOrAdd <Hostile> (); //copy the properties quickly Reflection.CopyProperties(Template.HostileTemplate, hostile.State); //copy the attacks directly hostile.TerritoryBase = TerritoryBase; hostile.State.Attack1 = ObjectClone.Clone <AttackStyle> (Template.HostileTemplate.Attack1); hostile.State.Attack2 = ObjectClone.Clone <AttackStyle> (Template.HostileTemplate.Attack2); hostile.OnAttack1Start += OnAttack1; hostile.OnAttack2Start += OnAttack2; hostile.OnWarn += OnWarn; hostile.OnCoolOff += OnCoolOff; result = true; } if (!hostile.HasPrimaryTarget || hostile.PrimaryTarget != itemOfInterest) { hostile.PrimaryTarget = itemOfInterest; result = true; } animator.Idling = false; animator.WeaponMode = CharacterWeaponMode.BareHands; return(false); }
public override bool Use(IItemOfInterest targetObject, int flavorIndex) { //first check if we're dealing directly with a barterable object IInventory barterInventory = targetObject.gameObject.GetComponent("IInventory") as IInventory; Container container = null; Character character = null; if (barterInventory == null) { //if not, check if we're dealing with an owned container if (targetObject.IOIType == ItemOfInterestType.WorldItem && targetObject.worlditem.Is <Container> (out container)) { //get the owner of the container IStackOwner owner = null; if (targetObject.worlditem.Group.HasOwner(out owner) && owner.IsWorldItem) { barterInventory = (IInventory)owner.worlditem.GetComponent(typeof(IInventory)); } else //if the owner isn't a world item then it hasn't been loaded //TODO handle unloaded shop owners { } character = owner.worlditem.Get <Character> (); } } else { character = targetObject.worlditem.Get <Character> (); } if (character != null) { ReputationState rep = Profile.Get.CurrentGame.Character.Rep.GetReputation(character.worlditem.FileName); if (rep.NormalizedReputationDifference(Profile.Get.CurrentGame.Character.Rep.GlobalReputation) > Extensions.MaxNormaliedReputationDifference) { GUIManager.PostWarning(character.worlditem.DisplayName + " is not interested in bartering with you."); return(false); } } if (barterInventory != null) { if (mCurrentSession == null) { mCurrentSession = new BarterSession(this, mCharacterGoods, mPlayerGoods); } mCurrentSession.Reset(Player.Local.Inventory, barterInventory); mCurrentSession.BarteringCharacter = character; if (flavorIndex > 0) { //flavor 0 is default mode //flavor 1 is zero cost mode (friends, multiplayer, etc) mCurrentSession.ZeroCostMode = true; } SpawnBarterDialog(); return(true); } return(false); }
public GameObject SpawnFX(IItemOfInterest parentObject, string fxName) { if (parentObject != null) { return(SpawnFX(parentObject.gameObject, fxName)); } return(null); }
public void InstantKill(IItemOfInterest causeOfDeath) { Debug.Log("Instant kill in damageable"); State.LastDamageTaken = Mathf.Clamp((State.Durability - State.DamageTaken), 0f, Mathf.Infinity); State.LastDamagePoint = transform.position; State.LastDamageMaterial = WIMaterialType.None; OnDieResult(); }
public override bool Use(IItemOfInterest targetObject, int flavorIndex) { if (IsInUse || !RequirementsMet) { return(false); } StartCoroutine(DetectOverTime()); return(true); }
public static void MakeWorldSound(IItemOfInterest source, MasterAudio.SoundType soundType, string soundName) { IAudible audibleSource = (IAudible)source.gameObject.GetComponent(typeof(IAudible)); if (audibleSource != null) { MakeWorldSound(audibleSource, soundType, soundName); } }
protected void Trigger(IItemOfInterest target) { Debug.Log("Triggering on target"); MasterAudio.PlaySound(MasterAudio.SoundType.Machines, transform, "HuntingTrapTrigger"); //AUGH we're damaged State.NumTimesTriggered++; PlayAnimation(AnimationCloseClipName); Mode = TrapMode.Triggered; }
public void Refresh(Vector3 origin, Vector3 attackPoint, string senderName, IItemOfInterest target) { Damage.DamageSent = UnityEngine.Random.Range(MinDamage, MaxDamage); Damage.SenderMaterial = AttackSourceMaterial; Damage.Origin = origin; Damage.Point = attackPoint; Damage.SenderName = senderName; Damage.Target = target; }
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); }
public virtual bool Use(IItemOfInterest targetObject, int flavorIndex) { if (targetObject.IOIType == ItemOfInterestType.Player) { RespawnPlayer(Player.Local); //todo make it work with anything return(true); } return(base.Use(flavorIndex)); }
public override WIListOption GetListOption(IItemOfInterest targetObject) { WIListOption option = base.GetListOption(targetObject); option.Flavors.Clear(); option.OptionText = "Barter"; option.DefaultFlavorIndex = -1; option.Disabled = false; //barter targets the owner of objects, not the object itself, so check if the owner is a shop owner if (targetObject.IOIType == ItemOfInterestType.WorldItem && targetObject.worlditem.Is <ShopOwner> ()) { //only do this if it's an actual worlditem //get the thing we're focusing on if (Player.Local.Surroundings.IsWorldItemInRange && !Player.Local.Surroundings.WorldItemFocus.worlditem.Is <OwnedByPlayer> () && Player.Local.Surroundings.WorldItemFocus.worlditem != targetObject.worlditem) { option.DefaultFlavorIndex = BuyFlavor; option.OptionText = "Buy for $" + Player.Local.Surroundings.WorldItemFocus.worlditem.BaseCurrencyValue.ToString(); } } else { //don't make it possible to barter for books BookAvatar bookAvatar = null; try { if (Player.Local.Surroundings.WorldItemFocus.worlditem.Is <BookAvatar> (out bookAvatar) && !bookAvatar.worlditem.Is <OwnedByPlayer> ()) { option.DefaultFlavorIndex = BuyFlavor; Book b = null; if (Books.Get.BookByName(bookAvatar.State.BookName, out b)) { if (b.TypeOfBook == BookType.Diary) { //can't buy diaries option.Disabled = true; option.OptionText = "Won't sell"; } else { option.OptionText = "Buy for $" + Player.Local.Surroundings.WorldItemFocus.worlditem.BaseCurrencyValue.ToString(); } } else { option.Disabled = true; } } } catch (Exception e) { Debug.Log("Couldn't get option because: " + e.ToString()); option.Disabled = true; } } return(option); }
public virtual void Initialize(IItemOfInterest bodyPartOwner) { if (mInitialized) { return; } gameObject.tag = "BodyGeneral"; //if we haven't created our main texture set it now if (mMainMaterial == null) { //TEMP //TODO figure this out another way try { MainMaterial = Renderers [0].material; } catch (Exception e) { //Debug.LogError (e); } } for (int i = 0; i < BodyParts.Count; i++) { //if this is set to null the body part will set its tag so that it won't be recognized BodyParts [i].Initialize(bodyPartOwner, BodyParts); } for (int i = 0; i < BodyParts.Count; i++) { for (int j = 0; j < BodyParts.Count; j++) { if (i != j) { #if UNITY_EDITOR if (BodyParts [i] == BodyParts [j]) { Debug.Log("Body part was the same in world body " + name); } #endif Physics.IgnoreCollision(BodyParts [i].PartCollider, BodyParts [j].PartCollider); } } } if (EyeRenderers.Count > 0) { EyeMaterial = EyeRenderers [0].material; for (int i = 0; i < EyeRenderers.Count; i++) { EyeRenderers [i].sharedMaterial = EyeMaterial; } } RefreshShadowCasters(); mInitialized = true; }
public override bool CanBePlacedOn(IItemOfInterest targetObject, Vector3 point, Vector3 normal, ref string errorMessage) { bool isPermitted = true; if (PermittedTargetScripts.Count > 0) { isPermitted &= targetObject.HasAtLeastOne(PermittedTargetScripts); } return(isPermitted); }