Exemplo n.º 1
0
 protected override void Begin()
 {
     base.Begin();
     if (this.eCratePush == null || this.eCratePush.Dead)
     {
         this.eCratePush = SoundEffectExtensions.EmitAt(this.sCratePush, this.PlayerManager.PushedInstance.Center, true);
     }
     else
     {
         this.eCratePush.Cue.Resume();
     }
     if (this.eGomezPush == null || this.eGomezPush.Dead)
     {
         this.eGomezPush = SoundEffectExtensions.EmitAt(this.sGomezPush, this.PlayerManager.Position, true);
     }
     else
     {
         this.eGomezPush.Cue.Resume();
     }
     if (this.LevelManager.PickupGroups.TryGetValue(this.PlayerManager.PushedInstance, out this.pickupGroup))
     {
         return;
     }
     this.pickupGroup = (TrileGroup)null;
 }
Exemplo n.º 2
0
        private void TryPushHorizontalStack(PickupState state, float elapsedSeconds)
        {
            TrileInstance trileInstance1 = state.Instance;
            TrileGroup    trileGroup     = state.Group;

            if (!BoxCollisionResultExtensions.AnyCollided(trileInstance1.PhysicsState.WallCollision))
            {
                return;
            }
            Vector3 vector3_1 = -FezMath.Sign(trileInstance1.PhysicsState.WallCollision.First.Response);

            trileInstance1.PhysicsState.Velocity = Vector3.Zero;
            TrileInstance instance = trileInstance1;

            while (instance != null && BoxCollisionResultExtensions.AnyCollided(instance.PhysicsState.WallCollision))
            {
                MultipleHits <CollisionResult> wallCollision = instance.PhysicsState.WallCollision;
                TrileInstance trileInstance2 = wallCollision.First.Destination;
                if (trileInstance2.PhysicsState != null && ActorTypeExtensions.IsPickable(trileInstance2.Trile.ActorSettings.Type) && (trileGroup == null || !trileGroup.Triles.Contains(trileInstance2)))
                {
                    Vector3 vector = -wallCollision.First.Response;
                    if (FezMath.Sign(vector) != vector3_1 || vector == Vector3.Zero)
                    {
                        instance = (TrileInstance)null;
                    }
                    else
                    {
                        instance = trileInstance2;
                        Vector3 velocity = instance.PhysicsState.Velocity;
                        instance.PhysicsState.Velocity = vector;
                        Vector3 center = instance.PhysicsState.Center;
                        if (instance.PhysicsState.Grounded)
                        {
                            instance.PhysicsState.Velocity += (float)(3.15000009536743 * (double)Math.Sign(this.CollisionManager.GravityFactor) * 0.150000005960464) * elapsedSeconds * Vector3.Down;
                        }
                        this.PhysicsManager.Update((ISimplePhysicsEntity)instance.PhysicsState, false, false);
                        if (trileInstance1.PhysicsState.Grounded)
                        {
                            instance.PhysicsState.Velocity = velocity;
                        }
                        instance.PhysicsState.UpdateInstance();
                        this.LevelManager.UpdateInstance(instance);
                        foreach (PickupState pickupState in this.PickupStates)
                        {
                            if (pickupState.Instance.PhysicsState.Ground.NearLow == instance || pickupState.Instance.PhysicsState.Ground.FarHigh == instance)
                            {
                                Vector3 vector3_2 = (instance.PhysicsState.Center - center) / 0.85f;
                                pickupState.Instance.PhysicsState.Velocity = vector3_2;
                            }
                        }
                    }
                }
                else
                {
                    instance = (TrileInstance)null;
                }
            }
        }
Exemplo n.º 3
0
            public ValveState(ValvesBoltsTimeswitchesHost host, ArtObjectInstance ao)
            {
                ServiceHelper.InjectServices((object)this);
                this.Host         = host;
                this.ArtObject    = ao;
                this.IsBolt       = this.ArtObject.ArtObject.ActorType == ActorType.BoltHandle;
                this.IsTimeswitch = this.ArtObject.ArtObject.ActorType == ActorType.Timeswitch;
                BoundingBox boundingBox = new BoundingBox(this.ArtObject.Position - this.ArtObject.ArtObject.Size / 2f, this.ArtObject.Position + this.ArtObject.ArtObject.Size / 2f);

                if (this.ArtObject.ActorSettings.AttachedGroup.HasValue)
                {
                    this.AttachedGroup = this.LevelManager.Groups[this.ArtObject.ActorSettings.AttachedGroup.Value];
                }
                if (this.IsTimeswitch)
                {
                    this.eTimeswitchWindBack = SoundEffectExtensions.EmitAt(this.Host.TimeswitchWindBackSound, ao.Position, true, true);
                    foreach (ArtObjectInstance artObjectInstance in (IEnumerable <ArtObjectInstance>) this.LevelManager.ArtObjects.Values)
                    {
                        if (artObjectInstance != ao && artObjectInstance.ArtObject.ActorType == ActorType.TimeswitchMovingPart)
                        {
                            BoundingBox box = new BoundingBox(artObjectInstance.Position - artObjectInstance.ArtObject.Size / 2f, artObjectInstance.Position + artObjectInstance.ArtObject.Size / 2f);
                            if (boundingBox.Intersects(box))
                            {
                                this.TimeswitchScrewAo = artObjectInstance;
                                break;
                            }
                        }
                    }
                }
                int num1;

                if (!this.IsBolt && !this.IsTimeswitch && (this.GameState.SaveData.ThisLevel.PivotRotations.TryGetValue(this.ArtObject.Id, out num1) && num1 != 0))
                {
                    int num2 = Math.Abs(num1);
                    int num3 = Math.Sign(num1);
                    for (int index = 0; index < num2; ++index)
                    {
                        this.ArtObject.Rotation *= Quaternion.CreateFromAxisAngle(Vector3.UnitY, 1.570796f * (float)num3);
                    }
                }
                if (this.IsBolt)
                {
                    foreach (TrileInstance instance in this.AttachedGroup.Triles)
                    {
                        instance.PhysicsState = new InstancePhysicsState(instance);
                    }
                }
                foreach (Volume volume in (IEnumerable <Volume>) this.LevelManager.Volumes.Values)
                {
                    Vector3 vector3 = FezMath.Abs(volume.To - volume.From);
                    if ((double)vector3.X == 3.0 && (double)vector3.Z == 3.0 && ((double)vector3.Y == 1.0 && boundingBox.Contains(volume.BoundingBox) == ContainmentType.Contains))
                    {
                        this.CenterOffset = (volume.From + volume.To) / 2f - this.ArtObject.Position;
                        break;
                    }
                }
            }
Exemplo n.º 4
0
            public PivotState(PivotsHost host, ArtObjectInstance handleAo)
            {
                ServiceHelper.InjectServices((object)this);
                this.Host               = host;
                this.HandleAo           = handleAo;
                this.Group              = this.LevelManager.Groups[handleAo.ActorSettings.AttachedGroup.Value];
                this.AttachedArtObjects = Enumerable.ToArray <ArtObjectInstance>(Enumerable.Where <ArtObjectInstance>((IEnumerable <ArtObjectInstance>) this.LevelManager.ArtObjects.Values, (Func <ArtObjectInstance, bool>)(x =>
                {
                    int?local_0 = x.ActorSettings.AttachedGroup;
                    int local_1 = this.Group.Id;
                    if ((local_0.GetValueOrDefault() != local_1 ? 0 : (local_0.HasValue ? 1 : 0)) != 0)
                    {
                        return(x != this.HandleAo);
                    }
                    else
                    {
                        return(false);
                    }
                })));
                this.AttachedAoOrigins   = Enumerable.ToArray <Vector3>(Enumerable.Select <ArtObjectInstance, Vector3>((IEnumerable <ArtObjectInstance>) this.AttachedArtObjects, (Func <ArtObjectInstance, Vector3>)(x => x.Position)));
                this.AttachedAoRotations = Enumerable.ToArray <Quaternion>(Enumerable.Select <ArtObjectInstance, Quaternion>((IEnumerable <ArtObjectInstance>) this.AttachedArtObjects, (Func <ArtObjectInstance, Quaternion>)(x => x.Rotation)));
                foreach (TrileInstance trileInstance in this.Group.Triles)
                {
                    trileInstance.ForceSeeThrough = true;
                }
                float num = Enumerable.Max <TrileInstance>(Enumerable.Where <TrileInstance>((IEnumerable <TrileInstance>) this.Group.Triles, (Func <TrileInstance, bool>)(x => !x.Trile.Immaterial)), (Func <TrileInstance, float>)(x => x.Position.Y));

                foreach (TrileInstance trileInstance in this.Group.Triles)
                {
                    if ((double)trileInstance.Position.Y == (double)num)
                    {
                        this.TopLayer.Add(trileInstance);
                    }
                }
                if (this.LevelManager.Name == "WATER_TOWER" && this.LevelManager.LastLevelName == "LIGHTHOUSE")
                {
                    if (this.GameState.SaveData.ThisLevel.PivotRotations.ContainsKey(handleAo.Id))
                    {
                        this.GameState.SaveData.ThisLevel.PivotRotations[handleAo.Id] = 0;
                    }
                }
                else
                {
                    int initialSpins;
                    if (this.GameState.SaveData.ThisLevel.PivotRotations.TryGetValue(handleAo.Id, out initialSpins) && initialSpins != 0)
                    {
                        this.ForceSpinTo(initialSpins);
                    }
                }
                if (!this.GameState.SaveData.ThisLevel.InactiveArtObjects.Contains(this.HandleAo.Id))
                {
                    return;
                }
                this.HandleAo.Enabled = false;
            }
Exemplo n.º 5
0
        public HeavyGroupState(TrileGroup group)
        {
            ServiceHelper.InjectServices((object)this);
            this.group = group;
            int minY = Enumerable.Min <TrileInstance>((IEnumerable <TrileInstance>)group.Triles, (Func <TrileInstance, int>)(x => x.Emplacement.Y));

            group.Triles.Sort((Comparison <TrileInstance>)((a, b) => a.Emplacement.Y - b.Emplacement.Y));
            this.bottomTriles = Enumerable.ToArray <TrileInstance>(Enumerable.Where <TrileInstance>((IEnumerable <TrileInstance>)group.Triles, (Func <TrileInstance, bool>)(x => x.Emplacement.Y == minY)));
            foreach (TrileInstance instance in group.Triles)
            {
                instance.PhysicsState = new InstancePhysicsState(instance);
            }
            this.MarkGrounds();
        }
Exemplo n.º 6
0
        public LongRunningAction Move(int id, float dX, float dY, float dZ)
        {
            TrileGroup group = this.LevelManager.Groups[id];

            group.Triles.Sort((IComparer <TrileInstance>) new MovingTrileInstanceComparer(new Vector3(dX, dY, dZ)));
            foreach (TrileInstance instance in group.Triles)
            {
                if (instance.PhysicsState == null)
                {
                    instance.PhysicsState = new InstancePhysicsState(instance);
                }
            }
            List <ArtObjectInstance> attachedAos = new List <ArtObjectInstance>();

            foreach (ArtObjectInstance artObjectInstance in (IEnumerable <ArtObjectInstance>) this.LevelManager.ArtObjects.Values)
            {
                int?attachedGroup = artObjectInstance.ActorSettings.AttachedGroup;
                int num           = id;
                if ((attachedGroup.GetValueOrDefault() != num ? 0 : (attachedGroup.HasValue ? 1 : 0)) != 0)
                {
                    attachedAos.Add(artObjectInstance);
                }
            }
            Vector3 velocity = new Vector3(dX, dY, dZ);

            return(new LongRunningAction((Func <float, float, bool>)((elapsedSeconds, _) =>
            {
                foreach (TrileInstance item_2 in group.Triles)
                {
                    item_2.PhysicsState.Velocity = velocity * elapsedSeconds;
                    item_2.Position += velocity * elapsedSeconds;
                    this.LevelManager.UpdateInstance(item_2);
                }
                foreach (ArtObjectInstance item_3 in attachedAos)
                {
                    item_3.Position += velocity * elapsedSeconds;
                }
                return false;
            })));
        }
Exemplo n.º 7
0
 public SwitchState(TrileGroup group, SoundEffect clickSound, SoundEffect thudSound, SoundEffect releaseSound)
 {
     foreach (TrileInstance instance in Enumerable.Where <TrileInstance>((IEnumerable <TrileInstance>)group.Triles, (Func <TrileInstance, bool>)(x => x.PhysicsState == null)))
     {
         instance.PhysicsState = new InstancePhysicsState(instance)
         {
             Sticky = true
         }
     }
     ;
     this.ClickSound     = clickSound;
     this.ThudSound      = thudSound;
     this.ReleaseSound   = releaseSound;
     this.Permanence     = group.ActorType == ActorType.PushSwitchPermanent ? PushSwitchesHost.SwitchState.SwitchPermanence.Permanent : (group.ActorType == ActorType.PushSwitchSticky ? PushSwitchesHost.SwitchState.SwitchPermanence.Sticky : PushSwitchesHost.SwitchState.SwitchPermanence.Volatile);
     this.Group          = group;
     this.OriginalHeight = group.Triles[0].Position.Y;
     ServiceHelper.InjectServices((object)this);
     if (this.Permanence != PushSwitchesHost.SwitchState.SwitchPermanence.Permanent || !this.GameState.SaveData.ThisLevel.InactiveGroups.Contains(this.Group.Id))
     {
         return;
     }
     this.action = PushSwitchesHost.SwitchState.SwitchAction.HeldDown;
 }
Exemplo n.º 8
0
        public LongRunningAction Move(int id, float dX, float dY, float dZ, float easeInFor, float easeOutAfter, float easeOutFor)
        {
            TrileGroup group         = (TrileGroup)null;
            int?       attachedGroup = this.LevelManager.ArtObjects[id].ActorSettings.AttachedGroup;

            if (attachedGroup.HasValue && this.LevelManager.Groups.ContainsKey(attachedGroup.Value))
            {
                group = this.LevelManager.Groups[attachedGroup.Value];
            }
            return(new LongRunningAction((Func <float, float, bool>)((elapsedSeconds, totalSeconds) =>
            {
                ArtObjectInstance local_0;
                if (!this.LevelManager.ArtObjects.TryGetValue(id, out local_0))
                {
                    return true;
                }
                if ((double)totalSeconds < (double)easeInFor)
                {
                    elapsedSeconds *= Easing.EaseIn((double)totalSeconds / (double)easeInFor, EasingType.Quadratic);
                }
                if ((double)easeOutFor != 0.0 && (double)totalSeconds > (double)easeOutAfter)
                {
                    elapsedSeconds *= Easing.EaseOut(1.0 - ((double)totalSeconds - (double)easeOutAfter) / (double)easeOutFor, EasingType.Quadratic);
                }
                Vector3 local_1 = new Vector3(dX, dY, dZ) * elapsedSeconds;
                if (group != null)
                {
                    foreach (TrileInstance item_0 in group.Triles)
                    {
                        item_0.Position += local_1;
                        this.LevelManager.UpdateInstance(item_0);
                    }
                }
                local_0.Position += local_1;
                return false;
            })));
        }
Exemplo n.º 9
0
            public GeyserState(TrileGroup group, GeysersHost host)
            {
                ServiceHelper.InjectServices((object)this);
                this.Host             = host;
                this.Group            = group;
                this.SinceStateChange = TimeSpan.FromSeconds(-(double)group.GeyserOffset);
                Vector3 position = Enumerable.Aggregate <TrileInstance, Vector3>((IEnumerable <TrileInstance>) this.Group.Triles, Vector3.Zero, (Func <Vector3, TrileInstance, Vector3>)((a, b) => a + b.Center)) / (float)group.Triles.Count;
                int     key1     = IdentifierPool.FirstAvailable <BackgroundPlane>(this.LevelManager.BackgroundPlanes);

                this.TopPlane = new BackgroundPlane(this.LevelMaterializer.AnimatedPlanesMesh, "sewer/sewer_geyser_top", true)
                {
                    Id             = key1,
                    Position       = position,
                    YTextureRepeat = true,
                    Crosshatch     = true,
                    Doublesided    = true
                };
                this.LevelManager.BackgroundPlanes.Add(key1, this.TopPlane);
                int key2 = IdentifierPool.FirstAvailable <BackgroundPlane>(this.LevelManager.BackgroundPlanes);

                this.TilePlane = new BackgroundPlane(this.LevelMaterializer.AnimatedPlanesMesh, "sewer/sewer_geyser_tile", true)
                {
                    Id             = key2,
                    Position       = position,
                    YTextureRepeat = true,
                    Billboard      = true
                };
                this.LevelManager.BackgroundPlanes.Add(key2, this.TilePlane);
                this.TopPlane.Timing.Step = this.TilePlane.Timing.Step;
                this.loopEmitter          = SoundEffectExtensions.EmitAt(this.Host.LoopSound, position, true, 0.0f, 0.0f);
                foreach (TrileInstance trileInstance in group.Triles)
                {
                    trileInstance.PhysicsState.IgnoreCollision    = true;
                    trileInstance.PhysicsState.IgnoreClampToWater = true;
                }
            }
Exemplo n.º 10
0
 protected override void TestConditions()
 {
     if (!this.PlayerManager.Grounded)
     {
         this.UnDotize();
     }
     else if (this.PlayerManager.CarriedInstance != null)
     {
         this.UnDotize();
     }
     else
     {
         bool flag = false;
         foreach (NearestTriles nearestTriles in this.PlayerManager.AxisCollision.Values)
         {
             TrileInstance trileInstance = nearestTriles.Surface;
             if (trileInstance != null)
             {
                 Trile           trile           = trileInstance.Trile;
                 FaceOrientation faceOrientation = FezMath.OrientationFromPhi(FezMath.ToPhi(trile.ActorSettings.Face) + trileInstance.Phi);
                 if (ActorTypeExtensions.IsDoor(trile.ActorSettings.Type) && faceOrientation == FezMath.VisibleOrientation(this.CameraManager.Viewpoint))
                 {
                     flag            = this.GameState.SaveData.Keys > 0 && this.LevelManager.Name != "VILLAGEVILLE_2D" || trile.ActorSettings.Type == ActorType.UnlockedDoor;
                     this.isUnlocked = trile.ActorSettings.Type == ActorType.UnlockedDoor;
                     this.doorBottom = trileInstance;
                     break;
                 }
             }
         }
         if (!flag)
         {
             this.UnDotize();
         }
         else if (this.doorBottom.ActorSettings.Inactive)
         {
             this.UnDotize();
         }
         else
         {
             if (!this.PlayerManager.HideFez && this.PlayerManager.CanControl && (!this.DotManager.PreventPoI && this.doorBottom.Trile.ActorSettings.Type == ActorType.Door))
             {
                 this.DotManager.Behaviour  = DotHost.BehaviourType.ThoughtBubble;
                 this.DotManager.FaceButton = DotFaceButton.Up;
                 this.DotManager.ComeOut();
                 if (this.DotManager.Owner != this)
                 {
                     this.DotManager.Hey();
                 }
                 this.DotManager.Owner = (object)this;
             }
             if (this.GameState.IsTrialMode && this.LevelManager.Name == "trial/VILLAGEVILLE_2D" || this.InputManager.ExactUp != FezButtonState.Pressed)
             {
                 return;
             }
             TrileGroup trileGroup1 = (TrileGroup)null;
             this.aoInstance = (ArtObjectInstance)null;
             foreach (TrileGroup trileGroup2 in (IEnumerable <TrileGroup>) this.LevelManager.Groups.Values)
             {
                 if (trileGroup2.Triles.Contains(this.doorBottom))
                 {
                     trileGroup1 = trileGroup2;
                     break;
                 }
             }
             if (trileGroup1 != null)
             {
                 foreach (ArtObjectInstance artObjectInstance in (IEnumerable <ArtObjectInstance>) this.LevelManager.ArtObjects.Values)
                 {
                     int?attachedGroup = artObjectInstance.ActorSettings.AttachedGroup;
                     int id            = trileGroup1.Id;
                     if ((attachedGroup.GetValueOrDefault() != id ? 0 : (attachedGroup.HasValue ? 1 : 0)) != 0)
                     {
                         this.aoInstance = artObjectInstance;
                         break;
                     }
                 }
                 if (this.aoInstance != null)
                 {
                     this.aoInitialRotation = this.aoInstance.Rotation;
                     this.initialAoPosition = this.aoInstance.Position;
                 }
             }
             this.WalkTo.Destination   = new Func <Vector3>(this.GetDestination);
             this.PlayerManager.Action = ActionType.WalkingTo;
             this.WalkTo.NextAction    = ActionType.OpeningDoor;
         }
     }
 }
Exemplo n.º 11
0
        private void TryInitialize()
        {
            this.Enabled   = this.LevelManager.Name == "CLOCK";
            this.RedAo     = this.BlueAo = this.GreenAo = this.WhiteAo = (ArtObjectInstance)null;
            this.sTickTock = (SoundEffect)null;
            this.eTickTock = (SoundEmitter)null;
            if (!this.Enabled)
            {
                return;
            }
            foreach (ArtObjectInstance artObjectInstance in (IEnumerable <ArtObjectInstance>) this.LevelManager.ArtObjects.Values)
            {
                if (artObjectInstance.ArtObjectName == "CLOCKHAND_RAO")
                {
                    this.RedAo = artObjectInstance;
                }
                if (artObjectInstance.ArtObjectName == "CLOCKHAND_GAO")
                {
                    this.GreenAo = artObjectInstance;
                }
                if (artObjectInstance.ArtObjectName == "CLOCKHAND_BAO")
                {
                    this.BlueAo = artObjectInstance;
                }
                if (artObjectInstance.ArtObjectName == "CLOCKHAND_WAO")
                {
                    this.WhiteAo = artObjectInstance;
                }
            }
            this.RedOriginalRotation   = this.RedAo.Rotation;
            this.BlueOriginalRotation  = this.BlueAo.Rotation;
            this.GreenOriginalRotation = this.GreenAo.Rotation;
            this.WhiteOriginalRotation = this.WhiteAo.Rotation;
            this.RedOriginalPosition   = this.RedAo.Position + 1.125f * Vector3.UnitX;
            this.GreenOriginalPosition = this.GreenAo.Position - 1.125f * Vector3.UnitX;
            this.BlueOriginalPosition  = this.BlueAo.Position + 1.125f * Vector3.UnitZ;
            this.WhiteOriginalPosition = this.WhiteAo.Position - 1.125f * Vector3.UnitZ;
            this.RedGroup     = this.LevelManager.Groups[23];
            this.BlueGroup    = this.LevelManager.Groups[24];
            this.GreenGroup   = this.LevelManager.Groups[25];
            this.WhiteGroup   = this.LevelManager.Groups[26];
            this.RedTopMost   = Enumerable.First <TrileInstance>((IEnumerable <TrileInstance>) this.RedGroup.Triles, (Func <TrileInstance, bool>)(x => x.Emplacement.Y == 58));
            this.BlueTopMost  = Enumerable.First <TrileInstance>((IEnumerable <TrileInstance>) this.BlueGroup.Triles, (Func <TrileInstance, bool>)(x => x.Emplacement.Y == 58));
            this.GreenTopMost = Enumerable.First <TrileInstance>((IEnumerable <TrileInstance>) this.GreenGroup.Triles, (Func <TrileInstance, bool>)(x => x.Emplacement.Y == 58));
            this.WhiteTopMost = Enumerable.First <TrileInstance>((IEnumerable <TrileInstance>) this.WhiteGroup.Triles, (Func <TrileInstance, bool>)(x => x.Emplacement.Y == 58));
            if (this.GameState.SaveData.ThisLevel.InactiveArtObjects.Contains(this.RedAo.Id))
            {
                this.RedAo.Enabled = false;
                this.LevelManager.RemoveArtObject(this.RedAo);
            }
            if (this.GameState.SaveData.ThisLevel.InactiveArtObjects.Contains(this.GreenAo.Id))
            {
                this.GreenAo.Enabled = false;
                this.LevelManager.RemoveArtObject(this.GreenAo);
            }
            if (this.GameState.SaveData.ThisLevel.InactiveArtObjects.Contains(this.BlueAo.Id))
            {
                this.BlueAo.Enabled = false;
                this.LevelManager.RemoveArtObject(this.BlueAo);
            }
            if (this.GameState.SaveData.ThisLevel.InactiveArtObjects.Contains(this.WhiteAo.Id))
            {
                this.WhiteAo.Enabled = false;
                this.LevelManager.RemoveArtObject(this.WhiteAo);
            }
            TimeSpan timeSpan = TimeSpan.FromTicks((DateTime.UtcNow - DateTime.FromFileTimeUtc(this.GameState.SaveData.CreationTime)).Ticks);

            if (this.RedAo.Enabled)
            {
                float angle = FezMath.WrapAngle((float)((double)FezMath.Round(timeSpan.TotalSeconds) / 60.0 * 6.28318548202515));
                this.lastRedAngle   = angle;
                this.RedAo.Rotation = Quaternion.CreateFromAxisAngle(-Vector3.UnitZ, angle) * this.RedOriginalRotation;
            }
            if (!this.WhiteAo.Enabled && !this.BlueAo.Enabled && (!this.GreenAo.Enabled && !this.RedAo.Enabled))
            {
                return;
            }
            this.sTickTock = this.CMProvider.CurrentLevel.Load <SoundEffect>("Sounds/MiscActors/TickTockLoop");
            Waiters.Wait(FezMath.Frac(timeSpan.TotalSeconds), (Action)(() => this.eTickTock = SoundEffectExtensions.EmitAt(this.sTickTock, new Vector3(41.5f, 61.5f, 35.5f), true)));
        }
Exemplo n.º 12
0
            public RotatingGroupState(TrileGroup group)
            {
                ServiceHelper.InjectServices((object)this);
                this.Group = group;
                this.AttachedArtObjects = Enumerable.ToArray <ArtObjectInstance>(Enumerable.Where <ArtObjectInstance>((IEnumerable <ArtObjectInstance>) this.LevelManager.ArtObjects.Values, (Func <ArtObjectInstance, bool>)(x =>
                {
                    int?local_0 = x.ActorSettings.AttachedGroup;
                    int local_1 = this.Group.Id;
                    if (local_0.GetValueOrDefault() == local_1)
                    {
                        return(local_0.HasValue);
                    }
                    else
                    {
                        return(false);
                    }
                })));
                this.AttachedAoOrigins   = Enumerable.ToArray <Vector3>(Enumerable.Select <ArtObjectInstance, Vector3>((IEnumerable <ArtObjectInstance>) this.AttachedArtObjects, (Func <ArtObjectInstance, Vector3>)(x => x.Position)));
                this.AttachedAoRotations = Enumerable.ToArray <Quaternion>(Enumerable.Select <ArtObjectInstance, Quaternion>((IEnumerable <ArtObjectInstance>) this.AttachedArtObjects, (Func <ArtObjectInstance, Quaternion>)(x => x.Rotation)));
                this.CachedMaterializers = Enumerable.ToArray <TrileMaterializer>(Enumerable.Select <TrileInstance, TrileMaterializer>((IEnumerable <TrileInstance>)group.Triles, (Func <TrileInstance, TrileMaterializer>)(x => this.LevelMaterializer.GetTrileMaterializer(x.Trile))));
                foreach (TrileInstance trileInstance in this.Group.Triles)
                {
                    trileInstance.ForceSeeThrough = true;
                    trileInstance.Unsafe          = true;
                }
                float num = Enumerable.Max <TrileInstance>(Enumerable.Where <TrileInstance>((IEnumerable <TrileInstance>) this.Group.Triles, (Func <TrileInstance, bool>)(x => !x.Trile.Immaterial)), (Func <TrileInstance, float>)(x => x.Position.Y));

                foreach (TrileInstance trileInstance in this.Group.Triles)
                {
                    if ((double)trileInstance.Position.Y == (double)num)
                    {
                        this.TopLayer.Add(trileInstance);
                    }
                }
                if (this.Group.SpinCenter != Vector3.Zero)
                {
                    this.Center = this.Group.SpinCenter;
                }
                else
                {
                    foreach (TrileInstance trileInstance in this.Group.Triles)
                    {
                        this.Center += trileInstance.Position + FezMath.HalfVector;
                    }
                    this.Center /= (float)this.Group.Triles.Count;
                }
                this.Enabled      = !this.Group.SpinNeedsTriggering;
                this.SinceChanged = -this.Group.SpinOffset;
                if ((double)this.SinceChanged != 0.0)
                {
                    this.SinceChanged -= 0.375f;
                }
                if (string.IsNullOrEmpty(group.AssociatedSound))
                {
                    return;
                }
                try
                {
                    this.sSpin = this.CMProvider.CurrentLevel.Load <SoundEffect>("Sounds/MiscActors/" + group.AssociatedSound);
                }
                catch (Exception ex)
                {
                    Logger.Log("RotatingGroups", LogSeverity.Warning, "Could not find associated sound '" + group.AssociatedSound + "'");
                }
            }
Exemplo n.º 13
0
 public SuckBlockState(TrileInstance instance, TrileGroup group)
 {
     this.Instance = instance;
     this.Group    = group;
 }
Exemplo n.º 14
0
        private void TryInitialize()
        {
            this.DoorAo           = (ArtObjectInstance)null;
            this.AttachedGroup    = (TrileGroup)null;
            this.AssociatedVolume = (Volume)null;
            this.Enabled          = false;
            this.sRumble          = (SoundEffect)null;
            this.sLightUp         = (SoundEffect)null;
            this.sFadeOut         = (SoundEffect)null;
            if (this.eRumble != null && !this.eRumble.Dead)
            {
                this.eRumble.Cue.Stop(false);
            }
            this.eRumble = (SoundEmitter)null;
            foreach (ArtObjectInstance artObjectInstance in (IEnumerable <ArtObjectInstance>) this.LevelManager.ArtObjects.Values)
            {
                if (artObjectInstance.ArtObject.ActorType == ActorType.SecretPassage)
                {
                    this.DoorAo  = artObjectInstance;
                    this.Enabled = true;
                    break;
                }
            }
            if (!this.Enabled)
            {
                if (this.GlowPlane != null)
                {
                    this.GlowPlane.Dispose();
                }
                this.GlowPlane = (BackgroundPlane)null;
            }
            if (!this.Enabled)
            {
                return;
            }
            this.AttachedGroup    = this.LevelManager.Groups[this.DoorAo.ActorSettings.AttachedGroup.Value];
            this.AssociatedVolume = Enumerable.FirstOrDefault <Volume>((IEnumerable <Volume>) this.LevelManager.Volumes.Values, (Func <Volume, bool>)(x =>
            {
                if (x.ActorSettings != null)
                {
                    return(x.ActorSettings.IsSecretPassage);
                }
                else
                {
                    return(false);
                }
            }));
            string key = (string)null;

            foreach (Script script in (IEnumerable <Script>) this.LevelManager.Scripts.Values)
            {
                foreach (ScriptAction scriptAction in script.Actions)
                {
                    if (scriptAction.Object.Type == "Level" && scriptAction.Operation.Contains("Level"))
                    {
                        foreach (ScriptTrigger scriptTrigger in script.Triggers)
                        {
                            if (scriptTrigger.Object.Type == "Volume" && scriptTrigger.Event == "Enter" && scriptTrigger.Object.Identifier.HasValue)
                            {
                                key = scriptAction.Arguments[0];
                            }
                        }
                    }
                }
            }
            this.Accessible = this.GameState.SaveData.World.ContainsKey(key);
            this.sRumble    = this.CMProvider.CurrentLevel.Load <SoundEffect>("Sounds/MiscActors/Rumble");
            this.sLightUp   = this.CMProvider.CurrentLevel.Load <SoundEffect>("Sounds/Zu/DoorBitLightUp");
            this.sFadeOut   = this.CMProvider.CurrentLevel.Load <SoundEffect>("Sounds/Zu/DoorBitFadeOut");
            if (!this.Accessible)
            {
                this.Enabled = false;
            }
            else
            {
                this.GlowPlane = new BackgroundPlane(this.LevelMaterializer.StaticPlanesMesh, (Texture)this.CMProvider.CurrentLevel.Load <Texture2D>("Other Textures/glow/secret_passage"))
                {
                    Fullbright    = true,
                    Opacity       = 0.0f,
                    Position      = this.DoorAo.Position + FezMath.AsVector(Enumerable.First <FaceOrientation>((IEnumerable <FaceOrientation>) this.AssociatedVolume.Orientations)) / (65.0 / 32.0),
                    Rotation      = FezMath.QuaternionFromPhi(FezMath.ToPhi(Enumerable.First <FaceOrientation>((IEnumerable <FaceOrientation>) this.AssociatedVolume.Orientations))),
                    AttachedGroup = new int?(this.AttachedGroup.Id)
                };
                this.LevelManager.AddPlane(this.GlowPlane);
                this.ExpectedViewpoint = FezMath.AsViewpoint(Enumerable.First <FaceOrientation>((IEnumerable <FaceOrientation>) this.AssociatedVolume.Orientations));
                if (!this.LevelManager.WentThroughSecretPassage)
                {
                    return;
                }
                this.MoveUp            = true;
                this.GlowPlane.Opacity = 1f;
                this.SinceStarted      = TimeSpan.Zero;
                this.AoOrigin          = this.DoorAo.Position;
                this.PlaneOrigin       = this.GlowPlane.Position;
            }
        }
Exemplo n.º 15
0
 public PickupState(TrileInstance ti, TrileGroup group)
 {
     this.Instance       = ti;
     this.OriginalCenter = ti.Center;
     this.Group          = group;
 }
Exemplo n.º 16
0
 public override void Update(GameTime gameTime)
 {
     if (this.CameraManager.Viewpoint == Viewpoint.Perspective || !this.CameraManager.ActionRunning || (this.GameState.Paused || this.GameState.InMap) || (this.GameState.Loading || this.PickupStates == null || this.PickupStates.Count == 0))
     {
         return;
     }
     this.sinceLevelChanged += (float)gameTime.ElapsedGameTime.TotalSeconds;
     this.initLock.WaitOne();
     for (int index = this.PickupStates.Count - 1; index >= 0; --index)
     {
         if (this.PickupStates[index].Instance.PhysicsState == null)
         {
             this.PickupStates.RemoveAt(index);
         }
     }
     foreach (PickupState pickupState in this.PickupStates)
     {
         if (pickupState.Instance.PhysicsState.StaticGrounds)
         {
             pickupState.Instance.PhysicsState.GroundMovement = Vector3.Zero;
         }
     }
     this.PickupStates.Sort((IComparer <PickupState>)MovingGroundsPickupComparer.Default);
     this.UpdatePickups((float)gameTime.ElapsedGameTime.TotalSeconds);
     foreach (TrileGroup trileGroup1 in (IEnumerable <TrileGroup>) this.LevelManager.PickupGroups.Values)
     {
         if (trileGroup1.InMidAir)
         {
             foreach (TrileInstance trileInstance in trileGroup1.Triles)
             {
                 if (!trileInstance.PhysicsState.Paused && trileInstance.PhysicsState.Grounded)
                 {
                     trileGroup1.InMidAir = false;
                     if (trileInstance.PhysicsState.Puppet)
                     {
                         trileInstance.PhysicsState.Puppet = false;
                         using (List <TrileInstance> .Enumerator enumerator = trileGroup1.Triles.GetEnumerator())
                         {
                             while (enumerator.MoveNext())
                             {
                                 TrileInstance current = enumerator.Current;
                                 if (current != trileInstance)
                                 {
                                     current.PhysicsState.Puppet = true;
                                 }
                             }
                             break;
                         }
                     }
                     else
                     {
                         break;
                     }
                 }
             }
         }
         else
         {
             trileGroup1.InMidAir = true;
             foreach (TrileInstance trileInstance in trileGroup1.Triles)
             {
                 TrileGroup trileGroup2 = trileGroup1;
                 int        num         = trileGroup2.InMidAir & !trileInstance.PhysicsState.Grounded ? 1 : 0;
                 trileGroup2.InMidAir = num != 0;
             }
         }
     }
     foreach (PickupState pickupState1 in this.PickupStates)
     {
         if (pickupState1.Group != null && !pickupState1.Instance.PhysicsState.Puppet)
         {
             PickupState pickupState2 = pickupState1;
             foreach (PickupState pickupState3 in this.PickupStates)
             {
                 if (pickupState3.Group == pickupState2.Group && pickupState3 != pickupState2)
                 {
                     pickupState3.Instance.PhysicsState.Center    += pickupState2.LastMovement - pickupState3.LastMovement;
                     pickupState3.Instance.PhysicsState.Background = pickupState2.Instance.PhysicsState.Background;
                     pickupState3.Instance.PhysicsState.Velocity   = pickupState2.Instance.PhysicsState.Velocity;
                     pickupState3.Instance.PhysicsState.UpdateInstance();
                     this.LevelManager.UpdateInstance(pickupState3.Instance);
                     pickupState3.LastMovement = Vector3.Zero;
                     pickupState3.FloatMalus   = pickupState2.FloatMalus;
                     pickupState3.FloatSeed    = pickupState2.FloatSeed;
                 }
             }
         }
         if (pickupState1.VisibleOverlapper != null)
         {
             PickupState          pickupState2 = pickupState1.VisibleOverlapper;
             InstancePhysicsState physicsState = pickupState1.Instance.PhysicsState;
             physicsState.Background = pickupState2.Instance.PhysicsState.Background;
             physicsState.Ground     = pickupState2.Instance.PhysicsState.Ground;
             physicsState.Floating   = pickupState2.Instance.PhysicsState.Floating;
             Array.Copy((Array)physicsState.CornerCollision, (Array)pickupState1.Instance.PhysicsState.CornerCollision, 4);
             physicsState.GroundMovement     = pickupState2.Instance.PhysicsState.GroundMovement;
             physicsState.Sticky             = pickupState2.Instance.PhysicsState.Sticky;
             physicsState.WallCollision      = pickupState2.Instance.PhysicsState.WallCollision;
             physicsState.PushedDownBy       = pickupState2.Instance.PhysicsState.PushedDownBy;
             pickupState1.LastGroundedCenter = pickupState2.LastGroundedCenter;
             pickupState1.LastVelocity       = pickupState2.LastVelocity;
             pickupState1.TouchesWater       = pickupState2.TouchesWater;
         }
     }
     foreach (PickupState pickupState in this.PickupStates)
     {
         if (pickupState.Instance.PhysicsState != null && (pickupState.Instance.PhysicsState.Grounded || this.PlayerManager.CarriedInstance == pickupState.Instance || pickupState.Instance.PhysicsState.Floating))
         {
             pickupState.FlightApex         = pickupState.Instance.Center.Y;
             pickupState.LastGroundedCenter = pickupState.Instance.Center;
         }
     }
     this.initLock.Set();
 }