Exemple #1
0
        public NpcState(Game game, NpcInstance npc)
            : base(game)
        {
            this.Npc       = npc;
            this.Npc.State = this;
            foreach (NpcAction key in Util.GetValues <NpcAction>())
            {
                switch (key)
                {
                case NpcAction.None:
                case NpcAction.Walk:
                case NpcAction.Idle:
                case NpcAction.Talk:
                    continue;

                default:
                    if (!this.Npc.Actions.ContainsKey(key))
                    {
                        if (MemoryContentManager.AssetExists(string.Concat(new object[4]
                        {
                            (object)"Character Animations\\",
                            (object)this.Npc.Name,
                            (object)"\\",
                            (object)key
                        })))
                        {
                            this.Npc.Actions.Add(key, new NpcActionContent()
                            {
                                AnimationName = ((object)key).ToString()
                            });
                            continue;
                        }
                        else
                        {
                            continue;
                        }
                    }
                    else
                    {
                        continue;
                    }
                }
            }
            if (MemoryContentManager.AssetExists("Character Animations\\" + this.Npc.Name + "\\Metadata"))
            {
                npc.FillMetadata(ServiceHelper.Get <IContentManagerProvider>().CurrentLevel.Load <NpcMetadata>("Character Animations/" + npc.Name + "/Metadata"));
            }
            this.CanIdle    = this.Npc.Actions.ContainsKey(NpcAction.Idle);
            this.CanIdle2   = this.Npc.Actions.ContainsKey(NpcAction.Idle2);
            this.CanIdle3   = this.Npc.Actions.ContainsKey(NpcAction.Idle3);
            this.CanTalk    = this.Npc.Actions.ContainsKey(NpcAction.Talk);
            this.CanWalk    = this.Npc.Actions.ContainsKey(NpcAction.Walk);
            this.CanTurn    = this.Npc.Actions.ContainsKey(NpcAction.Turn);
            this.CanBurrow  = this.Npc.Actions.ContainsKey(NpcAction.Burrow);
            this.CanHide    = this.Npc.Actions.ContainsKey(NpcAction.Hide);
            this.CanTakeOff = this.Npc.Actions.ContainsKey(NpcAction.TakeOff);
        }
Exemple #2
0
        public override void Load(string levelName)
        {
            levelName = levelName.Replace('\\', '/');
            string str = levelName;
            Level  level;

            using (MemoryContentManager memoryContentManager = new MemoryContentManager((IServiceProvider)this.Game.Services, this.Game.Content.RootDirectory))
            {
                if (!string.IsNullOrEmpty(this.Name))
                {
                    levelName = this.Name.Substring(0, this.Name.LastIndexOf("/") + 1) + levelName.Substring(levelName.LastIndexOf("/") + 1);
                }
                if (!MemoryContentManager.AssetExists("Levels" + (object)'\\' + levelName.Replace('/', '\\')))
                {
                    levelName = str;
                }
                try
                {
                    level = memoryContentManager.Load <Level>("Levels/" + levelName);
                }
                catch (Exception ex)
                {
                    Logger.LogError(ex);
                    this.oldLevel = new Level();
                    return;
                }
            }
            level.Name = levelName;
            ContentManager forLevel = this.CMProvider.GetForLevel(levelName);

            foreach (ArtObjectInstance artObjectInstance in level.ArtObjects.Values)
            {
                artObjectInstance.ArtObject = forLevel.Load <ArtObject>(string.Format("{0}/{1}", (object)"Art Objects", (object)artObjectInstance.ArtObjectName));
            }
            if (level.Sky == null)
            {
                level.Sky = forLevel.Load <Sky>("Skies/" + level.SkyName);
            }
            if (level.TrileSetName != null)
            {
                level.TrileSet = forLevel.Load <TrileSet>("Trile Sets/" + level.TrileSetName);
            }
            if (level.SongName != null)
            {
                level.Song = forLevel.Load <TrackedSong>("Music/" + level.SongName);
                level.Song.Initialize();
            }
            if (this.levelData != null)
            {
                this.GameState.SaveData.ThisLevel.FirstVisit = false;
            }
            this.ClearArtSatellites();
            this.oldLevel  = this.levelData ?? new Level();
            this.levelData = level;
        }
Exemple #3
0
 public void FillAnimations()
 {
     this.HatAnimations.Clear();
     this.NoHatAnimations.Clear();
     foreach (ActionType actionType in Util.GetValues <ActionType>())
     {
         if (actionType != ActionType.None)
         {
             string assetName = "Character Animations/Gomez/" + ActionTypeExtensions.GetAnimationPath(actionType);
             this.HatAnimations.Add(actionType, this.CMProvider.Global.Load <AnimatedTexture>(assetName));
             if (MemoryContentManager.AssetExists(assetName.Replace('/', '\\') + "_NoHat"))
             {
                 AnimatedTexture animatedTexture = this.CMProvider.Global.Load <AnimatedTexture>(assetName + "_NoHat");
                 animatedTexture.NoHat = true;
                 this.NoHatAnimations.Add(actionType, animatedTexture);
             }
         }
     }
 }
Exemple #4
0
 protected override void TestConditions()
 {
     switch (this.PlayerManager.Action)
     {
     case ActionType.Teetering:
     case ActionType.IdlePlay:
     case ActionType.IdleSleep:
     case ActionType.IdleLookAround:
     case ActionType.IdleYawn:
     case ActionType.Idle:
     case ActionType.LookingLeft:
     case ActionType.LookingRight:
     case ActionType.LookingUp:
     case ActionType.LookingDown:
     case ActionType.Walking:
     case ActionType.Running:
     case ActionType.Jumping:
     case ActionType.Lifting:
     case ActionType.Falling:
     case ActionType.Bouncing:
     case ActionType.Flying:
     case ActionType.Dropping:
     case ActionType.Sliding:
     case ActionType.Landing:
         string key = this.PlayerManager.NextLevel;
         if (this.PlayerManager.NextLevel == "CABIN_INTERIOR_A")
         {
             key = "CABIN_INTERIOR_B";
         }
         if (this.PlayerManager.DoorVolume.HasValue && this.PlayerManager.Grounded && (!this.PlayerManager.HideFez && this.PlayerManager.CanControl) && (!this.PlayerManager.Background && !this.DotManager.PreventPoI && (this.GameState.SaveData.World.ContainsKey(key) && !this.skipPreview)) && (key != this.LevelManager.Name && this.LevelManager.Name != "CRYPT" && this.LevelManager.Name != "PYRAMID"))
         {
             if (MemoryContentManager.AssetExists("Other Textures\\map_screens\\" + key.Replace('/', '\\')))
             {
                 Texture2D texture2D = this.CMProvider.CurrentLevel.Load <Texture2D>("Other Textures/map_screens/" + key);
                 this.DotManager.Behaviour           = DotHost.BehaviourType.ThoughtBubble;
                 this.DotManager.DestinationVignette = texture2D;
                 this.DotManager.ComeOut();
                 if (this.DotManager.Owner != this)
                 {
                     this.DotManager.Hey();
                 }
                 this.DotManager.Owner = (object)this;
             }
             else
             {
                 this.UnDotize();
             }
         }
         else
         {
             this.UnDotize();
         }
         if ((double)this.step != -1.0 || this.InputManager.ExactUp != FezButtonState.Pressed && this.PlayerManager.LastAction != ActionType.OpeningDoor || !this.PlayerManager.Grounded || (!this.PlayerManager.DoorVolume.HasValue || this.PlayerManager.Background))
         {
             break;
         }
         this.UnDotize();
         this.GameState.SkipLoadScreen = this.skipFade = this.LevelManager.DestinationVolumeId.HasValue && this.PlayerManager.NextLevel == this.LevelManager.Name;
         bool spinThroughDoor = this.PlayerManager.SpinThroughDoor;
         if (spinThroughDoor)
         {
             Vector3 b       = FezMath.ForwardVector(this.CameraManager.Viewpoint);
             Vector3 vector3 = FezMath.DepthMask(this.CameraManager.Viewpoint);
             Volume  volume  = this.LevelManager.Volumes[this.PlayerManager.DoorVolume.Value];
             Vector3 a       = (volume.From + volume.To) / 2f - (volume.To - volume.From) / 2f * b - b;
             if ((double)FezMath.Dot(this.PlayerManager.Position, b) < (double)FezMath.Dot(a, b))
             {
                 this.PlayerManager.Position = this.PlayerManager.Position * (Vector3.One - vector3) + a * vector3;
             }
             this.spinOrigin      = this.GetDestination();
             this.spinDestination = this.GetDestination() + b * 1.5f;
         }
         if (this.PlayerManager.CarriedInstance != null)
         {
             bool flag = ActorTypeExtensions.IsLight(this.PlayerManager.CarriedInstance.Trile.ActorSettings.Type);
             this.PlayerManager.Position = this.GetDestination();
             this.PlayerManager.Action   = flag ? (spinThroughDoor ? ActionType.EnterDoorSpinCarry : ActionType.CarryEnter) : (spinThroughDoor ? ActionType.EnterDoorSpinCarryHeavy : ActionType.CarryHeavyEnter);
             break;
         }
         else
         {
             this.WalkTo.Destination   = new Func <Vector3>(this.GetDestination);
             this.PlayerManager.Action = ActionType.WalkingTo;
             this.WalkTo.NextAction    = spinThroughDoor ? ActionType.EnterDoorSpin : ActionType.EnteringDoor;
             break;
         }
     }
 }
Exemple #5
0
        private void TryInitialize()
        {
            this.ThisLevelMesh.ClearGroups();
            this.NextLevelMesh.ClearGroups();
            lock (FarawayPlaceHost.FarawayWaterMutex)
                this.FarawayWaterMesh = (Mesh)null;
            (this.NextLevelMesh.Effect as FarawayEffect).CleanUp();
            foreach (Script script1 in Enumerable.Where <Script>((IEnumerable <Script>) this.LevelManager.Scripts.Values, (Func <Script, bool>)(x => Enumerable.Any <ScriptAction>((IEnumerable <ScriptAction>)x.Actions, (Func <ScriptAction, bool>)(y => y.Operation == "ChangeToFarAwayLevel")))))
            {
                Volume volume1;
                if (this.LevelManager.Volumes.TryGetValue(Enumerable.FirstOrDefault <ScriptTrigger>((IEnumerable <ScriptTrigger>)script1.Triggers, (Func <ScriptTrigger, bool>)(x =>
                {
                    if (x.Object.Type == "Volume")
                    {
                        return(x.Event == "Enter");
                    }
                    else
                    {
                        return(false);
                    }
                })).Object.Identifier.Value, out volume1))
                {
                    FaceOrientation faceOrientation = Enumerable.FirstOrDefault <FaceOrientation>((IEnumerable <FaceOrientation>)volume1.Orientations);
                    ScriptAction    scriptAction1   = Enumerable.FirstOrDefault <ScriptAction>((IEnumerable <ScriptAction>)script1.Actions, (Func <ScriptAction, bool>)(x => x.Operation == "ChangeToFarAwayLevel"));
                    string          str1            = scriptAction1.Arguments[0];
                    int             num1            = 0;
                    string          songName;
                    FaceOrientation orientation;
                    Vector2         vector2;
                    bool            flag;
                    float           num2;
                    float           num3;
                    float           num4;
                    using (MemoryContentManager memoryContentManager = new MemoryContentManager((IServiceProvider)this.Game.Services, this.Game.Content.RootDirectory))
                    {
                        string str2 = str1;
                        if (!MemoryContentManager.AssetExists("Levels" + (object)'\\' + str1.Replace('/', '\\')))
                        {
                            str2 = this.LevelManager.FullPath.Substring(0, this.LevelManager.FullPath.LastIndexOf("/") + 1) + str1.Substring(str1.LastIndexOf("/") + 1);
                        }
                        LevelReader.MinimalRead = true;
                        Level level;
                        try
                        {
                            level = memoryContentManager.Load <Level>("Levels/" + str2);
                        }
                        catch (Exception ex)
                        {
                            Logger.Log("FarawayPlaceHost", Common.LogSeverity.Warning, "Couldn't load faraway place destination level : " + str1);
                            continue;
                        }
                        LevelReader.MinimalRead = false;
                        songName = level.SongName;
                        int key;
                        try
                        {
                            key = int.Parse(scriptAction1.Arguments[1]);
                        }
                        catch (Exception ex)
                        {
                            key = -1;
                        }
                        Volume volume2 = key == -1 || !level.Volumes.ContainsKey(key) ? level.Volumes[Enumerable.First <ScriptTrigger>((IEnumerable <ScriptTrigger>)Enumerable.First <Script>((IEnumerable <Script>)level.Scripts.Values, (Func <Script, bool>)(s => Enumerable.Any <ScriptAction>((IEnumerable <ScriptAction>)s.Actions, (Func <ScriptAction, bool>)(a =>
                        {
                            if (a.Object.Type == "Level" && a.Operation.Contains("Level"))
                            {
                                return(a.Arguments[0] == this.LevelManager.Name);
                            }
                            else
                            {
                                return(false);
                            }
                        })))).Triggers, (Func <ScriptTrigger, bool>)(t =>
                        {
                            if (t.Object.Type == "Volume")
                            {
                                return(t.Event == "Enter");
                            }
                            else
                            {
                                return(false);
                            }
                        })).Object.Identifier.Value] : level.Volumes[key];
                        orientation = Enumerable.FirstOrDefault <FaceOrientation>((IEnumerable <FaceOrientation>)volume2.Orientations);
                        Vector3 vector3 = (level.Size / 2f - (volume2.From + volume2.To) / 2f) * (FezMath.RightVector(FezMath.AsViewpoint(orientation)) + Vector3.Up);
                        vector2 = new Vector2(vector3.X + vector3.Z, vector3.Y);
                        flag    = level.WaterType != LiquidType.None;
                        num2    = level.WaterHeight - (volume2.From + volume2.To).Y / 2f + this.EngineState.WaterLevelOffset;
                        num3    = this.LevelManager.WaterHeight - (volume1.From + volume1.To).Y / 2f - num2 / 4f;
                        num4    = level.Size.Y;
                        Script script2 = Enumerable.FirstOrDefault <Script>((IEnumerable <Script>)level.Scripts.Values, (Func <Script, bool>)(s =>
                        {
                            if (Enumerable.Any <ScriptTrigger>((IEnumerable <ScriptTrigger>)s.Triggers, (Func <ScriptTrigger, bool>)(t =>
                            {
                                if (t.Event == "Start")
                                {
                                    return(t.Object.Type == "Level");
                                }
                                else
                                {
                                    return(false);
                                }
                            })))
                            {
                                return(Enumerable.Any <ScriptAction>((IEnumerable <ScriptAction>)s.Actions, (Func <ScriptAction, bool>)(a =>
                                {
                                    if (a.Object.Type == "Camera")
                                    {
                                        return a.Operation == "SetPixelsPerTrixel";
                                    }
                                    else
                                    {
                                        return false;
                                    }
                                })));
                            }
                            else
                            {
                                return(false);
                            }
                        }));
                        if (script2 != null)
                        {
                            ScriptAction scriptAction2 = Enumerable.First <ScriptAction>((IEnumerable <ScriptAction>)script2.Actions, (Func <ScriptAction, bool>)(a =>
                            {
                                if (a.Object.Type == "Camera")
                                {
                                    return(a.Operation == "SetPixelsPerTrixel");
                                }
                                else
                                {
                                    return(false);
                                }
                            }));
                            try
                            {
                                num1 = int.Parse(scriptAction2.Arguments[0]);
                            }
                            catch (Exception ex)
                            {
                            }
                        }
                        num2 = level.WaterHeight;
                    }
                    Texture2D texture;
                    try
                    {
                        string assetName = "Other Textures/faraway_thumbs/" + (object)str1 + " (" + (string)(object)FezMath.AsViewpoint(orientation) + ")";
                        texture      = this.CMProvider.CurrentLevel.Load <Texture2D>(assetName);
                        texture.Name = assetName;
                    }
                    catch (Exception ex)
                    {
                        Logger.Log("FarawayPlacesHost", Common.LogSeverity.Warning, "Couldn't load faraway thumbnail for " + (object)str1 + " (viewpoint = " + (string)(object)FezMath.AsViewpoint(orientation) + ")");
                        continue;
                    }
                    if (!Enumerable.Any <Group>((IEnumerable <Group>) this.ThisLevelMesh.Groups, (Func <Group, bool>)(x => x.Texture == texture)))
                    {
                        if (num1 == 0)
                        {
                            num1 = (int)this.CameraManager.PixelsPerTrixel;
                        }
                        Group            group1           = this.ThisLevelMesh.AddFace(new Vector3((float)texture.Width, (float)texture.Height, (float)texture.Width) / 16f / 2f, Vector3.Zero, faceOrientation, true);
                        Group            group2           = this.NextLevelMesh.AddFace(new Vector3((float)texture.Width, (float)texture.Height, (float)texture.Width) / 16f / 2f, Vector3.Zero, faceOrientation, true);
                        FarawayPlaceData farawayPlaceData = new FarawayPlaceData()
                        {
                            OriginalCenter        = (volume1.From + volume1.To) / 2f,
                            Viewpoint             = FezMath.AsViewpoint(faceOrientation),
                            Volume                = volume1,
                            DestinationOffset     = vector2.X * FezMath.RightVector(FezMath.AsViewpoint(faceOrientation)) + Vector3.Up * vector2.Y,
                            WaterLevelOffset      = new float?(num3),
                            DestinationLevelName  = str1,
                            DestinationWaterLevel = num2,
                            DestinationLevelSize  = num4
                        };
                        if (this.LevelManager.WaterType == LiquidType.None && flag)
                        {
                            if (this.HorizontalGradientTex == null || this.HorizontalGradientTex.IsDisposed)
                            {
                                this.HorizontalGradientTex = this.CMProvider.Global.Load <Texture2D>("Other Textures/WaterHorizGradient");
                            }
                            lock (FarawayPlaceHost.FarawayWaterMutex)
                            {
                                FarawayPlaceHost temp_380 = this;
                                // ISSUE: explicit reference operation
                                // ISSUE: variable of a reference type
                                FarawayPlaceData& temp_381 = @farawayPlaceData;
                                Mesh local_28 = new Mesh();
                                Mesh temp_383 = local_28;
                                DefaultEffect.Textured local_29 = new DefaultEffect.Textured();
                                local_29.AlphaIsEmissive = false;
                                DefaultEffect.Textured temp_387 = local_29;
                                temp_383.Effect = (BaseEffect)temp_387;
                                Mesh temp_388;
                                Mesh local_43 = temp_388 = local_28;
                                // ISSUE: explicit reference operation
                                (^ temp_381).WaterBodyMesh = temp_388;
                                Mesh temp_389 = local_43;
                                temp_380.FarawayWaterMesh = temp_389;
                                this.FarawayWaterMesh.AddFace(Vector3.One, new Vector3(-0.5f, -1f, -0.5f) + FezMath.Abs(FezMath.AsVector(faceOrientation)) * 0.5f, faceOrientation, false).Material = new Material();
                                this.FarawayWaterMesh.AddFace(Vector3.One, new Vector3(-0.5f, -1f, -0.5f) + FezMath.Abs(FezMath.AsVector(faceOrientation)) * 0.5f, faceOrientation, false).Material = new Material();
                            }
                        }
                        group2.CustomData = group1.CustomData = (object)farawayPlaceData;
                        group2.Position   = group1.Position = farawayPlaceData.OriginalCenter;
                        group2.Texture    = group1.Texture = (Texture)texture;
                        group2.Material   = new Material()
                        {
                            Opacity = 0.125f
                        };
                        group1.Material = new Material()
                        {
                            Opacity = 0.125f
                        };
                        if (volume1.ActorSettings == null)
                        {
                            volume1.ActorSettings = new VolumeActorSettings();
                        }
                        volume1.ActorSettings.DestinationSong = songName;
                        switch (num1)
                        {
                        case 1:
                            volume1.ActorSettings.DestinationRadius = 80f;
                            break;

                        case 2:
                            volume1.ActorSettings.DestinationRadius = 40f;
                            break;

                        case 3:
                            volume1.ActorSettings.DestinationRadius = 26.66667f;
                            break;

                        case 4:
                            volume1.ActorSettings.DestinationRadius = 20f;
                            break;

                        case 5:
                            volume1.ActorSettings.DestinationRadius = 16f;
                            break;
                        }
                        volume1.ActorSettings.DestinationPixelsPerTrixel = (float)num1;
                        volume1.ActorSettings.DestinationOffset          = vector2;
                    }
                }
            }
        }