Esempio n. 1
0
        public void CreateInspiredReactable(Artable.Status status)
        {
            switch (status)
            {
            case Artable.Status.Ugly:
                effect = inspired1;
                break;

            case Artable.Status.Okay:
                effect = inspired2;
                break;

            default:
                effect = inspired3;
                break;
            }
            if (fossilReactable == null)
            {
                fossilReactable = new EmoteReactable(gameObject, "Inspired", Db.Get().ChoreTypes.Emote, "anim_react_starry_eyes_kanim", 15, 8, 0, 10f, float.PositiveInfinity)
                                  .AddThought(Db.Get().Thoughts.Angry);

                /*.AddStep(new EmoteReactable.EmoteStep
                 * {
                 *  anim = "react",
                 *  startcb = new Action<GameObject>(AddReactionEffect)
                 * });*/
                //.AddThought(Db.Get().Thoughts.Happy);
                //.AddPrecondition(new Reactable.ReactablePrecondition(ReactorIsOnFloor));
            }
        }
Esempio n. 2
0
 protected override void OnCleanUp()
 {
     if (fossilReactable != null)
     {
         fossilReactable.Cleanup();
         fossilReactable = null;
     }
 }
Esempio n. 3
0
 public EffectInstance(GameObject game_object, Effect effect, bool should_save)
     : base(game_object, effect)
 {
     this.effect = effect;
     shouldSave  = should_save;
     ConfigureStatusItem();
     if (effect.showInUI)
     {
         KSelectable component = base.gameObject.GetComponent <KSelectable>();
         if (!component.GetStatusItemGroup().HasStatusItemID(statusItem))
         {
             component.AddStatusItem(statusItem, this);
         }
     }
     if (effect.triggerFloatingText && (Object)PopFXManager.Instance != (Object)null)
     {
         PopFXManager.Instance.SpawnFX(PopFXManager.Instance.sprite_Plus, effect.Name, game_object.transform, 1.5f, false);
     }
     if (!string.IsNullOrEmpty(effect.emoteAnim))
     {
         ReactionMonitor.Instance sMI = base.gameObject.GetSMI <ReactionMonitor.Instance>();
         if (sMI != null)
         {
             if (effect.emoteCooldown < 0f)
             {
                 SelfEmoteReactable selfEmoteReactable = (SelfEmoteReactable) new SelfEmoteReactable(game_object, effect.Name + "_Emote", Db.Get().ChoreTypes.Emote, effect.emoteAnim, 100000f, 20f, float.PositiveInfinity).AddStep(new EmoteReactable.EmoteStep
                 {
                     anim = (HashedString)"react"
                 });
                 selfEmoteReactable.AddPrecondition(NotInATube);
                 if (effect.emotePreconditions != null)
                 {
                     foreach (Reactable.ReactablePrecondition emotePrecondition in effect.emotePreconditions)
                     {
                         selfEmoteReactable.AddPrecondition(emotePrecondition);
                     }
                 }
                 sMI.AddOneshotReactable(selfEmoteReactable);
             }
             else
             {
                 reactable = new SelfEmoteReactable(game_object, effect.Name + "_Emote", Db.Get().ChoreTypes.Emote, effect.emoteAnim, effect.emoteCooldown, 20f, float.PositiveInfinity).AddStep(new EmoteReactable.EmoteStep
                 {
                     anim = (HashedString)"react"
                 });
                 reactable.AddPrecondition(NotInATube);
                 if (effect.emotePreconditions != null)
                 {
                     foreach (Reactable.ReactablePrecondition emotePrecondition2 in effect.emotePreconditions)
                     {
                         reactable.AddPrecondition(emotePrecondition2);
                     }
                 }
             }
         }
     }
 }
Esempio n. 4
0
 protected override void OnSpawn()
 {
     base.OnSpawn();
     base.smi.StartSM();
     if (info != null)
     {
         SetAnimToInfo();
     }
     reactable = CreateReactable();
 }
Esempio n. 5
0
 public override void OnCleanUp()
 {
     if (statusItem != null)
     {
         KSelectable component = base.gameObject.GetComponent <KSelectable>();
         component.RemoveStatusItem(statusItem, false);
         statusItem = null;
     }
     if (reactable != null)
     {
         reactable.Cleanup();
         reactable = null;
     }
 }
Esempio n. 6
0
    void RemoveReactable(Reactable reactable)
    {
        int id    = reactable.gameObject.GetInstanceID();
        int layer = 0;

        if (_reactableToLayer.TryGetValue(id, out layer))
        {
            Dictionary <int, GameObject> reactablesInLayer;
            if (_reactables.TryGetValue(layer, out reactablesInLayer))
            {
                reactablesInLayer.Remove(id);
                _reactableToLayer.Remove(id);
            }
        }
    }
Esempio n. 7
0
    bool TryGetReactable(GameObject gameObject, out Reactable reactable)
    {
        reactable = null;

        // This is a way to discover objects that should be reactable but doesn't have the react script assigned
        if (gameObject.tag == "Reactable")
        {
            reactable = gameObject.GetComponent <Reactable>();
            if (reactable == null)
            {
                Debug.Log(gameObject.name + " should have reactable script attached!!!");
            }
        }

        return(reactable != null);
    }
Esempio n. 8
0
    public void AddComponentsIfMissing(Reactable reactable = null)
    {
        if (reactable == null) reactable = this.reactable;

        if(reactable == null)
            Debug.LogError("Unable to add fill code with proper init component");
        /*if (reactable != null) {
            foreach (var b in reactable.behaviourTypes) {
                if (gameObject.GetComponent(b) == false) {
                    var c = UnityEngineInternal.APIUpdaterRuntimeServices.AddComponent(gameObject, "Assets/AI/React/Scripts/Reactor.cs (74,29)", b);
                    AddMethodsFromComponent(c);
                    var behaviour = c as Behaviour;
                    if (behaviour != null)
                        behaviour.Initialize();
                }
            }
        }*/
    }
Esempio n. 9
0
        public void PollForReactables(Navigator.ActiveTransition transition)
        {
            if (!IsReacting())
            {
                if (justReacted)
                {
                    justReacted = false;
                }
                else
                {
                    lastReactable = null;
                }
                for (int num = oneshotReactables.Count - 1; num >= 0; num--)
                {
                    Reactable reactable = oneshotReactables[num];
                    if (reactable.IsExpired())
                    {
                        reactable.Cleanup();
                    }
                }
                int cell = Grid.PosToCell(base.smi.gameObject);
                ListPool <ScenePartitionerEntry, ReactionMonitor> .PooledList pooledList = ListPool <ScenePartitionerEntry, ReactionMonitor> .Allocate();

                GameScenePartitioner instance = GameScenePartitioner.Instance;
                Vector2I             vector2I = Grid.CellToXY(cell);
                int      x         = vector2I.x;
                Vector2I vector2I2 = Grid.CellToXY(cell);
                instance.GatherEntries(x, vector2I2.y, 1, 1, GameScenePartitioner.Instance.objectLayers[0], pooledList);
                for (int i = 0; i < pooledList.Count; i++)
                {
                    Reactable reactable2 = pooledList[i].obj as Reactable;
                    if (reactable2 != null && reactable2 != lastReactable && (!lastReactTimes.ContainsKey(reactable2.id) || !(GameClock.Instance.GetTime() - lastReactTimes[reactable2.id] < reactable2.minReactorTime)) && reactable2.CanBegin(base.gameObject, transition))
                    {
                        justReacted   = true;
                        lastReactable = reactable2;
                        lastReactTimes[reactable2.id] = GameClock.Instance.GetTime();
                        base.sm.reactable.Set(reactable2, base.smi);
                        base.smi.GoTo(base.sm.reacting);
                        break;
                    }
                }
                pooledList.Recycle();
            }
        }
Esempio n. 10
0
    void AddReactable(Reactable reactable)
    {
        int layer = reactable.Layer;
        Dictionary <int, GameObject> reactablesInLayer;

        if (!_reactables.TryGetValue(layer, out reactablesInLayer))
        {
            reactablesInLayer  = new Dictionary <int, GameObject>();
            _reactables[layer] = reactablesInLayer;
        }

        int id = reactable.gameObject.GetInstanceID();

        if (!reactablesInLayer.ContainsKey(id))
        {
            reactablesInLayer.Add(id, reactable.gameObject);
            _reactableToLayer.Add(id, layer);
        }
    }
Esempio n. 11
0
 void Load(Reactable asset)
 {
     reactable = asset;
     if (reactable != null) {
         if (reactable.json != null && reactable.json.Length > 0) {
             root = (Root)React.JsonSerializer.Decode (reactable.json);
             BaseNode.hotNode = root;
             BaseNode.editorReactable = reactable;
         } else {
             root = new Root ();
             BaseNode.hotNode = root;
             BaseNode.editorReactable = reactable;
         }
     }
 }
 public void SetReactable(Reactable reactable)
 {
     this.reactable = reactable;
 }
 public GreetingUnit(MinionIdentity minion, Reactable reactable)
 {
     this.minion    = minion;
     this.reactable = reactable;
 }
Esempio n. 14
0
 protected override void OnSpawn()
 {
     base.OnSpawn();
     reactable = Decomposition.CreateRottenReactable(gameObject);
     GetComponent <KSelectable>().AddStatusItem(Db.Get().DuplicantStatusItems.Rotten);
 }