Beispiel #1
0
        public void ActivateInspector(ResourceActivationContext context, ObjectInspector inspector)
        {
            if (inspector.TargetReferences != null)
            {
                string targetId     = null;
                string targetAction = null;

                foreach (var reference in inspector.TargetReferences)
                {
                    var id = context.GetInstanceId(reference.ObjectId);

                    if (targetId == null && m_objectActions.GetCount(id) > 0)
                    {
                        // TODO: inspectors should define this action
                        targetAction = m_objectActions[id].First();
                        targetId     = id;
                    }

                    m_inspectors.Add(id, context);
                }

                // No current object or current object is the same as targetId
                if (targetId != null)
                {
                    if (m_currObjId == null ||
                        m_currObjId == targetId)
                    {
                        // Actions stored in m_objectActions are never one-shot
                        ApplyObjectAction(targetId, targetAction, false);
                    }
                }
            }
        }
        public void RemoveEffects(ResourceActivationContext context, WorldObjectEffectPlayer resource)
        {
            if (m_effects.ContainsKey(context.InstanceId))
            {
                var effects = m_effects[context.InstanceId];

                if (effects != null)
                {
                    foreach (var effect in effects)
                    {
                        GameObject.Destroy(effect);
                    }
                }
            }

            if (resource.WorldObjectReferences != null)
            {
                foreach (var objRef in resource.WorldObjectReferences)
                {
                    var instId = context.GetInstanceId(objRef.ObjectId);

                    m_pendingEffects.RemoveAll(instId);
                }
            }

            m_effects.RemoveAll(context.InstanceId);
        }
        public void ApplyEffects(ResourceActivationContext context, WorldObjectEffectPlayer resource)
        {
            if (resource.WorldObjectReferences != null &&
                resource.Effects != null)
            {
                foreach (var wo in resource.WorldObjectReferences)
                {
                    var instId = context.GetInstanceId(wo.ObjectId);

                    var worldObjs = m_worldObjects[instId];

                    if (worldObjs != null)
                    {
                        foreach (var worldObj in worldObjs)
                        {
                            ApplyEffects(worldObj, context, resource);
                        }
                    }
                    else
                    {
                        m_pendingEffects.Add(instId, new ActiveResourceContainer <WorldObjectEffectPlayer>(context, resource));
                    }
                }
            }
        }
Beispiel #4
0
        public void DeactivateInspector(ResourceActivationContext context, ObjectInspector inspector)
        {
            if (inspector.TargetReferences != null)
            {
                foreach (var reference in inspector.TargetReferences)
                {
                    var id = context.GetInstanceId(reference.ObjectId);

                    m_inspectors.Remove(id, context);
                }
            }
        }
Beispiel #5
0
        public void RemoveEffects(ResourceActivationContext context, WorldObjectEffectPlayer resource)
        {
            var appliedEffects = m_appliedEffects[context.InstanceId];

            if (appliedEffects != null)
            {
                foreach (var effect in appliedEffects)
                {
                    effect.Handler.RemoveEffect(effect);
                }
            }

            if (resource.WorldObjectReferences != null)
            {
                foreach (var objRef in resource.WorldObjectReferences)
                {
                    var objInstId = context.GetInstanceId(objRef.ObjectId);

                    m_pendingEffects.RemoveAll(objInstId);
                }
            }

            m_appliedEffects.RemoveAll(context.InstanceId);
        }